# Create Invoice — Xendit

> Create a new invoice on Xendit platform See the documentation

- Key: `xendit-create-invoice`
- Type: Action (Write)
- Version: 0.0.2
- App: Xendit (`xendit`) — https://pipedream.com/apps/xendit.md
- This page (HTML): https://pipedream.com/apps/xendit/actions/create-invoice
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/xendit/actions/create-invoice/create-invoice.mjs

## Description

Create a new invoice on Xendit platform [See the documentation](https://developers.xendit.co/api-reference/#create-invoice)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `externalId` | `string` | Yes | ID of your choice (typically the unique identifier of an invoice in your system). |
| `amount` | `string` | Yes | Amount on the invoice. Min and max amounts are stated here. The amount should be inclusive of any fees and or items that you may choose to include. If there is a difference between this amount and the sum of the price in the items parameters and or fees parameter, Xendit will refer to this amount parameter to create invoice. Do take note: if the currency or default currency is IDR and the amount includes decimals (e.g IDR 4550.50), the amount will be truncated to IDR 4550. |
| `description` | `string` | No | Description of invoice - you can use this field to list what items are being paid for, or anything else of your choice that describes the function of the invoice. |
| `givenNames` | `string` | No | Given name of the customer |
| `surname` | `string` | No | Surname of the customer |
| `email` | `string` | No | Email address of the customer |
| `mobileNumber` | `string` | No | Mobile phone number of the customer in E164 format |
| `addressCity` | `string` | No | The city of the customer |
| `addressCountry` | `string` | No | The country of the customer |
| `addressPostalCode` | `string` | No | The postal code of the customer |
| `addressstate` | `string` | No | The state of the customer |
| `addressLine1` | `string` | No | The address line 1 of the customer |
| `addressLine2` | `string` | No | The address line 2 of the customer |
| `invoiceCreatedNotification` | `string[]` | No | Specify which channel you want to notify your end customer through when you create a payment/invoice. If you do not specify values for this object, your end user will not be notified for this notification type. |
| `invoiceReminderNotification` | `string[]` | No | Specify which channel you want to notify your end customer through when you want to remind your customer to complete their payment. If you do not specify values for this object, your end user will not be notified for this notification type. |
| `invoicePaidNotification` | `string[]` | No | Specify which channel you want to notify your end customer through when they have successfully completed payment. If you do not specify values for this object, your end user will not be notified for this notification type. |
| `invoiceDuration` | `integer` | No | Duration of time that the end customer is given to pay the invoice before expiration (in seconds, since creation). Default is 24 hours (86,400 seconds). |
| `successRedirectUrl` | `string` | No | URL to redirect the customer to after successful payment. |
| `failureRedirectUrl` | `string` | No | URL to redirect the customer to after failed payment. |
| `paymentMethods` | `string[]` | No | Specify the payment channels that you wish to be available on your Invoice. |
| `currency` | `string` | No | Currency of the amount that you created. |
| `locale` | `string` | No | The default language to display |
| `items` | `string[]` | No | Array of items JSON objects describing the item(s) purchased. Max array size: 75. Mandatory for PayLater payment method. See the documentation for further details. |
| `fees` | `string[]` | No | Array of items JSON objects describing the fee(s) that you charge to your end customer. This can be an admin fee, logistics fee, etc. This amount will be included in the total invoice amount and will be transferred to your balance when the transaction settles. Max array size: 10. See the documentation for further details. |
| `metadata` | `object` | No | An object containing any additional information you want to include with the invoice. This will be returned in the response and can be used for tracking or reporting purposes. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "xendit",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "xendit-create-invoice",
  arguments: {
    externalId: "External ID",
    amount: "Amount",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "xendit-create-invoice",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    xendit: { authProvisionId: "apn_xxxxxxx" },
    externalId: "External ID",
    amount: "Amount",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "xendit-create-invoice",
    "configured_props": {
      "xendit": { "authProvisionId": "apn_xxxxxxx" },
      "externalId": "External ID",
      "amount": "Amount"
    }
  }'
```

---

- App: https://pipedream.com/apps/xendit.md · All apps: https://pipedream.com/apps
