# Create Invoice — faktoora

> Create a new ZUGFeRD/xrechnung invoice. See the documentation

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

## Description

Create a new ZUGFeRD/xrechnung invoice. [See the documentation](https://api.faktoora.com/api/v1/api-docs/static/index.html)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `format` | `string` | Yes | The format of the invoice (ZUGFeRD/xrechnung). |
| `invoiceNumber` | `string` | Yes | The invoice number. |
| `issueDate` | `string` | Yes | The issue date of the invoice (YYYYMMDD). |
| `currency` | `string` | Yes | The currency of the invoice. |
| `buyerName` | `string` | Yes | The name of the buyer. |
| `buyerPostcode` | `string` | Yes | Buyer location postcode. |
| `buyerStreet` | `string` | Yes | Buyer location street. |
| `buyerCity` | `string` | Yes | Buyer location city. |
| `buyerCountry` | `string` | Yes | Buyer location country. |
| `invoiceItems` | `string[]` | Yes | A list of product objects. E.g. {"productId": "39887", "name": "Freezer Z7749", "quantity": "1", "unitCode": "C62", "price": 100, "taxes": [{"typeCode": "VAT", "categoryCode": "S", "rate": 16}] }. For further information about init code click here. For further information about Category Code click here |
| `additionalData` | `object` | No | An object to manual input other fields. Please check the fields from the API doc > POST /invoice > Request Body |

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

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: "faktoora-create-invoice",
  arguments: {
    format: "Format",
    invoiceNumber: "Invoice Number",
  },
})
```

**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: "faktoora-create-invoice",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    faktoora: { authProvisionId: "apn_xxxxxxx" },
    format: "Format",
    invoiceNumber: "Invoice Number",
  },
})

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": "faktoora-create-invoice",
    "configured_props": {
      "faktoora": { "authProvisionId": "apn_xxxxxxx" },
      "format": "Format",
      "invoiceNumber": "Invoice Number"
    }
  }'
```

---

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