# Read and write values

Discover definitions, translate their names and choice labels, then upsert values by namespace.key on owner resources.

After install, use your app token (`tpat_` or `tast_`) against the Store API. Value endpoints address definitions by **`namespace` and `key`**, never by raw definition IDs.

## Discover definitions

`GET /api/2025-01/metafield-definitions?owner_type={owner}` lists definitions visible to your token: definitions your app owns, merchant-owned definitions, and another app's definitions only when `app_access` is `shared`. Use this when you need to enumerate keys at runtime. Discovery does not create schema: your definitions come from your release declaration.

## Translate definition names and choice labels

A definition's name is the label shoppers see next to its value, for example in the platform metafield block. Translate names per locale with `GET`/`PUT /api/2025-01/metafield-definitions/{id}/translations/{locale}` (body `{"translations": {"name": "…"}}`), or many at once with `GET /api/2025-01/metafield-definitions/translations/{locale}?ids=…` and `PUT /api/2025-01/metafield-definitions/translations` (rows `{id, locale, fields}`). Select choice labels translate with `/metafield-definitions/{id}/choices/{choiceKey}/translations/{locale}`. Your app can translate only definitions it owns, and only names whose `merchant_access` is `read_write`, the names merchants also translate in Store Admin and translation CSV. These calls need `read_translations` or `write_translations` plus the definition owner's read scope, and send no webhooks.

## Write values

`PUT` on the owner resource accepts an array of `{namespace, key, value}` entries. Send `null` or an empty string as `value` to delete a value. Access is re-checked on every write: your app can set values only on definitions it owns. `app_access=shared` grants reads to other appropriately scoped apps, not writes. Store admin tokens (`tsat_`) and connected AI tools write as the merchant: merchant-owned definitions, and your definitions only when `merchant_access` is `read_write`.

| Owner | Value endpoints | Typical scopes |
| --- | --- | --- |
| Product | `GET` / `PUT` `/products/{id}/metafields` | `read_products` / `write_products` |
| Variant | `GET` / `PUT` `/products/{id}/variants/{variantId}/metafields` | `read_products` / `write_products` |
| Customer | `GET` / `PUT` `/customers/{id}/metafields` | `read_customers` / `write_customers` |
| Collection | `GET` / `PUT` `/collections/{id}/metafields` | `read_products` / `write_products` |
| Category | `GET` / `PUT` `/categories/{id}/metafields` | `read_products` / `write_products` |
| Page | `GET` / `PUT` `/pages/{id}/metafields` | `read_pages` / `write_pages` |
| Brand | `GET` / `PUT` `/brands/{id}/metafields` | `read_products` / `write_products` |
| Vendor | `GET` / `PUT` `/vendors/{id}/metafields` | `read_products` / `write_products` |
| Order | `GET` / `PUT` `/orders/{orderId}/metafields` | `read_orders` / `write_orders` |
| Order line | `GET` / `PUT` `/orders/{orderId}/items/{itemId}/metafields` | `read_orders` / `write_orders` |
| Store (shop) | `GET` / `PUT` `/store/metafields` | `read_storefront` / `write_storefront` |

## Clear one value

Clear one value with DELETE on its existing value-list path followed by /{namespace}/{key}. This is available for products, variants, categories, brands, vendors, collections, pages, blog posts, blog categories, customers, orders, order items, and store. Use the same write scope as set. Apps can clear only values belonging to their own definitions. The value row and its translations are removed; the definition and other resources are preserved. Repeating a clear for an absent value succeeds with the normal success envelope and no deleted-count field. Unknown or unreadable definitions fail. No body or confirmation token is needed. Cart and wishlist line properties use their line-property APIs instead.

Metafield value webhooks follow API read access for every owner, including products, variants, customers, content, orders, order items, and store. Active app subscriptions need the topic’s owner read scope. Merchant-owned values reach every such app; app-owned values reach the owning app and, when app_access is shared, other scoped apps. Private app-owned values reach only the owning app. Each subscriber’s payload is visibility-filtered using the same definition access rules as API reads; merchant endpoints receive only merchant-readable values. These rules also apply to supported value-translation events. Definition webhooks retain their separate owning-app policy.

Reading a value translation requires the owner read scope plus read_translations. Setting or clearing it requires the owner write scope plus write_translations. Staff also need the corresponding owner and Languages permissions. App ownership and merchant-access restrictions still apply.

## Example: set a product metafield

```json
{
  "metafields": [
    {
      "namespace": "app:my-app",
      "key": "material",
      "value": "organic-cotton"
    }
  ]
}
```

Call `PUT /api/2025-01/products/{product_id}/metafields` with the JSON body above. Replace `app:my-app` with your live namespace (`app:{slug}`) and `material` with your declared key.

> A store has one set of shop-level values, so `/store/metafields` has no owner ID: the token's store is the owner. Discover its definitions with `owner_type=store`. Reads and writes follow the same access rules as every other owner, and changes send `store_metafields/*` webhooks.

## Further reference

See the **Metafield definitions** Store API page for the discovery response shape, owner-type to scope mapping, and visibility matrix. Each owner resource guide (Products, Customers, …) documents its metafield list/set/delete endpoints, translation routes where applicable, and webhook topics for value changes.

