Goal
By the end of this guide you will be able to retrieve your contact structure with its fields and tags, and update it to add or modify custom fields.Prerequisites
- An API key with
contacts:writescope (for updating the structure) orcontacts:readscope (for read-only access) - Your API base URL (found on the Settings > API Keys page)
Background
A contact structure defines the schema for your contacts. It includes:- A key name and key type — the primary identifier for contacts (typically “Email” of type “email”)
- Fields — custom fields like First Name, Last Name, Company, Phone, etc.
- Tags — label definitions that can be assigned to contacts
Steps
1. List all contact structures
Retrieve all contact structures in your account.200 OK):
_id values of the fields array are what you use when creating or updating contacts and when searching by custom field values.
2. Get a specific contact structure
Retrieve a single contact structure by its ID.200 OK):
3. Update a contact structure
UsePUT to update a contact structure. This replaces the full structure, so include all existing fields plus any changes. Include the current __v value for optimistic concurrency control.
Adding a new “Loyalty Tier” field to an existing structure:
200 OK):
text— free-text stringnumber— numeric valuedate— date valueboolean— true/falserecurrent_date— recurring date (month/day)
predefinedField to map standard fields like firstName, lastName. These enable features like merge tags in email campaigns.
Important notes:
PUTis a full replacement. Include all existing fields you want to keep, or they will be removed.- When adding a new field, omit
_id— the server generates it. - When keeping existing fields, include their
_idto preserve them. - Include the current
__vvalue for optimistic concurrency control. - Removing a field that is referenced by a published signup form will return a
400error with details about which forms are affected.
Common Errors
| Status | Error | Cause | Fix |
|---|---|---|---|
401 | UnauthorizedError | Invalid or inactive API key | Verify your key in Settings > API Keys |
403 | ForbiddenError | Key lacks contacts:write scope | Update operations require contacts:write |
403 | ForbiddenError | Attempted to create a new contact structure via API key | Creating contact structures is not available via API key. Use the web application |
400 | ValidationError | Missing required properties (label, keyName), or invalid field dataType | Check request body against the schema requirements |
400 | ContactFieldInUseError | Tried to remove a field used by a signup form | Update or unpublish the affected form first. The error response includes debug.affectedForms with form IDs and names |
404 | RecordNotFound | Contact structure ID does not exist | Verify the structure ID |
429 | TooManyRequestsError | Rate limit exceeded | Wait for the Retry-After period. See Rate Limits |
Next Steps
- Manage Contacts — create contacts using the field IDs from your structure
- Manage Lists — create lists within a contact structure
- Search Contacts — search by custom field values
- Migration from Legacy — set up your structure before importing data