# Create Invoice — Invoiced

> Creates a new invoice in Invoiced. See the documentation

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

## Description

Creates a new invoice in Invoiced. [See the documentation](https://developer.invoiced.com/api/invoices#create-an-invoice)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `customer` | `string` | Yes | The ID of the customer this invoice is for Options are loaded from the connected account. |
| `name` | `string` | No | Invoice name for internal use, defaults to "Invoice" |
| `number` | `string` | No | The reference number assigned to the invoice, defaults to next # in auto-numbering sequence |
| `currency` | `string` | No | 3-letter ISO code - defaults to account currency |
| `autoplay` | `boolean` | No | AutoPay enabled? - inherited from customer by default |
| `paymentTerms` | `string` | No | Payment terms for the invoice, i.e. "NET 30" - inherited from customer by default |
| `purchaseOrder` | `string` | No | The customer's purchase order number |
| `date` | `string` | No | Invoice date - defaults to current timestamp. Format YYYY-MM-DDTHH:MM:SSZ. |
| `dueDate` | `string` | No | Due date - computed from paymentTerms when not supplied. Format YYYY-MM-DDTHH:MM:SSZ. |
| `draft` | `boolean` | No | When false, the invoice is considered outstanding, or when true, the invoice is a draft |
| `closed` | `boolean` | No | Marks an invoice as closed |
| `items` | `string[]` | Yes | JSON array of invoice items. Example: [{ "amount": 45, "catalog_item": null, "description": null, "discountable": true, "discounts": [], "id": 7, "metadata": [], "name": "Copy Paper, Case", "object": "line_item", "quantity": 1, "taxable": true, "taxes": [], "type": "product", "unit_cost": 45 }] |
| `notes` | `string` | No | Additional notes displayed on invoice |
| `discounts` | `string[]` | No | A list of coupon Ids Options are loaded from the connected account. |
| `taxes` | `string[]` | No | Array of Tax Rate IDs Options are loaded from the connected account. |
| `metadata` | `object` | No | A hash of key/value pairs that can store additional information about this object. |
| `disabledPaymentMethods` | `string[]` | No | Array of payment method IDs to disable for the customer. i.e., ["wire_transfer", "credit_card"] |
| `calculateTaxes` | `boolean` | No | Disables tax calculation, default is true |

## 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": "invoiced",
      },
    },
  },
)

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: "invoiced-create-invoice",
  arguments: {
    customer: "Customer ID",
    name: "Name",
  },
})
```

**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: "invoiced-create-invoice",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    invoiced: { authProvisionId: "apn_xxxxxxx" },
    customer: "Customer ID",
    name: "Name",
  },
})

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": "invoiced-create-invoice",
    "configured_props": {
      "invoiced": { "authProvisionId": "apn_xxxxxxx" },
      "customer": "Customer ID",
      "name": "Name"
    }
  }'
```

---

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