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

# Upsert Customer Custom Attribute

> Creates or updates a [custom attribute](entity:CustomAttribute) for a customer profile.

`square.upsertCustomerCustomAttribute` creates or updates a [custom attribute](entity:CustomAttribute) for a customer profile.

## Example

```ts automations/square-upsert-customer-custom-attribute.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { square } from "automate.ax/square"

export default automation("Upsert Square Customer Custom Attribute", () => {
  onDashboardRun({ title: "Upsert Square Customer Custom Attribute" })

  square.upsertCustomerCustomAttribute({
    customerId: "customer_id",
    key: "key",
    customAttribute: {
      value: "Dune",
    },
  })
})
```

## Inputs

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

| Field             | Type                     | Required | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ----------------- | ------------------------ | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `customerId`      | `string`                 | Yes      | —       | The ID of the target customer profile.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `key`             | `string`                 | Yes      | —       | The key of the custom attribute to create or update. This key must match the `key` of a custom attribute definition in the Square seller account. If the requesting application is not the definition owner, you must use the qualified key.                                                                                                                                                                                                                                                                                                                                 |
| `customAttribute` | `Square.CustomAttribute` | Yes      | —       | The custom attribute to create or update, with the following fields: - `value`. This value must conform to the `schema` specified by the definition. For more information, see [Value data types](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attributes#value-data-types). - `version`. To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) control for an update operation, include this optional field and specify the current version of the custom attribute. |
| `idempotencyKey`  | `string \| null`         | No       | —       | A unique identifier for this request, used to ensure idempotency. For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).                                                                                                                                                                                                                                                                                                                                                                                 |

Use the official [UpsertCustomerCustomAttribute reference](https://developer.squareup.com/reference/square/customer-custom-attributes-api/upsert-customer-custom-attribute) for provider field semantics and limits.

## Output

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