> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Publish Invoice

> Publishes the specified draft invoice.

`square.publishInvoice` publishes the specified draft invoice.

## Example

```ts automations/square-publish-invoice.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { square } from "automate.ax/square"

export default automation("Publish Square Invoice", () => {
  onDashboardRun({ title: "Publish Square Invoice" })

  square.publishInvoice({
    invoiceId: "invoice_id",
    version: 1,
    idempotencyKey: "32da42d0-1997-41b0-826b-f09464fc2c2e",
  })
})
```

## Inputs

Every input accepts a compatible signal. It requires `INVOICES_WRITE` and `ORDERS_WRITE`.

| Field            | Type             | Required | Default | Description                                                                                                                                                                                                                                                                                                                  |
| ---------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `invoiceId`      | `string`         | Yes      | —       | The ID of the invoice to publish.                                                                                                                                                                                                                                                                                            |
| `version`        | `number`         | Yes      | —       | The version of the invoice to publish. This must match the current version of the invoice; otherwise, the request is rejected.                                                                                                                                                                                               |
| `idempotencyKey` | `string \| null` | No       | —       | A unique string that identifies the `PublishInvoice` request. If you do not provide `idempotency_key` (or provide an empty string as the value), the endpoint treats each request as independent. For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). |

Use the official [PublishInvoice reference](https://developer.squareup.com/reference/square/invoices-api/publish-invoice) for provider field semantics and limits.

## Output

Returns the official `Square.PublishInvoiceResponse` response as a codec-safe object. Square integer money amounts remain `bigint` values.
