• Example searches: “transaction”, “CreateOrder”, “/v2/locations”, “inventory”, “delete customer”

You are viewing an old version of the API
Upsert customer custom attribute

POST /v2/customers/{customer_id}/custom-attributes/{key}

Creates or updates a custom attribute for a customer profile.

Use this endpoint to set the value of a custom attribute for a specified customer profile. A custom attribute is based on a custom attribute definition in a Square seller account, which is created using the CreateCustomerCustomAttributeDefinition endpoint.

To create or update a custom attribute owned by another application, the visibility setting must be VISIBILITY_READ_WRITE_VALUES. Note that seller-defined custom attributes (also known as custom fields) are always set to VISIBILITY_READ_WRITE_VALUES.

Name Description
customer_id
string

Required

The ID of the target customer profile.

key
string

Required

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.

Name Description
custom_attribute
CustomAttribute

Required

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.

  • version. To enable optimistic concurrency control for an update operation, include this optional field and specify the current version of the custom attribute.

idempotency_key
string

A unique identifier for this request, used to ensure idempotency. For more information, see Idempotency.

Max Length 45

Response Fields

Name Description
custom_attribute
CustomAttribute

The new or updated custom attribute.

errors
Error [ ]

Any errors that occurred during the request.

Examples

You are viewing an old version of the API
POST /v2/customers/{customer_id}/custom-attributes/{key}
cURL
  • cURL
  • Ruby
  • Python
  • C#
  • Java
  • PHP
  • Node.js
curl https://connect.squareup.com/v2/customers/Z57QXKM2FGXEQDV42W8RBZY7BR/custom-attributes/favoritemovie \
  -X POST \
  -H 'Square-Version: 2022-09-21' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "custom_attribute": {
      "value": "Dune"
    }
  }'
Response JSON
{
  "custom_attribute": {
    "key": "favoritemovie",
    "version": 1,
    "updated_at": "2022-04-26T15:50:27Z",
    "value": "Dune",
    "created_at": "2022-04-26T15:50:27Z",
    "visibility": "VISIBILITY_READ_ONLY"
  }
}