Skip to content

Update a custom field

PATCH
/customer-fields/{key}
curl --request PATCH \
--url https://api.usesonora.com/v1/customer-fields/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "label": "example", "options": [ "example" ] }'

Rename a custom field, or add options to a select field. The key and every customer’s value stay as they are, so nothing reading the field by key notices a rename. A field’s type can’t change, and a select’s options can be added and reordered but not removed: customers may hold them. A label another field already shows is 409 customer_field_exists.

Requires the custom-fields:manage scope. API keys only.

key
required
string

The field’s key, as GET /customer-fields lists it.

Media typeapplication/json

What to change. The key, the type and every customer’s value stay as they are.

object
label

How Sonora shows the field. No other field may show the same label, ignoring case; runs of spaces are kept as one.

string
>= 1 characters <= 100 characters
options

A select field’s options, in the order to show them: every option it has, plus any to add. Leaving one out is 422, since customers may hold it. Adding is 422 past 50 options, or past the field’s own count if it already has more, and an option added must be 1 to 100 characters.

Array<string>
>= 1 items
Examplegenerated
{
"label": "example",
"options": [
"example"
]
}

The field, as saved.

Media typeapplication/json

A custom field on customers.

object
key
required

The key in a customer’s customFields.

string
label
required
string
type
required

date is YYYY-MM-DD; datetime an ISO 8601 instant; select one of options (or several, with multiple); user a list of people.

string
Allowed values: string number boolean date datetime select user array object
format
required

How the value is meant: currency, percentage, email, url, phone, … Null when it’s plain.

string | null
options
required
Any of:
Array<string>
multiple
required

Whether the value is a list: a multi-select, or a user field holding several people.

boolean
Example
{
"type": "string"
}

invalid_json: The request body is not valid JSON.

invalid_request: A parameter or body field is missing, malformed or unknown; details.issues names each.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

unauthorized: The Authorization header is missing, or the key is invalid, revoked or expired.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

insufficient_scope: The key or token lacks the scope this endpoint needs, and details.required names it; or an OAuth access token called an endpoint only an API key can.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

customer_field_not_found: No custom field with that key, or not one Sonora shows: fields an import hid or marked sensitive are never found.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

customer_field_exists: A custom field already has that label; details.key names it when it’s one the API shows.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

payload_too_large: The request body is too large; details.maxBytes gives the limit.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

invalid_fields: A field’s value can’t be saved, so nothing was; details.issues names each field and why.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

rate_limited: Too many requests for this key; retry after Retry-After seconds.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

internal_error: Something went wrong on Sonora’s side. Retry, and quote requestId if it persists.

Media typeapplication/json

The one error shape every endpoint answers with.

object
error
required
object
code
required

Stable snake_case code to branch on; see the error table.

string
message
required

For humans; may change.

string
details
object
key
additional properties
requestId
required

Quote it when asking for help.

string | null
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {
"additionalProperty": "example"
},
"requestId": "example"
}
}

Try it

Try it runs the reference's read endpoints, and this one changes data, so it needs an API key with the custom-fields:manage scope. Create a key in Sonora under Settings → API and call it from your own code.