User Schema

The User Schema API provides schema discovery for user properties, enabling dynamic segment building and user targeting in your loyalty campaigns.

Overview

The User Schema endpoint returns a comprehensive schema of all available user properties for your organization, combining:

  1. Standard Properties - 23 built-in properties available to all organizations

  2. Custom Fields - Organisation-specific fields defined via the Custom Fields API

  3. Integration Properties - Data from connected systems (CRM, CDP, etc.)

This enables:

  • Dynamic segment builder UIs

  • API-driven segmentation

  • Self-documenting user properties

  • Type-safe filtering and targeting

Endpoints

Get User Schema

Retrieve all available user properties for segmentation and filtering.

Endpoint: GET /users/schema

Query Parameters:

Parameter
Type
Required
Description

includeInactive

boolean

No

Include inactive custom fields (default: false)

Example Request:

Example Response:

Property Types

Standard Properties (23 built-in)

Identity

  • userId - Unique user identifier

  • email - User email address

  • createdAt - Registration date

  • lastActiveAt - Last activity timestamp

Loyalty

  • tier - Current loyalty tier (bronze, silver, gold, platinum, diamond)

  • points - Current points balance

  • lifetimePoints - Total points earned all-time

  • xp - Experience points

  • level - User level based on XP

  • coins - Coins balance

Achievements

  • badges - Array of earned badge IDs

  • badgeCount - Total badges earned

Engagement

  • streak - Current consecutive days active

  • longestStreak - Longest streak achieved

  • transactionCount - Total transactions

Location

  • country - ISO 3166-1 alpha-2 country code

  • city - User city

  • timezone - User timezone

Preferences

  • language - ISO 639-1 language code

Social

  • referralCount - Number of users referred

  • referredBy - User ID of referrer

Metadata

  • segments - Array of segment IDs

  • tags - Custom tags array

Custom Field Properties

Properties defined via the Custom Fields API are automatically included with:

  • Namespace: Prefixed with custom. (e.g., custom.favorite_team)

  • Type Mapping: Field types map to appropriate operators

  • Options: Select and multi-select fields include available options

  • Source Tracking: Includes fieldId for reference

Integration Properties (Future)

Properties from connected systems:

  • Salesforce: integration.salesforce.account_type

  • HubSpot: integration.hubspot.lifecycle_stage

  • Segment: integration.segment.computed_traits

Operators

Each property type supports specific operators:

String Operators

  • equals - Exact match

  • notEquals - Not equal

  • contains - Contains substring

  • notContains - Does not contain

  • startsWith - Starts with

  • endsWith - Ends with

  • in - One of (list)

  • notIn - Not one of (list)

Number Operators

  • equals - Exact match

  • notEquals - Not equal

  • greaterThan - Greater than

  • lessThan - Less than

  • between - Between two values

Date Operators

  • equals - Exact date match

  • before - Before date

  • after - After date

  • between - Between two dates

Array Operators

  • contains - Contains item

  • notContains - Does not contain

  • containsAll - Contains all items

  • containsAny - Contains any item

Existence Operators

  • exists - Field has a value

  • notExists - Field is null/undefined

Categories

Properties are organized into logical categories:

Category
Description
Example Properties

identity

Basic user identification

userId, email, createdAt

loyalty

Points, tiers, and rewards

tier, points, lifetimePoints

achievements

Badges and accomplishments

badges, badgeCount

engagement

Activity and participation

streak, transactionCount

segmentation

Segment membership

segments

location

Geographic information

country, city, timezone

preferences

User preferences

language

social

Referrals and connections

referralCount, referredBy

metadata

Custom tags and data

tags

custom

Organisation-defined fields

custom.*

integration

Connected system data

integration.*

Use Cases

Dynamic Segment Builder UI

Build a segment builder that adapts to your organization's schema:

Campaign Targeting

Use schema to validate targeting criteria:

API-Driven Segmentation

Discover and use properties programmatically:

Type-Safe Filtering

Use operator information to build type-safe filters:

Integration with Custom Fields

Custom fields defined via the Custom Fields API are automatically included in the schema:

Step 1: Create Custom Field

Step 2: Retrieve Schema

Result:

Schema Evolution

The schema adapts to your organization:

  1. Add Custom Field → Automatically appears in schema

  2. Update Field Options → Options refresh in schema

  3. Delete Custom Field → Removed from schema (unless includeInactive=true)

  4. Connect Integration → Integration properties added automatically

Best Practices

  1. Cache Schema: Cache the schema response for 5-10 minutes to reduce API calls

  2. Category Organisation: Group properties by category in your UI for better UX

  3. Operator Validation: Check operators array before allowing filter operations

  4. Custom Field Namespace: Always prefix custom fields with custom. in criteria

  5. Type Safety: Use type field to render appropriate input controls (text, number, select)

  6. Example Usage: Reference the examples array for common segment patterns

  7. Source Tracking: Use source field to distinguish between standard, custom, and integration properties

Error Responses

401 Unauthorized:

500 Internal Server Error:

Schema Response Example

Full example showing all three property sources:

Last updated