Square: Create Merchant Custom Attribute Definition
Square merchantCustomAttributes.createMerchantCustomAttributeDefinition: arguments, response, policy and SDK examples.
← Merchant custom attributes operations · Get started
Operation square.createmerchantcustomattributedefinition
Provider route: POST /v2/merchants/custom-attribute-definitions. 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"]["createMerchantCustomAttributeDefinition"]>[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.createMerchantCustomAttributeDefinition(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.create_merchant_custom_attribute_definition(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
body | Model | Required within parent | Expand Create Merchant Custom Attribute Definition — request body — body |
Referenced models: Create Merchant Custom Attribute Definition — 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 Create Merchant Custom Attribute Definition — response body |
Referenced models: Create Merchant Custom Attribute Definition — response body
Schemas
Section titled “Schemas”2 more schemas are linked from the tables above, on the schema pages.
Create Merchant Custom Attribute Definition — request body — body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents a [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) request. |
custom_attribute_definition | Model | Required within parent | Expand Create Order Custom Attribute Definition — request body — body custom attribute definition The custom attribute definition to create. Note the following: - With the exception of the `Selection` data type, the `schema` is specified as a simple URL to the JSON schema definition hosted on the Square CDN. For more information, including supported values and constraints, see [Supported data types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). - `name` is required unless `visibility` is set to `VISIBILITY_HIDDEN`. |
idempotency_key | string | Optional | 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 |
Referenced models: Create Order Custom Attribute Definition — request body — body custom attribute definition
Create Merchant Custom Attribute Definition — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents a [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) response. Either `custom_attribute_definition` or `errors` is present in the response. |
custom_attribute_definition | Model | Optional | Expand Create Order Custom Attribute Definition — response body — custom attribute definition The new custom attribute definition. |
errors | array | Optional | Any errors that occurred during the request. |
errors[] | Model | Each item | Expand Get Shift — response body — errors item |
Referenced models: Create Order Custom Attribute Definition — response body — custom attribute definition, Get Shift — response body — errors item
Create Order Custom Attribute Definition — request body — body custom attribute definition
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents a definition for custom attribute values. A custom attribute definition specifies the key, visibility, schema, and other properties for a custom attribute. |
created_at | string | Optional | The timestamp that indicates when the custom attribute definition was created, in RFC 3339 format. Read only: true |
description | JSON | Optional | |
description (anyOf 1) | string | Alternative | Seller-oriented description of the custom attribute definition, including any constraints that the seller should observe. May be displayed as a tooltip in Square UIs. This field is required if the `visibility` field is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Maximum length: 255 |
description (anyOf 2) | null | Alternative | |
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 (-). This field can not be changed after the custom attribute definition is created. This field is required when creating a definition and must be unique per application, seller, and resource type. Minimum length: 1 Pattern: ^([a-zA-Z0-9\._-]+:)?[a-zA-Z0-9\._-]{1,60}$ |
key (anyOf 2) | null | Alternative | |
name | JSON | Optional | |
name (anyOf 1) | string | Alternative | The name of the custom attribute definition for API and seller-facing UI purposes. The name must be unique within the seller and application pair. This field is required if the `visibility` field is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Maximum length: 255 |
name (anyOf 2) | null | Alternative | |
schema | JSON | Optional | |
schema (anyOf 1) | object | Alternative | The JSON schema for the custom attribute definition, which determines the data type of the corresponding custom attributes. For more information, see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). This field is required when creating a definition. |
schema (anyOf 2) | null | Alternative | |
updated_at | string | Optional | The timestamp that indicates when the custom attribute definition was created or most recently updated, in RFC 3339 format. Read only: true |
version | integer | Optional | Read only. The current version of the custom attribute definition. The value is incremented each time the custom attribute definition is updated. When updating a custom attribute definition, you can provide this field and specify the current version of the custom attribute definition to enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency). On writes, this field must be set to the latest version. Stale writes are rejected. 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 | JSON | Optional | |
visibility (anyOf 1) | string | Alternative | 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. Specifies how the custom attribute definition and its values should be shared with the seller and other applications. If no value is specified, the value defaults to `VISIBILITY_HIDDEN`. See [Visibility](#type-visibility) for possible values One of: VISIBILITY_HIDDEN, VISIBILITY_READ_ONLY, VISIBILITY_READ_WRITE_VALUES |
visibility (anyOf 2) | null | Alternative |
Create Order Custom Attribute Definition — response body — custom attribute definition
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents a definition for custom attribute values. A custom attribute definition specifies the key, visibility, schema, and other properties for a custom attribute. |
created_at | string | Optional | The timestamp that indicates when the custom attribute definition was created, in RFC 3339 format. Read only: true |
description | JSON | Optional | |
description (anyOf 1) | string | Alternative | Seller-oriented description of the custom attribute definition, including any constraints that the seller should observe. May be displayed as a tooltip in Square UIs. This field is required if the `visibility` field is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Maximum length: 255 |
description (anyOf 2) | null | Alternative | |
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 (-). This field can not be changed after the custom attribute definition is created. This field is required when creating a definition and must be unique per application, seller, and resource type. Minimum length: 1 Pattern: ^([a-zA-Z0-9\._-]+:)?[a-zA-Z0-9\._-]{1,60}$ |
key (anyOf 2) | null | Alternative | |
name | JSON | Optional | |
name (anyOf 1) | string | Alternative | The name of the custom attribute definition for API and seller-facing UI purposes. The name must be unique within the seller and application pair. This field is required if the `visibility` field is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Maximum length: 255 |
name (anyOf 2) | null | Alternative | |
schema | JSON | Optional | |
schema (anyOf 1) | object | Alternative | The JSON schema for the custom attribute definition, which determines the data type of the corresponding custom attributes. For more information, see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). This field is required when creating a definition. |
schema (anyOf 2) | null | Alternative | |
updated_at | string | Optional | The timestamp that indicates when the custom attribute definition was created or most recently updated, in RFC 3339 format. Read only: true |
version | JSON | Optional | |
version (anyOf 1) | integer | Alternative | Read only. The current version of the custom attribute definition. The value is incremented each time the custom attribute definition is updated. When updating a custom attribute definition, you can provide this field and specify the current version of the custom attribute definition to enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency). On writes, this field must be set to the latest version. Stale writes are rejected. 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 | JSON | Optional | |
visibility (anyOf 1) | string | Alternative | 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. Specifies how the custom attribute definition and its values should be shared with the seller and other applications. If no value is specified, the value defaults to `VISIBILITY_HIDDEN`. See [Visibility](#type-visibility) for possible values Known values: VISIBILITY_HIDDEN, VISIBILITY_READ_ONLY, VISIBILITY_READ_WRITE_VALUES |
visibility (anyOf 2) | null | Alternative |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: square.createmerchantcustomattributedefinition. Catalog operation: CreateMerchantCustomAttributeDefinition. 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"}