Metadata definitions

GET /metadata-definitions

List the organization's metadata definitions: the typed fields its customers, products, variants and orders carry in metadata. Filter by resource to get one resource's fields in order.

Requires the settings:read permission.

Query parameters

limitnumber

The number of records to return.

cursorstring

A pagination cursor. Fetch the next page by passing the nextCursor value from the previous response.

sortposition | -position | name | -name | createdAt | -createdAt

The sort order. Prefix a field with - to sort descending. Defaults to position.

filterstring

A JSON-encoded filter document, for example {"createdAt":{"$gte":"2025-01-01T00:00:00Z"}}. Filterable fields: id, resource, key, name, type, storefront, createdAt. See Filtering for the syntax.

Request
curl \
  "https://your-store.meisei.app/api/metadata-definitions" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
Response
{
  "data": [
    {
      "id": "A4Ws1igz",
      "resource": "customers",
      "key": "string",
      "name": "string",
      "description": "string",
      "type": "text",
      "options": ["..."],
      "rules": {
        "required": "...",
        "min": "...",
        "max": "...",
        "maxLength": "...",
        "pattern": "..."
      },
      "storefront": true,
      "position": 0,
      "createdAt": "2025-01-15T09:30:00Z",
      "updatedAt": "2025-01-15T09:30:00Z"
    }
  ],
  "nextCursor": "string"
}

POST /metadata-definitions

Define a metadata field. From then on every write of that key on the resource is checked against its type and rules. Values already stored that convert, such as the text "12" for a number, are rewritten in the background; the rest are left as they are.

Requires the settings:write permission.

Body parameters

resourcecustomers | products | productVariants | ordersrequired

Which records the definition applies to.

keystringrequired

The key in metadata to type. Starts with a letter, then letters, digits and underscores, up to 64 characters. It cannot be changed later.

namestringrequired

The field's label.

descriptionstring | null

Optional help text for the field.

typetext | number | integer | boolean | date | dateTime | url | select | multiSelectrequired

What the key holds. text and url are strings, number and integer are numbers, boolean is true or false, date is YYYY-MM-DD, dateTime is an ISO 8601 timestamp, select is one option's value and multiSelect is a list of option values.

optionsobject[]

The choices a select or multiSelect field offers. Empty for every other type.

rulesobject

Optional rules a value is checked against. Which ones apply depends on the type.

storefrontboolean

Whether storefront widgets may read this key. Defaults to false.

positioninteger

Where the field sits among its resource's fields. Defaults to after the last one.

Request
curl \
  -X POST \
  "https://your-store.meisei.app/api/metadata-definitions" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "resource": "customers",
  "key": "string",
  "name": "string",
  "description": "string",
  "type": "text",
  "options": [
    {
      "value": "string",
      "label": "string"
    }
  ],
  "rules": {
    "required": true,
    "min": 0,
    "max": 0,
    "maxLength": 0,
    "pattern": "string"
  },
  "storefront": true,
  "position": 0
}'
Response
{
  "id": "A4Ws1igz",
  "resource": "customers",
  "key": "string",
  "name": "string",
  "description": "string",
  "type": "text",
  "options": [
    {
      "value": "string",
      "label": "string"
    }
  ],
  "rules": {
    "required": true,
    "min": 0,
    "max": 0,
    "maxLength": 0,
    "pattern": "string"
  },
  "storefront": true,
  "position": 0,
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T09:30:00Z"
}

GET /metadata-definitions/{id}

Get a single metadata definition by ID, with a count of the stored values it would refuse.

Requires the settings:read permission.

Path parameters

idstringrequired

The ID of the metadata definition.

Request
curl \
  "https://your-store.meisei.app/api/metadata-definitions/A4Ws1igz" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
Response
{
  "id": "A4Ws1igz",
  "resource": "customers",
  "key": "string",
  "name": "string",
  "description": "string",
  "type": "text",
  "options": [
    {
      "value": "string",
      "label": "string"
    }
  ],
  "rules": {
    "required": true,
    "min": 0,
    "max": 0,
    "maxLength": 0,
    "pattern": "string"
  },
  "storefront": true,
  "position": 0,
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T09:30:00Z",
  "nonConformingCount": 0
}

PATCH /metadata-definitions/{id}

Change a metadata field's label, type, options, rules or position. Its resource and key cannot be changed.

Requires the settings:write permission.

Path parameters

idstringrequired

The ID of the metadata definition to update.

Body parameters

namestring

The field's label.

descriptionstring | null

Help text for the field. Null removes it.

typetext | number | integer | boolean | date | dateTime | url | select | multiSelect

A new type for the field. Stored values that convert, such as the text "12" for a number, are rewritten in the background; the rest are left as they are and are checked the next time each record is saved.

optionsobject[]

Replaces the field's options wholesale.

rulesobject

Replaces the field's rules wholesale.

storefrontboolean

Whether storefront widgets may read this key.

positioninteger

Where the field sits among its resource's fields.

Request
curl \
  -X PATCH \
  "https://your-store.meisei.app/api/metadata-definitions/A4Ws1igz" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "description": "string",
  "type": "text",
  "options": [
    {
      "value": "string",
      "label": "string"
    }
  ],
  "rules": {
    "required": true,
    "min": 0,
    "max": 0,
    "maxLength": 0,
    "pattern": "string"
  },
  "storefront": true,
  "position": 0
}'
Response
{
  "id": "A4Ws1igz",
  "resource": "customers",
  "key": "string",
  "name": "string",
  "description": "string",
  "type": "text",
  "options": [
    {
      "value": "string",
      "label": "string"
    }
  ],
  "rules": {
    "required": true,
    "min": 0,
    "max": 0,
    "maxLength": 0,
    "pattern": "string"
  },
  "storefront": true,
  "position": 0,
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T09:30:00Z"
}

DELETE /metadata-definitions/{id}

Delete a metadata definition. The values records already carry stay, as free-form metadata.

Requires the settings:write permission.

Path parameters

idstringrequired

The ID of the metadata definition to delete.

Request
curl \
  -X DELETE \
  "https://your-store.meisei.app/api/metadata-definitions/A4Ws1igz" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
Response
{
  "id": "A4Ws1igz",
  "resource": "customers",
  "key": "string",
  "name": "string",
  "description": "string",
  "type": "text",
  "options": [
    {
      "value": "string",
      "label": "string"
    }
  ],
  "rules": {
    "required": true,
    "min": 0,
    "max": 0,
    "maxLength": 0,
    "pattern": "string"
  },
  "storefront": true,
  "position": 0,
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T09:30:00Z"
}