Overview
A metafield is one typed value attached to one Salesive record. Use metafields to keep your app’s data next to the record it belongs to, instead of in a database of your own keyed by Salesive ids: a size chart on a product, a loyalty tier on a customer, a gift message on an order, a feature flag on the store. Every metafield has an owner, a namespace, a key, a type and a value:
Metafields need the
READ_METAFIELDS and WRITE_METAFIELDS scopes.
Namespaces
You never need to spell out your own namespace: send
"namespace": "$app" and Salesive expands it
to app--<your clientId>. Responses always show the expanded name. Your namespace is the same on
every store and survives a reinstall.
Another app’s namespace does not exist as far as your app can tell: it is left out of lists and
counts, a direct read is 404, and a write is 403. The merchant can read your namespace in the
dashboard but cannot edit it.
Namespaces are 2 to 100 characters and keys 1 to 64, using lowercase letters, digits, _ and -.
Value types
A record holds at most 200 metafields. A value that fails its type is a
400 with a message
naming the problem.
Endpoints
All paths are underhttps://api.salesive.com/api/v1 with your app_ token. The store comes from
your token; never send a shop id.
List a record’s metafields
GET /metafields?ownerType=product&ownerId=<id> (READ_METAFIELDS)
Optional namespace (or $app), key, page and limit (up to 250). Returns
{ metafields, total, page, limit }. An owner on another store, or one that does not exist, is a
404.
Get one
GET /metafields/:id (READ_METAFIELDS)
Set one
PUT /metafields (WRITE_METAFIELDS) creates or replaces the value for that owner, namespace and
key.
type out; if you send it, it must match.
Set many
POST /metafields/set (WRITE_METAFIELDS) with { "metafields": [ ... ] }, up to 25 rows, on any
mix of owners. Every row is checked before any is written, so one bad row fails the whole request
and nothing is saved. The error message names the row, such as metafields[3]: value must be a number. Returns the saved rows in the order sent.
Delete one
DELETE /metafields/:id (WRITE_METAFIELDS). Returns the deleted row’s identifiers.
Definitions
A definition is an optional schema for one key on one owner type. It fixes the type, adds validations, and is the only way to make a value readable by the storefront theme.
Creating a definition fails with
409 when existing values for the key have a different type.
Turning storefrontVisible on or off applies to the existing values at once. Deleting a
definition keeps the values but makes them private again. A store can have 200 definitions per
owner type. The same namespace rules apply: your app’s definitions are hidden from other apps.
On the storefront
Themes read storefront visible values from the Store API, for the store being browsed:-
GET /api/v1/products/:idincludesmetafields, keyed"<namespace>.<key>": -
GET /api/v1/metafields?ownerType=product&ownerIds=<id>,<id>(up to 50 ids) returns the same, grouped by owner id, for list pages.ownerType=shopreturns the store’s own values.
Webhooks
WithREAD_METAFIELDS your webhook URL receives metafields/created,
metafields/updated and metafields/deleted, and the same for metafield-definitions. Each
delivery covers one row, so a batch of 10 arrives as 10 deliveries, and adds which record and key
changed:
GET /metafields/:id. Changes in your own
namespace reach only your app, and you never hear about another app’s namespace.

