# Create Invoice — Agiled

> Creates a new invoice in Agiled. See the documentation

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

## Description

Creates a new invoice in Agiled. [See the documentation](https://my.agiled.app/developers)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `invoiceNumber` | `integer` | Yes | Invoice Number in integer form. Don't include prefix. It must be 10 for example and never INV#10 |
| `clientId` | `integer` | Yes | The ID of a client. Options are loaded from the connected account. |
| `issueDate` | `string` | Yes | Issue Date (Use same date format as in your company settings). Eg. 2021-01-01 |
| `dueDate` | `string` | Yes | Due Date (Use same date format as in your company settings). Eg. 2021-01-01 |
| `currencyId` | `integer` | Yes | The currency to use for the invoice. Options are loaded from the connected account. |
| `recurringPayment` | `boolean` | Yes | If its a recurring profile or not |
| `discountType` | `string` | Yes | Discount Type |
| `discount` | `integer` | Yes | Discount. Eg. 10 |
| `subTotal` | `integer` | Yes | Sub Total. Eg. 100 |
| `total` | `integer` | Yes | Total. Eg. 120 |
| `billingFrequency` | `string` | Yes | Specifies billing frequency. Either day, week, month or year. |
| `billingInterval` | `integer` | Yes | The number of intervals between subscription billings. |
| `billingCycle` | `string` | Yes | How many times you want to bill? Eg. 1 |
| `note` | `string` | No | Notes in Invoice |
| `numberOfItems` | `integer` | Yes | The number of items to generate. Defaults to 1. |

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

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: "agiled-create-invoice",
  arguments: {
    invoiceNumber: 10,
    clientId: 10,
  },
})
```

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

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": "agiled-create-invoice",
    "configured_props": {
      "agiled": { "authProvisionId": "apn_xxxxxxx" },
      "invoiceNumber": 10,
      "clientId": 10
    }
  }'
```

---

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