Skip to content

Create an attribute value

POST
/stores/{storeRef}/attributes/{attributeId}/values
curl --request POST \
--url https://apibase.ecomweb.app/api/v1/stores/example/attributes/1/values \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '{ "value": "blue", "display_value": "Blue", "swatch_type": "none", "swatch_value": "#0000FF", "sort_order": 1, "taxonomy_value_code": "blue" }'

Adds a value, such as Blue for Color, to the attribute. A value that already exists on the attribute is rejected with a 400 error and the code ATTRIBUTE_VALUE_TAKEN. An attribute that does not exist is reported as a 400 error with the code ATTRIBUTE_NOT_FOUND.

Required scopes: write:products

attributeId
required
integer

The attribute ID.

storeRef
required
string

The store’s ref, as returned by GET /stores.

Media typeapplication/json
object
value
required

Raw value

string
<= 255 characters

Example

blue
display_value
required

Display value

string
<= 255 characters

Example

Blue
swatch_type

Swatch rendering type

string
Allowed values: none color image

Example

none
swatch_value

Swatch payload — a CSS color for swatch_type=color, or an image URL for swatch_type=image

string

Example

#0000FF
sort_order

Sort order among the attribute’s values

number
taxonomy_value_code

Global facet bucket. Required when the parent attribute carries a taxonomy code.

string
<= 100 characters

Example

blue
Media typeapplication/json
object
id
required

Attribute value ID.

number
attribute_id
required

ID of the attribute this value belongs to.

number
value
required

Stored value, such as “red”.

string
display_value
required

Value as shown to shoppers, such as “Red”.

string
swatch_type
required

Swatch kind: none, color or image.

string
swatch_value
required

Swatch content: a color code or an image URL. Empty when there is no swatch.

string
sort_order
required

Position of the value within its attribute.

number
nullable
created_at
required

When the value was created, as an ISO 8601 timestamp.

string
updated_at
required

When the value was last updated, as an ISO 8601 timestamp.

string
taxonomy_value_code
required

Code of the global taxonomy value this one maps to, or null.

string
nullable

Example generated

{
"id": 1,
"attribute_id": 1,
"value": "example",
"display_value": "example",
"swatch_type": "example",
"swatch_value": "example",
"sort_order": 1,
"created_at": "example",
"updated_at": "example",
"taxonomy_value_code": "example"
}

The request is malformed or failed validation.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}