Update the signed-in customer's metafields
const url = 'https://apibase.ecomweb.app/api/v1/tenant/stores/example/customers/metafields';const options = { method: 'PUT', headers: { 'x-storefront-api-key': '<x-storefront-api-key>', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"values":[{"namespace":"example","key":"example","value":{}}]}'};
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/tenant/stores/example/customers/metafields \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'x-storefront-api-key: <x-storefront-api-key>' \ --data '{ "values": [ { "namespace": "example", "key": "example", "value": {} } ] }'Sets values on the signed-in shopper’s customer record. Only fields the store has made writable by shoppers can be changed; a value of null clears one. Every value is validated before anything is written, so one invalid value rejects the whole request. Returns all the metafields the shopper may read, as the get route does.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The values to set. Each is validated against its definition before anything is written, and one invalid value fails the whole request.
Example generated
{ "values": [ { "namespace": "example", "key": "example", "value": {} } ]}Responses
Section titled “Responses”The metafields the shopper may read, keyed by namespace.key.
object
object
The metafield’s type, such as single_line_text_field or list.number_integer.
Example generated
{ "additionalProperty": { "value": {}, "type": "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"}