Skip to content

Data Model

The data model defines the custom fields that live on a workspace's clients. Each workspace has a set of workspace_data_model field definitions that drive validation, default values, and consistent field metadata across the API and UI.

All data-model endpoints are workspace-scoped: the caller must be a member of the workspace (enforced by the workspaceGuard middleware). Mutating endpoints (create, update, delete, reorder) additionally require the manage_workspace_settings permission, enforced inside the service.

Base URL: https://api.wallethero.app

Sub-pages

  • Fields — read the data model, create/update/delete fields, reorder fields, and fetch default values.
  • Validation — validate a set of custom field values against the data model.

Endpoints

MethodEndpointPage
GET/wallethero-api/workspace/:workspaceId/data-modelFields
POST/wallethero-api/workspace/:workspaceId/data-model/fieldsFields
PATCH/wallethero-api/workspace/:workspaceId/data-model/fields/:fieldIdFields
DELETE/wallethero-api/workspace/:workspaceId/data-model/fields/:fieldIdFields
POST/wallethero-api/workspace/:workspaceId/data-model/reorderFields
GET/wallethero-api/workspace/:workspaceId/data-model/defaultsFields
POST/wallethero-api/workspace/:workspaceId/data-model/validateValidation

Field Types

TypeDescriptionExample Value
stringText value"Gold", "Downtown Store"
numberNumeric value1500, 99.99
multiselectValue constrained to a fixed list of allowed_values"sports"
dateDate string in YYYY-MM-DD format"2024-01-15"
imageA Directus file UUID or an http(s):// URL"https://cdn.example.com/logo.png"

TIP

multiselect fields require a non-empty allowed_values list. A submitted value is validated as a single scalar that must be one of the allowed_values.

Field Structure

The WorkspaceDataModelField shape returned by the API:

typescript
interface WorkspaceDataModelField {
  id: string;                  // UUID
  workspace_id: string;        // UUID
  field_name: string;          // API key, e.g. "points"
  field_label: string;         // Display label, e.g. "Points Balance"
  field_type: "string" | "number" | "multiselect" | "date" | "image";
  default_value?: string | null;   // Default value (stored as string)
  allowed_values?: string[] | null; // Allowed values (required for multiselect)
  is_required: boolean;        // Whether the field is required
  is_system: boolean;          // System-managed field (cannot be deleted)
  sort_order: number;          // Display order (lower = first)
  entity_type: "client";       // Entity the field applies to
  date_created?: string;       // ISO 8601 timestamp
  user_created?: string;
  date_updated?: string;
  user_updated?: string;
}

System Fields

Every workspace is seeded with a set of system fields (is_system: true) for clients:

field_namefield_labelfield_typeRequired
emailEmailstringYes
first_nameFirst NamestringNo
last_nameLast NamestringNo
phonePhonestringNo
birth_dateBirth DatedateNo

System fields cannot be deleted, and their field_name and field_type cannot be changed. Other attributes (e.g. field_label, is_required, sort_order) may be updated.

Reserved Field Names

Custom field_name values cannot collide with the built-in client scalar columns. The following names are reserved and rejected when creating or renaming a field:

first_name, last_name, email, phone, birth_date, status, marketing_consent

A field_name must also match the pattern ^[a-zA-Z_][a-zA-Z0-9_]*$ (start with a letter or underscore; alphanumerics and underscores only) and be unique within the workspace.

SDK

Data-model methods live on wh.workspaces:

typescript
import { WalletHero } from "@wallethero/sdk";

const wh = new WalletHero({ apiToken: "YOUR_TOKEN" });

const dataModel = await wh.workspaces.getDataModel(workspaceId);

WalletHero Documentation