REST API
Use people and companies for customer identities and deals for sales opportunities. The shared API conventions apply across their activities, notes and addresses.
Open the API Explorer at /docs/api on your Open Mercato instance to inspect request and response schemas or try a call with an API key.
All examples assume the environment variables defined in REST API Overview:
export BASE_URL="http://localhost:3000/api"
export API_KEY="<paste your API key secret here>"
export ORG_ID="<organization uuid in scope>"
export TENANT_ID="<tenant uuid in scope>"
X-Api-Key: $API_KEY on every request. JSON responses are returned unless stated otherwise.organizationId and tenantId. With an API key, you must supply both values explicitly.packages/core/src/modules/customers/acl.ts. Calls fail with 403 when the caller lacks the feature.cf_<slug> top-level keys or a customFields object (e.g. { "customFields": { "language": "en" } }). Both map to the same runtime handler.GET /customers/peopleFeature: customers.people.view
Query parameters (selected):
page, pageSize – pagination (pageSize max 100).search – case-insensitive match on display_name.email, emailStartsWith, emailContains – mutually exclusive email filters.status, lifecycleStage, source – dictionary-backed filters.hasEmail, hasPhone, hasNextInteraction – true/false.createdFrom, createdTo – ISO timestamps (filters created_at).tagIds – comma separated UUIDs to require assigned tags. tagIdsEmpty=true matches people without tags.cf_ to filter against custom field values.curl -X GET "$BASE_URL/customers/people?page=1&pageSize=20&search=Acme" \
-H "X-Api-Key: $API_KEY" \
-H "Accept: application/json"
Response includes the matching records plus pagination metadata.
GET /customers/people/{id}Feature: customers.people.view
By default the payload contains the core record, person profile, addresses, tags, custom field values, organization scope, and viewer metadata. Add include parameters to hydrate related collections on demand:
include=comments or include=notesinclude=activitiesinclude=dealsinclude=todos or include=tasksinclude=addressescurl -X GET "$BASE_URL/customers/people/$PERSON_ID?include=deals&include=activities" \
-H "X-Api-Key: $API_KEY" \
-H "Accept: application/json"
GET /customers/people/check-phone?digits=<4+ digits>Feature: customers.people.view
Normalises a primary phone to digits and returns { match: { id, displayName } | null }. Use it before creation to prevent duplicates.
POST /customers/peopleFeature: customers.people.manage
Body must satisfy personCreateSchema:
organizationId, tenantId, firstName, lastName.displayName, description, ownerUserId, primaryEmail, primaryPhone, status, lifecycleStage, source, nextInteraction.preferredName, jobTitle, department, seniority, timezone, linkedInUrl, twitterUrl, companyEntityId.tags (array of tag UUIDs) and custom field values.Response: { "entityId": "<uuid>", "personId": "<uuid>" }.
PUT /customers/peopleFeature: customers.people.manage
Send id, organizationId, tenantId, and any mutable fields from the create schema. Only supplied keys are updated.
DELETE /customers/people?id=<uuid>Feature: customers.people.manage
Provide the id in the query string or body. Soft deletes the entity and reindexes downstream search views.
GET /customers/companiesFeature: customers.companies.view
Supports the same pagination, search, tag, status, lifecycle stage, source, email, and custom field filters as /customers/people.
GET /customers/companies/{id}Feature: customers.companies.view
Detail payload includes core company data, profile, tags, custom fields, and viewer info. Optional include values hydrate:
include=addressesinclude=comments / include=notesinclude=activitiesinclude=dealsinclude=todos / include=tasksinclude=people (company members)POST /customers/companiesFeature: customers.companies.manage
Body follows companyCreateSchema:
organizationId, tenantId, displayName.description, ownerUserId, primaryEmail, primaryPhone, status, lifecycleStage, source, nextInteraction, tags.legalName, brandName, domain, websiteUrl, industry, sizeBucket, annualRevenue.cf_ keys or customFields object.Response: { "entityId": "<uuid>", "companyId": "<uuid>" }.
PUT /customers/companiesFeature: customers.companies.manage
Provide id, organizationId, tenantId, and the fields you need to modify.
DELETE /customers/companies?id=<uuid>Feature: customers.companies.manage
Accepts id in the query string or JSON body. Performs a soft delete.
GET /customers/dealsFeature: customers.deals.view
Query parameters: page, pageSize, search (title substring), status, pipelineStage, sortField (createdAt, updatedAt, title, value), sortDir, personEntityId, companyEntityId, and legacy aliases personId, companyId.
GET /customers/deals/{id}Feature: customers.deals.view
Returns core deal data plus:
viewerName, viewerEmail).The route enforces tenant and organization scoping just like the list endpoint.
POST /customers/dealsFeature: customers.deals.manage
Required body fields: organizationId, tenantId, title. Optional: description, status, pipelineStage, valueAmount, valueCurrency, probability, expectedCloseAt, ownerUserId, source, companyIds, personIds, custom fields.
PUT /customers/dealsFeature: customers.deals.manage
Send id, organizationId, tenantId, and the fields to change.
DELETE /customers/deals?id=<uuid>Feature: customers.deals.manage
Accepts the id via query string or JSON body.
GET /customers/activitiesFeature: customers.activities.view
Query parameters: page, pageSize, entityId, dealId, activityType, sortField (occurredAt, createdAt), sortDir.
The response normalises timestamps to ISO strings, carries author information (including enriched name/email when present), and includes any custom field values.
POST /customers/activitiesFeature: customers.activities.manage
Body (plus scope identifiers): entityId, activityType, optional subject, body, occurredAt, dealId, authorUserId, appearanceIcon, appearanceColor, custom fields.
PUT /customers/activitiesFeature: customers.activities.manage
Send id plus any fields from the create schema to mutate.
DELETE /customers/activities?id=<uuid>Feature: customers.activities.manage
Removes the record via soft delete and reindexes.
GET /customers/commentsFeature: customers.activities.view
Query parameters: page, pageSize, entityId, dealId, sortField, sortDir.
Every comment in the response is enriched with dealTitle when linked to a deal.
POST /customers/commentsFeature: customers.activities.manage
Body: organizationId, tenantId, entityId, body, optional dealId, authorUserId, appearanceIcon, appearanceColor.
Response: { "id": "<uuid>", "authorUserId": "<uuid|null>" }.
PUT /customers/commentsFeature: customers.activities.manage
Provide id alongside scoped fields to update body/appearance attributes.
DELETE /customers/comments?id=<uuid>Feature: customers.activities.manage
id may be supplied via query string or JSON payload.
GET /customers/addressesFeature: customers.activities.view
Query parameters: page, pageSize, entityId, sortField, sortDir.
POST /customers/addressesFeature: customers.activities.manage
Body: organizationId, tenantId, entityId, addressLine1, optional name, purpose, addressLine2, buildingNumber, flatNumber, city, region, postalCode, country, latitude, longitude, isPrimary.
PUT /customers/addressesFeature: customers.activities.manage
Include id, scope identifiers, and the fields to change.
DELETE /customers/addresses?id=<uuid>Feature: customers.activities.manage
GET /customers/tagsFeature: customers.activities.view
Optional query parameters: page, pageSize, search, sortField, sortDir.
POST /customers/tagsFeature: customers.activities.manage
Body: organizationId, tenantId, slug, label, optional color, description. Returns { id: "<uuid>" }.
PUT /customers/tagsFeature: customers.activities.manage
Send id, scope fields, and any updatable attributes from the create schema.
DELETE /customers/tags?id=<uuid>Feature: customers.activities.manage
Soft deletes the tag. id can be in the query string or payload.
POST /customers/tags/assignFeature: customers.activities.manage
Body: organizationId, tenantId, entityId, tagId. Creates a tag assignment and returns { id: "<uuid>" }. The response includes an x-om-operation header for undo metadata.
POST /customers/tags/unassignFeature: customers.activities.manage
Accepts the same body as assign. Removes the tag link and emits undo metadata via x-om-operation.
Tasks are linked to customers via CustomerTodoLink records. The module can both create a todo (via a registered provider) and attach an existing item.
GET /customers/todosFeature: customers.activities.view
Query parameters: page, pageSize, search, isDone (true/false), organizationId, entityId.
The response includes todo metadata resolved from the remote source (todoSource) and the linked customer summary.
POST /customers/todosFeature: customers.activities.manage
Body:
organizationId, tenantId, entityId, title (required).isDone/is_done, todoSource (defaults to example:todo), createdByUserId.todoCustom and custom objects are forwarded to the provider to seed fields.Response: { "todoId": "<uuid|null>", "linkId": "<uuid>" } plus the x-om-operation header.
PUT /customers/todosFeature: customers.activities.manage
Body: organizationId, tenantId, entityId, todoId, optional todoSource, createdByUserId. Response mirrors the create endpoint.
DELETE /customers/todos?id=<uuid>Feature: customers.activities.manage
Provide the todo link id in the query string or body to remove the association.
GET /customers/dictionaries/{kind}Feature: customers.people.view
{kind} accepts: statuses, sources, lifecycle-stages, address-types, activity-types, deal-statuses, pipeline-stages, job-titles, industries.
The response merges organisation-level entries with inherited ancestors and marks inherited values with isInherited: true.
POST /customers/dictionaries/{kind}Feature: customers.settings.manage
Body: value (required), optional label, color (hex), icon. Values are normalised per organization; sending the same value updates the label.
GET /customers/dictionaries/currencyFeature: customers.people.view
Returns the first active currency/currencies dictionary visible to the caller, or 404 when none exist.
GET /customers/settings/address-formatFeature: customers.settings.manage
Returns { "addressFormat": "line_first" | "street_first" } scoped to the selected organization.
PUT /customers/settings/address-formatFeature: customers.settings.manage
Body: organizationId, tenantId, addressFormat (line_first or street_first). Response echoes the persisted value.