Skip to content

Update the signed-in customer's metafields

PUT
/tenant/stores/{storeRef}/customers/metafields
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.

storeRef
required
string

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

Media typeapplication/json
object
values

The values to set. Each is validated against its definition before anything is written, and one invalid value fails the whole request.

Array<object>
object
namespace
required

The definition’s namespace.

string
key
required

The definition’s key.

string
value
required

The new value, in the form the definition’s type defines. Send null to delete the stored value.

nullable
One of:
string

Example generated

{
"values": [
{
"namespace": "example",
"key": "example",
"value": {}
}
]
}

The metafields the shopper may read, keyed by namespace.key.

Media typeapplication/json
object
key
additional properties
object
value
required

The value in the form its type defines. A reference type resolves to the referenced resource’s public data.

nullable
One of:
string
type
required

The metafield’s type, such as single_line_text_field or list.number_integer.

string

Example generated

{
"additionalProperty": {
"value": {},
"type": "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"
}