Square: Upsert Merchant Custom Attribute
Square merchantCustomAttributes.upsertMerchantCustomAttribute: arguments, response, policy and SDK examples.
← Merchant custom attributes operations · Get started
Operation square.upsertmerchantcustomattribute
Provider route: POST /v2/merchants/{merchant_id}/custom-attributes/{key}. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/square with npm, or alter-sdk-square with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { SquareIntegration } from "@alter-ai/square";
async function execute(input: Parameters<SquareIntegration["merchantCustomAttributes"]["upsertMerchantCustomAttribute"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new SquareIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.merchantCustomAttributes.upsertMerchantCustomAttribute(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_square import SquareIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = SquareIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.merchant_custom_attributes.upsert_merchant_custom_attribute(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.merchant_id | string | Required within parent | |
path.key | string | Required within parent | |
body | Model | Required within parent | Expand Upsert Merchant Custom Attribute — request body — body |
Referenced models: Upsert Merchant Custom Attribute — request body — body
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Upsert Merchant Custom Attribute — response body |
Referenced models: Upsert Merchant Custom Attribute — response body
Schemas
Section titled “Schemas”3 more schemas are linked from the tables above, on the schema pages.
Upsert Merchant Custom Attribute — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents an [UpsertMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-UpsertMerchantCustomAttribute) response. Either `custom_attribute_definition` or `errors` is present in the response. |
custom_attribute | Model | Optional | Expand Upsert Order Custom Attribute — response body — custom attribute The new or updated custom attribute. |
errors | array | Optional | Any errors that occurred during the request. |
errors[] | Model | Each item | Expand Get Shift — response body — errors item |
Referenced models: Upsert Order Custom Attribute — response body — custom attribute, Get Shift — response body — errors item
Upsert Merchant Custom Attribute — request body — body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents an [UpsertMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-UpsertMerchantCustomAttribute) request. |
custom_attribute | Model | Required within parent | Expand Upsert Order Custom Attribute — request body — body custom attribute 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 [Supported data types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). - The version field must match the current version of the custom attribute definition to enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) If this is not important for your application, version can be set to -1. For any other values, the request fails with a BAD_REQUEST error. |
idempotency_key | JSON | Optional | |
idempotency_key (anyOf 1) | string | Alternative | 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). Maximum length: 45 |
idempotency_key (anyOf 2) | null | Alternative |
Referenced models: Upsert Order Custom Attribute — request body — body custom attribute
Upsert Order Custom Attribute — response body — custom attribute
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A custom attribute value. Each custom attribute value has a corresponding `CustomAttributeDefinition` object. |
created_at | string | Optional | The timestamp that indicates when the custom attribute was created, in RFC 3339 format. Read only: true |
definition | Model | Optional | Expand Create Order Custom Attribute Definition — response body — custom attribute definition A copy of the associated custom attribute definition object. This field is only set when the optional field is specified on the request. Read only: true |
key | JSON | Optional | |
key (anyOf 1) | string | Alternative | The identifier of the custom attribute definition and its corresponding custom attributes. This value can be a simple key, which is the key that is provided when the custom attribute definition is created, or a qualified key, if the requesting application is not the definition owner. The qualified key consists of the application ID of the custom attribute definition owner followed by the simple key that was provided when the definition was created. It has the format application_id:simple key. The value for a simple key can contain up to 60 alphanumeric characters, periods (.), underscores (_), and hyphens (-). Minimum length: 1 Pattern: ^([a-zA-Z0-9\._-]+:)?[a-zA-Z0-9\._-]{1,60}$ |
key (anyOf 2) | null | Alternative | |
updated_at | string | Optional | The timestamp that indicates when the custom attribute was created or was most recently updated, in RFC 3339 format. Read only: true |
value | JSON | Optional | |
value (anyOf 1) | JSON | Alternative | The value assigned to the custom attribute. It is validated against the custom attribute definition's schema on write operations. For more information about custom attribute values, see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). |
value (anyOf 2) | null | Alternative | |
version | JSON | Optional | |
version (anyOf 1) | integer | Alternative | Read only. The current version of the custom attribute. This field is incremented when the custom attribute is changed. When updating an existing custom attribute value, you can provide this field and specify the current version of the custom attribute to enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency). This field can also be used to enforce strong consistency for reads. For more information about strong consistency for reads, see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). |
version (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
visibility | string | Optional | The level of permission that a seller or other applications requires to view this custom attribute definition. The `Visibility` field controls who can read and write the custom attribute values and custom attribute definition. A copy of the `visibility` field value for the associated custom attribute definition. See [CustomAttributeDefinitionVisibility](#type-customattributedefinitionvisibility) for possible values Known values: VISIBILITY_HIDDEN, VISIBILITY_READ_ONLY, VISIBILITY_READ_WRITE_VALUES Read only: true |
Referenced models: Create Order Custom Attribute Definition — response body — custom attribute definition
Get Shift — response body — errors item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents an error encountered during a request to the Connect API. See [Handling errors](https://developer.squareup.com/docs/build-basics/handling-errors) for more information. |
category | string | Required within parent | Indicates which high-level category of error has occurred during a request to the Connect API. The high-level category for the error. See [ErrorCategory](#type-errorcategory) for possible values Known values: API_ERROR, AUTHENTICATION_ERROR, INVALID_REQUEST_ERROR, RATE_LIMIT_ERROR, PAYMENT_METHOD_ERROR, REFUND_ERROR, MERCHANT_SUBSCRIPTION_ERROR, EXTERNAL_VENDOR_ERROR |
code | Model | Required within parent | Expand Get Shift — response body — errors item code The specific code of the error. See [ErrorCode](#type-errorcode) for possible values |
detail | string | Optional | A human-readable description of the error for debugging purposes. |
field | string | Optional | The name of the field provided in the original request (if any) that the error pertains to. |
Referenced models: Get Shift — response body — errors item code
Upsert Order Custom Attribute — request body — body custom attribute
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A custom attribute value. Each custom attribute value has a corresponding `CustomAttributeDefinition` object. |
created_at | string | Optional | The timestamp that indicates when the custom attribute was created, in RFC 3339 format. Read only: true |
definition | Model | Optional | Expand Create Order Custom Attribute Definition — request body — body custom attribute definition A copy of the associated custom attribute definition object. This field is only set when the optional field is specified on the request. Read only: true |
key | JSON | Optional | |
key (anyOf 1) | string | Alternative | The identifier of the custom attribute definition and its corresponding custom attributes. This value can be a simple key, which is the key that is provided when the custom attribute definition is created, or a qualified key, if the requesting application is not the definition owner. The qualified key consists of the application ID of the custom attribute definition owner followed by the simple key that was provided when the definition was created. It has the format application_id:simple key. The value for a simple key can contain up to 60 alphanumeric characters, periods (.), underscores (_), and hyphens (-). Minimum length: 1 Pattern: ^([a-zA-Z0-9\._-]+:)?[a-zA-Z0-9\._-]{1,60}$ |
key (anyOf 2) | null | Alternative | |
updated_at | string | Optional | The timestamp that indicates when the custom attribute was created or was most recently updated, in RFC 3339 format. Read only: true |
value | JSON | Optional | |
value (anyOf 1) | JSON | Alternative | The value assigned to the custom attribute. It is validated against the custom attribute definition's schema on write operations. For more information about custom attribute values, see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). |
value (anyOf 2) | null | Alternative | |
version | integer | Optional | Read only. The current version of the custom attribute. This field is incremented when the custom attribute is changed. When updating an existing custom attribute value, you can provide this field and specify the current version of the custom attribute to enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency). This field can also be used to enforce strong consistency for reads. For more information about strong consistency for reads, see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). |
visibility | string | Optional | The level of permission that a seller or other applications requires to view this custom attribute definition. The `Visibility` field controls who can read and write the custom attribute values and custom attribute definition. A copy of the `visibility` field value for the associated custom attribute definition. See [CustomAttributeDefinitionVisibility](#type-customattributedefinitionvisibility) for possible values One of: VISIBILITY_HIDDEN, VISIBILITY_READ_ONLY, VISIBILITY_READ_WRITE_VALUES Read only: true |
Referenced models: Create Order Custom Attribute Definition — request body — body custom attribute definition
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: square.upsertmerchantcustomattribute. Catalog operation: UpsertMerchantCustomAttribute. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.
Required provider scopes: ["MERCHANT_PROFILE_WRITE"]
Pinned headers: {"Square-Version": "2026-11-18"}