{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://raw.githubusercontent.com/api-evangelist/square/main/json-schema/square-create-order-custom-attribute-definition-request-schema.json", "title": "CreateOrderCustomAttributeDefinitionRequest", "description": "Represents a create request for an order custom attribute definition.", "x-generated": "2026-10-12", "x-method": "derived", "x-generator": "derive-json-schema.py", "x-source": "openapi/square-ordercustomattributes-api-openapi.yml#/components/schemas/CreateOrderCustomAttributeDefinitionRequest", "type": "object", "x-release-status": "BETA", "required": [ "custom_attribute_definition" ], "properties": { "custom_attribute_definition": { "$ref": "#/$defs/CustomAttributeDefinition", "description": "The custom attribute definition to create. Note the following:\n- With the exception of the `Selection` data type, the `schema` is specified as a simple URL to the JSON schema\ndefinition hosted on the Square CDN. For more information, including supported values and constraints, see\n[Specifying the schema](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attribute-definitions#specify-schema).\n- If provided, `name` must be unique (case-sensitive) across all visible customer-related custom attribute definitions for the seller.\n- All custom attributes are visible in exported customer data, including those set to `VISIBILITY_HIDDEN`." }, "idempotency_key": { "type": "string", "description": "A unique identifier for this request, used to ensure idempotency. \nFor more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).", "minLength": 1, "maxLength": 45 } }, "$defs": { "CustomAttributeDefinition": { "type": "object", "description": "Represents a definition for custom attribute values. A custom attribute definition\nspecifies the key, visibility, schema, and other properties for a custom attribute.", "x-release-status": "PUBLIC", "properties": { "key": { "type": [ "string", "null" ], "description": "The identifier\nof the custom attribute definition and its corresponding custom attributes. This value\ncan be a simple key, which is the key that is provided when the custom attribute definition\nis created, or a qualified key, if the requesting\napplication is not the definition owner. The qualified key consists of the application ID\nof the custom attribute definition owner\nfollowed by the simple key that was provided when the definition was created. It has the\nformat application_id:simple key.\n\nThe value for a simple key can contain up to 60 alphanumeric characters, periods (.),\nunderscores (_), and hyphens (-).\n\nThis field can not be changed\nafter the custom attribute definition is created. This field is required when creating\na definition and must be unique per application, seller, and resource type.", "minLength": 1, "pattern": "^([a-zA-Z0-9\\._-]+:)?[a-zA-Z0-9\\._-]{1,60}$" }, "schema": { "type": [ "object", "null" ], "description": "The JSON schema for the custom attribute definition, which determines the data type of the corresponding custom attributes. For more information,\nsee [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). This field is required when creating a definition." }, "name": { "type": [ "string", "null" ], "description": "The name of the custom attribute definition for API and seller-facing UI purposes. The name must\nbe unique within the seller and application pair. This field is required if the\n`visibility` field is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.", "maxLength": 255 }, "description": { "type": [ "string", "null" ], "description": "Seller-oriented description of the custom attribute definition, including any constraints\nthat the seller should observe. May be displayed as a tooltip in Square UIs. This field is\nrequired if the `visibility` field is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.", "maxLength": 255 }, "visibility": { "$ref": "#/$defs/CustomAttributeDefinitionVisibility", "description": "Specifies how the custom attribute definition and its values should be shared with\nthe seller and other applications. If no value is specified, the value defaults to `VISIBILITY_HIDDEN`.\nSee [Visibility](#type-visibility) for possible values" }, "version": { "type": "integer", "description": "Read only. The current version of the custom attribute definition.\nThe value is incremented each time the custom attribute definition is updated.\nWhen updating a custom attribute definition, you can provide this field\nand specify the current version of the custom attribute definition to enable\n[optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency).\n\nOn writes, this field must be set to the latest version. Stale writes are rejected.\n\nThis field can also be used to enforce strong consistency for reads. For more information about strong consistency for reads,\nsee [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview)." }, "updated_at": { "type": "string", "description": "The timestamp that indicates when the custom attribute definition was created or most recently updated,\nin RFC 3339 format.", "readOnly": true }, "created_at": { "type": "string", "description": "The timestamp that indicates when the custom attribute definition was created, in RFC 3339 format.", "readOnly": true } } }, "CustomAttributeDefinitionVisibility": { "type": "string", "enum": [ "VISIBILITY_HIDDEN", "VISIBILITY_READ_ONLY", "VISIBILITY_READ_WRITE_VALUES" ], "x-enum-elements": [ { "name": "VISIBILITY_HIDDEN", "description": "The custom attribute definition and values are hidden from the seller (except on export\nof all seller data) and other developers." }, { "name": "VISIBILITY_READ_ONLY", "description": "The seller and other developers can read the custom attribute definition and values\non resources." }, { "name": "VISIBILITY_READ_WRITE_VALUES", "description": "The seller and other developers can read the custom attribute definition,\nand can read and write values on resources. A custom attribute definition\ncan only be edited or deleted by the application that created it." } ], "description": "The level of permission that a seller or other applications requires to\nview this custom attribute definition.\nThe `Visibility` field controls who can read and write the custom attribute values\nand custom attribute definition.", "x-release-status": "PUBLIC" } } }