Replace a product's attribute links
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/products/1/attributes';const options = { method: 'PUT', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"attributes":[{"attribute_id":12,"value_ids":[3,4],"position":0,"is_visible":true,"is_variation":true},{"custom_name":"Material","custom_values":["Cotton"],"position":1,"is_visible":true,"is_variation":false}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://apibase.ecomweb.app/api/v1/stores/example/products/1/attributes \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "attributes": [ { "attribute_id": 12, "value_ids": [ 3, 4 ], "position": 0, "is_visible": true, "is_variation": true }, { "custom_name": "Material", "custom_values": [ "Cotton" ], "position": 1, "is_visible": true, "is_variation": false } ] }'Replaces the product’s whole set of attribute links with the list you send, in one step, and returns the new set. Each link carries exactly one of attribute_id or custom_name, and only library attributes can drive variants. Dropping an attribute or a value that existing variants use is refused with a 409 error.
Required scopes: write:products
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The product ID.
The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Full set of attribute links for the product. Replaces all existing links.
object
Library attribute id. Mutually exclusive with custom_name — exactly one must be set.
Example
12Local (non-library) attribute name. Mutually exclusive with attribute_id.
Example
MaterialSelected attribute_values ids, for a library attribute_id
Example
[ 3, 4]Local values, for a custom_name link
Example
[ "Cotton"]Display order
Example
0Optional group label for organizing attributes
Example
SpecificationsWhether this attribute is shown on the storefront
Whether this attribute drives variant generation
Example
[ { "attribute_id": 12, "value_ids": [ 3, 4 ], "position": 0, "is_visible": true, "is_variation": true }, { "custom_name": "Material", "custom_values": [ "Cotton" ], "position": 1, "is_visible": true, "is_variation": false }]Responses
Section titled “Responses”object
The values the product uses for this attribute.
object
Stable key of the value within the link.
Value as shown to shoppers.
Swatch kind: none, color or image.
Swatch content: a color code or an image URL. Empty when there is no swatch.
ID of the library value, or null for a local value.
Code of the global taxonomy value this one maps to, or null.
Link ID. Use it to remove the link.
Display position of the attribute on the product.
Group label the attribute is shown under, or null.
Whether the attribute is shown on the storefront.
Whether the attribute drives the product’s variants.
ID of the library attribute, or null for a local attribute.
Name of the local attribute, or null for a library attribute.
The attribute’s name, whether library or local.
Code of the global taxonomy attribute this one maps to, or null.
Example generated
[ { "values": [ { "key": "example", "display": "example", "swatch_type": "example", "swatch_value": "example", "attribute_value_id": 1, "taxonomy_value_code": "example" } ], "id": 1, "position": 1, "group": "example", "is_visible": true, "is_variation": true, "attribute_id": 1, "custom_name": "example", "name": "example", "taxonomy_attribute_code": "example" }]The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
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.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The request conflicts with the resource’s current state.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}