# Create Invoice — sevDesk

> Creates a new invoice with optional details like invoice date, due date, discount amount, and invoice items. See the documentation

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

## Description

Creates a new invoice with optional details like invoice date, due date, discount amount, and invoice items. [See the documentation](https://api.sevdesk.de/)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `invoiceNumber` | `string` | No | The invoice number |
| `contactId` | `string` | Yes | The ID of the contact for the invoice. Options are loaded from the connected account. |
| `invoiceDate` | `string` | Yes | Needs to be provided as timestamp or dd.mm.yyyy |
| `header` | `string` | No | Normally consist of prefix plus the invoice number. |
| `headText` | `string` | No | Certain html tags can be used here to format your text. |
| `footText` | `string` | No | Certain html tags can be used here to format your text. |
| `timeToPay` | `integer` | No | The time the customer has to pay the invoice in days. |
| `discount` | `integer` | Yes | If you want to give a discount, define the percentage here. Otherwise provide zero as value. |
| `address` | `string` | No | Complete address of the recipient including name, street, city, zip and country. * Line breaks can be used and will be displayed on the invoice pdf. |
| `addressCountryId` | `string` | Yes | Can be omitted as complete address is defined in address attribute. Options are loaded from the connected account. |
| `payDate` | `string` | No | Needs to be timestamp or dd.mm.yyyy. |
| `deliveryDate` | `string` | No | Timestamp. This can also be a date range if you also use Delivery Date Until. |
| `deliveryDateUntil` | `string` | No | If the delivery date should be a time range, another timestamp can be provided in this attribute * to define a range from timestamp used in deliveryDate attribute to the timestamp used here. |
| `status` | `string` | Yes | Please have a look in Sevdesk's Types and status of invoices to see what the different status codes mean. |
| `smallSettlement` | `boolean` | No | Defines if the client uses the small settlement scheme. If yes, the invoice must not contain any vat. |
| `taxRate` | `string` | Yes | Is overwritten by invoice position tax rates. |
| `taxText` | `string` | Yes | A common tax text would be 'Tax 19%'. |
| `taxType` | `string` | Yes | Tax type of the invoice. |
| `taxSetId` | `string` | No | Tax set of the invoice. Needs to be added if you chose the tax type custom. Options are loaded from the connected account. |
| `paymentMethodId` | `string` | No | Payment method used for the invoice. Options are loaded from the connected account. |
| `sendDate` | `string` | No | The date the invoice was sent to the customer. |
| `invoiceType` | `string` | Yes | Type of the invoice. For more information on the different types, check this section |
| `currency` | `string` | Yes | Currency used in the invoice. Needs to be currency code according to ISO-4217. |
| `showNet` | `boolean` | No | If true, the net amount of each position will be shown on the invoice. Otherwise gross amount. |
| `sendType` | `string` | No | Type which was used to send the invoice. |
| `originId` | `string` | No | The Id of the order. Options are loaded from the connected account. |
| `customerInternalNote` | `string` | No | Internal note of the customer. Contains data entered into field 'Referenz/Bestellnummer'. |

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

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: "sevdesk-create-invoice",
  arguments: {
    invoiceNumber: "Invoice Number",
    contactId: "Contact ID",
  },
})
```

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

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": "sevdesk-create-invoice",
    "configured_props": {
      "sevdesk": { "authProvisionId": "apn_xxxxxxx" },
      "invoiceNumber": "Invoice Number",
      "contactId": "Contact ID"
    }
  }'
```

---

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