> ## 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.

# Create Terminal Refund

> Creates a request to refund an Interac payment completed on a Square Terminal.

`square.createTerminalRefund` creates a request to refund an Interac payment completed on a Square Terminal.

## Example

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

export default automation("Create Square Terminal Refund", () => {
  onDashboardRun({ title: "Create Square Terminal Refund" })

  square.createTerminalRefund({
    idempotencyKey: "402a640b-b26f-401f-b406-46f839590c04",
    refund: {
      paymentId: "5O5OvgkcNUhl7JBuINflcjKqUzXZY",
      amountMoney: {
        amount: BigInt("111"),
        currency: "CAD",
      },
      reason: "Returning items",
      deviceId: "f72dfb8e-4d65-4e56-aade-ec3fb8d33291",
    },
  })
})
```

## Inputs

Every input accepts a compatible signal. It requires `PAYMENTS_WRITE`.

| Field            | Type                    | Required | Default | Description                                                                                                                                                                                                                                                                   |
| ---------------- | ----------------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `idempotencyKey` | `string`                | Yes      | —       | A unique string that identifies this `CreateRefund` request. Keys can be any valid string but must be unique for every `CreateRefund` request. See [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information. |
| `refund`         | `Square.TerminalRefund` | No       | —       | The refund to create.                                                                                                                                                                                                                                                         |

Use the official [CreateTerminalRefund reference](https://developer.squareup.com/reference/square/terminal-api/create-terminal-refund) for provider field semantics and limits.

## Output

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