Metafield definitions
A Metafield definition declares a custom field you can attach to a resource. It sets the field’s namespace and key (which together identify it), the ownerType it applies to (such as product), the type of data it holds, and any validations and constraints that values must satisfy.
Definitions are the schema; the actual values are Metafields stored on individual owner records. Define a field once, then set its value on each product, variant, and so on.
The Metafield definition object
Section titled “The Metafield definition object”| Property | Type | Required | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | string | - | The resource's unique identifier (UUID). | ||||||||||||
name | string | - | The human-readable name of the metafield definition. | ||||||||||||
description | string | null | - | The description of the metafield definition. | ||||||||||||
namespace | string | - | The container for a group of metafields that the metafield definition is associated with. | ||||||||||||
key | string | - | The unique identifier for the metafield definition within its namespace. | ||||||||||||
ownerType | string | required | The resource type that the metafield definition is attached to. | ||||||||||||
type | string | required | The type of data that each of the metafields that belong to the metafield definition will store. | ||||||||||||
createdAt | string | - | The date and time when the resource was created (ISO 8601 format). | ||||||||||||
updatedAt | string | - | The date and time when the resource was last modified (ISO 8601 format). | ||||||||||||
validations | EmbeddedMetafieldDefinitionValidationResource[] | - | The validation rules applied to the values of metafields using this definition. | ||||||||||||
Show | |||||||||||||||
| Property | Type | Required | Description |
|---|---|---|---|
name | string | required | The type of validation rule |
value | string | required | The validation parameter value. Format depends on the validation type. |
constraintsEmbeddedMetafieldDefinitionConstraintResource[]Show constraints fields
| Property | Type | Required | Description |
|---|---|---|---|
key | string | required | The type of constraint rule |
values | string[] | required | Array of constraint values. Format depends on the constraint type. |
metafieldsCountintegerCommon workflows
Section titled “Common workflows”- Add a custom field. Create a definition with a
namespace,key,ownerTypeandtype, then set Metafield values on records of that owner type. - Constrain values. Attach
validations(for example a maximum length or a numeric range) so invalid values are rejected when a metafield is written. - Audit usage. Each definition reports a
metafieldsCount- how many records currently carry a value for it.
Type compatibility
Section titled “Type compatibility”Which validations and constraints you can attach is not free-form - it depends on the definition’s type, and the API rejects an incompatible combination with 422 Unprocessable Entity. The rules differ for the two:
- Validations depend on the
type. Anumber_decimalaccepts numeric validations (min_value,max_value,max_precision); a text type acceptsmin_length/max_length; ajsontype acceptsjson_schema; reference types accept none. The authoritative, always-current list for each type is theallowedValidationsfield on Metafield definition types - query that resource rather than hard-coding a table. - Constraints depend on the
ownerType, not the type. Constraints (category,channel,category_channel) are scoped to the owner resource. Today onlyproductsallows constraints; every other owner type allows none. The authoritative list is theallowedConstraintsfield on Metafield owner types.
[!TIP] Before creating a definition, read the matching definition type and owner type to see exactly what it accepts. That way your
validationsandconstraintsare valid by construction.
Submitting an incompatible rule returns 422 with a message such as Validation "min_value" is not compatible with metafield definition type "single_line_text_field". or Constraint "category" is not compatible with owner type "variants".
Conventions
Section titled “Conventions”Authentication and headers
Section titled “Authentication and headers”All requests require an OAuth 2.0 bearer token and the organization scope header:
Authorization: Bearer <token>X-Flowkiwi-Organization-Id: <organization-id>Partial updates
Section titled “Partial updates”PATCH uses JSON Merge Patch with Content-Type: application/merge-patch+json.