Skip to content

Create definition

POST/admin/v1/stores/{store_id}/metafield-definitions
  • settings:write
  • Idempotency-Key supported

Add a definition.

Path parameters

  • store_idstringrequired

    The store's ID, like store_01k8qs5s…. Apps get it with the install, in the OAuth redirect and the token response.

Headers

  • Idempotency-Keystring

    Send the same key to retry safely: the first answer is replayed for 24 hours.

  • shop-api-versionYYYY-MM

    The version to answer in. Without it, your app’s pinned version, else the newest.

Body

  • owner_typeenumrequired

    What a metafield belongs to.

    • product
    • variant
    • collection
    • customer
    • order
    • store
  • keystringrequired
  • typestringrequired

    single_line_text, multi_line_text, integer, decimal, boolean, date, date_time, url, color, json, product_reference, variant_reference, collection_reference, file_reference; most also as list.…. Fixed once created.

  • namestringrequired
  • namespacestring · or null

    Default custom.

  • descriptionstring · or null
  • validationsobject

    Optional rules a definition puts on its values (on each item of a list).

  • storefrontboolean
  • shopper_editableboolean

    The signed-in shopper sets it from their account: customers' fields that storefronts read, of a type a shopper can type or pick.

Returns

201 Created.

Errors

  • 403forbiddenMissing settings:write.
  • 409The identifier is taken (identifier_taken), or the owner type has 200 definitions (limit_reached).
  • 422validation_failedValidation failed.