Skip to content

Attribute Schemas

The attribute schema defines the valid attribute keys and their types for a memberbase. It acts as a contract - only attributes matching the schema can be set on members within that memberbase.

Defining a Schema

Use the set endpoint to define or update the schema for a memberbase. The schema is a map of attribute keys to their type definitions:

bash
curl -X POST https://<your-instance-url>/publisher.v1/attribute.schema/set \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "member_base_id": "mb_abc123",
    "schema": {
      "tier": { "type": "string" },
      "lifetime_spend": { "type": "number" },
      "signup_date": { "type": "date" },
      "dob": { "type": "date" }
    }
  }'

Supported Types

TypeDescriptionExample Value
stringText values"gold"
numberInteger or decimal values2500.50
booleanTrue or falsetrue
dateISO 8601 date-time strings"2024-01-15T10:30:00Z"

Updating the Schema

You can add new attribute keys at any time by calling the set endpoint with the full updated schema. Existing members are not affected - they simply won't have the new attributes until explicitly set.

Restrictions on Modifications

  • Removing a key - You cannot remove an attribute key from the schema if any members currently have values set for that key. Delete the attribute values first, then remove the key from the schema.
  • Changing a type - You cannot change the type of an existing attribute key if any members have values set for it. Delete existing values before changing the type.

These restrictions prevent silent data corruption. If you attempt a disallowed modification, the API returns an invalid_schema_modification error.

Planning Your Schema

When designing your attribute schema, consider what member properties you will use for:

  • Audience targeting - Attributes the delivery engine will evaluate when determining which deals are eligible for a member (e.g. tier, location, age_range).
  • Segmentation - Attributes for grouping members in reporting or batch operations.
  • Personalisation - Attributes that inform creative rendering or messaging.

Keep attribute keys stable and meaningful. Once set on members, changing a key name requires deleting the old key's values and re-setting them under the new name.