# Generate E-Invoice — PolyDoc

> Generate a ZUGFeRD or Factur-X hybrid PDF/A-3 e-invoice (EN 16931). See the documentation.

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

## Description

Generate a ZUGFeRD or Factur-X hybrid PDF/A-3 e-invoice (EN 16931). [See the documentation](https://docs.polydoc.tech).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `sourceType` | `string` | Yes | Where the content to render comes from. |
| `url` | `string` | No | The web page to render. Used when Source Type is url. |
| `html` | `string` | No | Inline HTML to render. Used when Source Type is html. |
| `templateId` | `string` | No | ID of a template saved in PolyDoc (for example jlE-whg). Used when Source Type is template. |
| `templateData` | `object` | No | Key-value data passed to the Liquid template renderer. Example: { "customerName": "Ada Lovelace", "invoiceNumber": "INV-1001" }. Used when Source Type is template. |
| `eInvoiceStandard` | `string` | Yes | E-invoice standard. |
| `eInvoiceProfile` | `string` | Yes | E-invoice profile. en16931 is the EU-standard profile. |
| `invoice` | `object` | Yes | Structured invoice data (EN 16931 CII XML). Every nested object is required — partial seller/buyer/line objects will fail API validation with a generic 400. Required shape: { "number": "INV-1001", "issueDate": "2026-06-16", "dueDate": "2026-07-16", "currencyCode": "EUR", "seller": { "name": "Acme GmbH", "address": { "line1": "Hauptstr 1", "city": "Berlin", "postalCode": "10115", "countryCode": "DE" }, "taxId": "DE123456789" }, "buyer": { "name": "Example SARL", "address": { "line1": "15 rue de Rivoli", "city": "Paris", "postalCode": "75001", "countryCode": "FR" } }, "lines": [{ "description": "Consulting", "quantity": 1, "unitPrice": 100, "lineTotal": 100, "vatRate": 20 }], "totalNetAmount": 100, "totalTaxAmount": 20, "totalGrossAmount": 120 } Required top-level: number, issueDate, currencyCode, seller, buyer, lines, totalNetAmount, totalTaxAmount, totalGrossAmount. Strongly recommended: dueDate (or paymentTerms). Required on each seller / buyer: name AND address (with line1, city, postalCode, countryCode all required — ISO 3166-1 alpha-2 country code). For EU B2B, also include taxId (VAT ID). Required on each item in lines: description (NOT name), quantity, unitPrice, lineTotal (= quantity × unitPrice, net before tax). Optional: vatRate (percent, defaults to 0), vatCategoryCode (S/Z/E, defaults to S), unitCode (UN/ECE code, defaults to C62). |
| `eInvoiceVerify` | `boolean` | No | Verify PDF/A and e-invoice compliance during generation. |
| `filename` | `string` | No | Output filename, used in the file written for download delivery. |
| `tag` | `string` | No | A short label (max 30 chars) for logging and analytics. |
| `timeout` | `integer` | No | Conversion timeout in milliseconds. The free tier is capped at 30000. |
| `deliveryMode` | `string` | Yes | How the result is delivered. |
| `presignedUrl` | `string` | No | A presigned upload URL (S3 / GCS / Azure). Used when Delivery Mode is cloudStorage. |
| `webhookUrl` | `string` | No | The URL the file is delivered to. Used when Delivery Mode is webhook. |
| `webhookOptions` | `object` | No | Optional webhook settings. Example: { "async": true, "method": "POST", "headers": { "X-Signature": "abc123" }, "retries": 3, "retryDelay": 1000, "timeout": 10000 }. |
| `advanced` | `object` | No | Raw object deep-merged into the request body for any API field not exposed above (for example pdf.watermark, pdf.pdfa, render, request). Advanced values win on conflict. |
| `syncDir` | `dir` | Yes | SyncDir |

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

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: "polydoc-generate-einvoice",
  arguments: {
    sourceType: "Source Type",
    url: "URL",
  },
})
```

**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: "polydoc-generate-einvoice",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    polydoc: { authProvisionId: "apn_xxxxxxx" },
    sourceType: "Source Type",
    url: "URL",
  },
})

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": "polydoc-generate-einvoice",
    "configured_props": {
      "polydoc": { "authProvisionId": "apn_xxxxxxx" },
      "sourceType": "Source Type",
      "url": "URL"
    }
  }'
```

---

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