# Update Invoice — FreshBooks

> Update an existing invoice in FreshBooks. See the documentation

- Key: `freshbooks-update-invoice`
- Type: Action (Write)
- Version: 0.0.1
- App: FreshBooks (`freshbooks`) — https://pipedream.com/apps/freshbooks.md
- This page (HTML): https://pipedream.com/apps/freshbooks/actions/update-invoice
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/freshbooks/actions/update-invoice/update-invoice.mjs

## Description

Update an existing invoice in FreshBooks. [See the documentation](https://www.freshbooks.com/api/invoices)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `accountId` | `string` | Yes | The FreshBooks account ID (accounting system id). Options are loaded from the connected account. |
| `invoiceId` | `string` | Yes | The ID of the invoice Options are loaded from the connected account. |
| `clientId` | `string` | No | The client (customer) ID to invoice Options are loaded from the connected account. |
| `invoiceNumber` | `string` | No | User-specified and visible invoice id |
| `createDate` | `string` | No | Invoice date (YYYY-MM-DD). Defaults to today if not set |
| `generationDate` | `string` | No | Date invoice generated from object, null if it wasn't, YYYY-MM-DD (string) if it was |
| `discountValue` | `string` | No | Discount percentage (0-100) applied to the subtotal |
| `discountDescription` | `string` | No | Public note about the discount |
| `poNumber` | `string` | No | Reference number for address on invoice |
| `currencyCode` | `string` | No | Three-letter currency code (e.g. USD, CAD) |
| `language` | `string` | No | Two-letter language code (e.g. en, fr) |
| `terms` | `string` | No | Terms listed on the invoice |
| `notes` | `string` | No | Notes displayed on the invoice |
| `address` | `string` | No | First line of address on invoice |
| `street` | `string` | No | Street for address on invoice |
| `street2` | `string` | No | Second line of street for address on invoice |
| `city` | `string` | No | City for address on invoice |
| `province` | `string` | No | Province for address on invoice |
| `code` | `string` | No | Zip code for address on invoice |
| `country` | `string` | No | Country for address on invoice |
| `dueOffsetDays` | `integer` | No | Number of days from creation that invoice is due. If not set, the due date will default to the date of issue |
| `lines` | `string[]` | No | A list of line items. Example: [{"lineId":1, "unit_cost":{"amount":"10.50","code":"USD"}, "updated":"2020-01-01 12:00:00" }] See the documentation |

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

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: "freshbooks-update-invoice",
  arguments: {
    accountId: "Account ID",
    invoiceId: "Invoice 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: "freshbooks-update-invoice",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    freshbooks: { authProvisionId: "apn_xxxxxxx" },
    accountId: "Account ID",
    invoiceId: "Invoice 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": "freshbooks-update-invoice",
    "configured_props": {
      "freshbooks": { "authProvisionId": "apn_xxxxxxx" },
      "accountId": "Account ID",
      "invoiceId": "Invoice ID"
    }
  }'
```

---

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