# Create Invoice — Clockify

> Creates a new invoice for a client in a Clockify workspace. Set Import From and Import To to bill tracked time: the invoice is created and the time entries logged in that period are imported as line items. Leave both blank to create an…

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

## Description

Creates a new invoice for a client in a Clockify workspace. Set **Import From** and **Import To** to bill tracked time: the invoice is created and the time entries logged in that period are imported as line items. Leave both blank to create an empty invoice. The invoice is created first and the tracked time is imported in a second request, so if the import fails the invoice still exists and can be removed with **Delete Invoice** or retried. Chain **Update Invoice** afterwards to set the subject, note or status. [See the documentation](https://docs.clockify.me/#tag/Invoice/operation/createInvoice)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `workspaceId` | `string` | Yes | Identifier of a workspace Options are loaded from the connected account. |
| `clientId` | `string` | Yes | Identifier of a client Options are loaded from the connected account. |
| `number` | `string` | Yes | Invoice number. Example: INV-001 |
| `issuedDate` | `string` | Yes | Issue date of the invoice, in ISO 8601 format. Example: 2026-08-05T00:00:00Z |
| `dueDate` | `string` | Yes | Due date of the invoice, in ISO 8601 format. Example: 2026-09-05T00:00:00Z |
| `currency` | `string` | Yes | Currency of the invoice. Example: USD |
| `timeViewMode` | `string` | No | How tracked time is presented on the invoice. TIME_SENSITIVE_VIEW lists entries individually, AGGREGATED_TIME_VIEW rolls them up |
| `importFrom` | `string` | No | Start of the period to bill tracked time from, in ISO 8601 format. Set this and Import To to import the time entries logged in that period as line items. Example: 2026-08-01T00:00:00Z |
| `importTo` | `string` | No | End of the period to bill tracked time from, in ISO 8601 format. Example: 2026-08-31T23:59:59Z |
| `projectIds` | `string[]` | No | Only bill time tracked against these projects. Leave blank to bill every project in the period. Use the List Projects action to find the IDs. |

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

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: "clockify-create-invoice",
  arguments: {
    workspaceId: "Workspace",
    clientId: "Client",
  },
})
```

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

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": "clockify-create-invoice",
    "configured_props": {
      "clockify": { "authProvisionId": "apn_xxxxxxx" },
      "workspaceId": "Workspace",
      "clientId": "Client"
    }
  }'
```

---

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