REST API reference
The-Y CRM's public REST API is meant for server-to-server integrations: read or create contacts, conversations, deals, tasks and notes, reply in conversations and receive events via webhook. Requests are authenticated with an API key.
Authentication
Every request needs your API key in the header — either as a Bearer token or as X-API-Key:
Authorization: Bearer <YOUR_API_KEY>
# or
X-API-Key: <YOUR_API_KEY>
Create a key: in the app under Settings → Integrations (under “Advanced” → Connections) → "API keys" → new key. The key starts with tyk_ and is shown only once — store it safely (The-Y only stores a hash). The key is bound to your tenant.
Permissions (scopes), expiry and renewal: each key has its own scopes – you choose them when you create it: contacts:read, contacts:write, conversations:read, conversations:write, deals:read, deals:write, tasks:write, notes:write, users:read and webhooks:manage (which route needs which scope is in the overview). Optionally it gets an expiry date (at most 5 years). “Renew” creates a new key; the old one keeps working for the time you choose (immediately, 24 hours, 7 or 30 days). Older keys without defined permissions (before 1.1.60) can still only read and write contacts – for the new areas, set the permissions in the settings or create a new key.
Overview: all routes (since 1.1.62)
All routes live under https://crm.the-y.at/api/ext/v1 (self-hosted: your address + /api/ext/v1). Every route needs a scope of the key.
| Route | Scope | What |
|---|---|---|
GET /me | – (any valid key) | name, scopes and limits of the key itself (e.g. a connection test) |
GET /contacts, GET /contacts/{id} | contacts:read | search / read contacts |
POST /contacts, PATCH /contacts/{id} | contacts:write | create / update a contact |
POST /contacts/upsert | contacts:write | create or update by email (no duplicates) |
GET /custom-fields?entity=contact|company|deal | contacts:read (deals: deals:read) | custom fields (key, type, options) |
GET /conversations, GET /conversations/{id} | conversations:read | conversations and messages |
POST /conversations/{id}/messages | conversations:write | reply in a conversation |
PATCH /conversations/{id} | conversations:write | status, assignee |
GET /pipelines, GET /deals/{id} | deals:read | pipelines with stages, one deal |
POST /deals, PATCH /deals/{id} | deals:write | create a deal, change its stage |
POST /tasks | tasks:write | create a task |
POST /notes | notes:write | note on a contact, company, deal or conversation |
GET /users | users:read | active team members (for assignees) |
GET/POST /webhooks, GET/DELETE /webhooks/{id} | webhooks:manage | register and remove webhooks |
Conventions
- Format: requests & responses in
application/json(UTF-8). - Pagination:
GET /contactstakes?limit=(1–200, default 100) and?offset=(from 0). The response includeslimit,offset,countandhasMore.hasMoreistrueas soon as the page is full – the next page may then be empty. - Rate limit: 300 requests per minute per IP address (not per key), for all calls under
/api/ext/v1together. Several keys used from the same server share one limit, and requests with a wrong key count too. Since 1.1.62 there is also a limit per account and plan (limits). When exceeded you get429with aRetry-Afterheader (seconds) – wait that long, then retry. - Errors: JSON with an
errorfield. For400,401,403,404and409it is a string (the code), e.g.{ "error": "unauthorized" }; if the key lacks a permission, it is also named inrequired:{ "error": "insufficient_scope", "required": "contacts:write" }. With400you also get a readable sentence inmessage, and for a wrong field its name infield:{ "error": "invalid_field", "field": "first_name", "message": "…" }. The sentence followsAccept-Language(English, German or Turkish, otherwise English) – your code should always check the code, never the sentence. Only429returns an object:{ "error": { "code": "rate_limited", "message": "…" } }. The safest way is to check the HTTP status first. - Warnings (since 1.1.62): if a call succeeds but something wasn't taken over, it is listed in
warnings(only then), e.g.{ "code": "unknown_custom_fields", "fields": ["colour"], "message": "…" }for custom fields that don't exist in the CRM, orcustom_not_objectifcustomisn't an object.
| Status | Meaning |
|---|---|
200 / 201 | OK / created (possibly with warnings, see above) |
400 | invalid_json: the body isn't a valid JSON object (or is empty) · invalid_field: a field has the wrong type (see field; allowed are text, a number or null) · contact_empty: creating a contact without first name, last name, email and phone · more codes of the new routes: see error codes |
401 | unauthorized: key missing, unknown, revoked or expired |
403 | insufficient_scope: the key lacks the permission (see required) · tenant_suspended: account suspended · feature_locked: integrations are switched off for this account · cloud_readonly: the account is read-only right now (e.g. after Cloud Pro ended while above the Free limits) – creating and updating blocked, reading works · terms_required: new terms of use not accepted yet – updating blocked, creating and reading work |
404 | not_found: the item doesn't exist, was deleted, or the ID isn't a valid ID (e.g. /contacts/abc) |
409 | a reply in a conversation is not sent (e.g. window_closed, see conversations) · webhook_limit: already 100 webhooks |
429 | limit exceeded (rate_limited or, on the Free plan, daily_limit_reached, with Retry-After; see limits) |
500 | server error |
Error codes of the new routes (since 1.1.62): 400: invalid_events, unsafe_url, invalid_status, invalid_assignee, text_required, template_not_supported, template_not_found, invalid_reference, title_required, target_required, email_required, invalid_entity (always with message, mostly with field) · 403: limit_reached (monthly limit on the Free plan) · 409: see reply, webhook_limit · 429: rate_limited, daily_limit_reached.
Limits and plans (since 1.1.62)
In addition to the limit per IP address (300 requests per minute), each account has:
| Free | Cloud Pro, Paid, Founder | self-hosted | |
|---|---|---|---|
| per minute | 60 | 300 | none (configurable: API_LIMIT_PER_MINUTE) |
| per day (UTC) | 1,000 | none | none (configurable: API_LIMIT_PER_DAY) |
Every response to an authenticated request carries the headers X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (Unix seconds) for the current minute; on the Free plan also X-RateLimit-Limit-Day, X-RateLimit-Remaining-Day and X-RateLimit-Reset-Day for the day (UTC). This shows you how many requests are left. Self-hosted without a configured limit there is no limit and therefore none of these headers. They are not sent before authentication (missing or wrong key).
Above a limit the API answers 429 and additionally Retry-After (seconds): { "error": { "code": "rate_limited", "message": "…", "limit": 60, "window": "minute", "retry_after": 12, "reset_at": "…" } }, or for the daily limit { "error": { "code": "daily_limit_reached", "message": "…", "upgrade": { "href": "…" } } }. Webhooks the CRM sends to you don't count. Tip: on 429 wait the seconds from Retry-After before you try again.
Contacts
Contact IDs are UUIDs (e.g. 3f6c1e2a-8b4d-4c1e-9a7f-2d5b6c7e8f90). When creating and updating, the API understands these fields:
| Field | Type | Meaning |
|---|---|---|
first_name | text | first name |
last_name | text | last name |
email | text | one email address |
phone | text | one phone number |
custom | object | custom fields as { "key": value }. Only keys of custom fields that exist for contacts in the CRM are taken over (Settings → Custom fields, keys via GET /custom-fields). Unknown keys are not saved and are listed in the response under warnings |
Each field takes text, a number (stored as text, e.g. a phone number from a spreadsheet) or null (empty). An object, a list or true/false returns 400 invalid_field. Other fields (e.g. name, company, emails) are ignored. A company can't be set via the API at the moment.
GET/contacts
List contacts, newest first (paginated, see Conventions). ?q= searches first and last name, email, phone, company name and WhatsApp username.
# Request curl "https://crm.the-y.at/api/ext/v1/contacts?limit=20&offset=0" \ -H "Authorization: Bearer $API_KEY" # Response 200 { "data": [ { "id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6c7e8f90", "first_name": "Maria", "last_name": "Muster", "emails": [{ "type": "work", "value": "maria@example.com" }], "phones": [{ "type": "mobile", "value": "+4366012345678" }], "company": "ACME", "created_at": "2026-11-09T10:15:00.000Z", "wa": null } ], "limit": 20, "offset": 0, "count": 1, "hasMore": false }
company is the name of the linked company (or null), wa the WhatsApp ID { "bsuid", "username" } (or null). Custom fields are only included when you read a single contact.
POST/contacts
Create a contact. Fields: see the table above.
curl -X POST "https://crm.the-y.at/api/ext/v1/contacts" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "first_name": "Maria", "last_name": "Muster", "email": "maria@example.com", "phone": "+4366012345678" }'
# Response 201 Created
{
"id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6c7e8f90",
"contact": {
"id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6c7e8f90",
"first_name": "Maria",
"last_name": "Muster",
"emails": [{ "type": "work", "value": "maria@example.com" }],
"phones": [{ "type": "mobile", "value": "+4366012345678" }],
"company": null,
…
}
}
contact has the same fields as reading a single contact, just without custom. Send custom fields along, e.g. "custom": { "customer_no": "K-1001" } (only if the field “customer_no” exists in the CRM).
first_name, last_name, email or phone with content. Otherwise you get 400 contact_empty and no contact is created – nor with broken JSON (400 invalid_json). POST /contacts doesn't detect duplicate email addresses: every call creates a new contact. To avoid duplicates, use POST /contacts/upsert.# Response 400 (empty body, or unknown fields only such as "name") { "error": "contact_empty", "message": "A contact needs at least one of these fields: first_name, last_name, email or phone." } # Response 201 with a warning (the custom field "colour" doesn't exist in the CRM – the contact is created anyway) { "id": "3f6c1e2a-…", "contact": { … }, "warnings": [ { "code": "unknown_custom_fields", "fields": ["colour"], "message": "…" } ] }
GET/contacts/{id}
Read a single contact. The response is the contact itself (no data wrapper), with custom fields in custom.
curl "https://crm.the-y.at/api/ext/v1/contacts/3f6c1e2a-8b4d-4c1e-9a7f-2d5b6c7e8f90" \
-H "Authorization: Bearer $API_KEY"
# Response 200
{
"id": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b6c7e8f90",
"first_name": "Maria",
"last_name": "Muster",
"emails": [{ "type": "work", "value": "maria@example.com" }],
"phones": [{ "type": "mobile", "value": "+4366012345678" }],
"company_id": null,
"company": null,
"owner_user_id": null,
"owner_name": null,
"birthday": null,
"consent_state": {},
"consent_meta": {},
"created_at": "2026-11-09T10:15:00.000Z",
"wa": null,
"custom": { "customer_no": "K-1001" }
}
owner_user_id/owner_name = the person in charge, consent_state/consent_meta = consent per channel with proof. Unknown or invalid ID (e.g. abc): 404 { "error": "not_found" }.
PATCH/contacts/{id}
Partially update a contact — only the fields you send change, everything else stays:
first_name/last_name: sets the value;""clears it.email/phone: replaces the first entry, further addresses and numbers stay. An empty value changes nothing (removing isn't possible via the API).custom: sets the named custom fields, others stay. Unknown keys are listed inwarnings.- Broken JSON →
400invalid_json, wrong field type →400invalid_field; nothing is changed then.
curl -X PATCH "https://crm.the-y.at/api/ext/v1/contacts/3f6c1e2a-8b4d-4c1e-9a7f-2d5b6c7e8f90" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "phone": "+4366099999999" }'
# Response 200: { "id": "…", "contact": { … } } (same as when creating, possibly with warnings)
POST/contacts/upsert
Create or update by email address (since 1.1.62): { "email": "maria@example.com", "first_name": "Maria", "custom": { … } } → new: 201 { "created": true, … }, existing: 200 { "created": false, … } (only the fields you send change). If several contacts have the address, the oldest is updated and warnings contains multiple_matches. Without email: 400 email_required.
GET/custom-fields
GET /custom-fields?entity=contact (also company, deal) → { "entity", "data": [{ "key", "label", "type", "options", "required" }] }. key is the key in custom.
Conversations (since 1.1.62)
GET /conversations?status=open&channel=whatsapp&since=2026-11-01T00:00:00Z&limit=50&offset=0 — newest activity first. Optional filters: status (open, snoozed, closed), channel (email, whatsapp, sms, webchat, messenger, instagram, call, …), since (last message at or after), contact_id. Response { "data": [ … ], "limit", "offset", "count", "hasMore" }.
A conversation: { "id", "number", "channel", "status", "priority", "subject", "contact_id", "customer": { "name", "address" }, "assignee": { "id", "name" } | null, "created_at", "last_message_at", "first_response_at", "resolved_at", "snooze_until", … }. GET /conversations/{id}?messages=200 adds messages (latest ones, oldest first): { "id", "direction": "in" | "out", "internal", "text", "author_name", "created_at", "delivery", "attachments": [{ "id", "filename", "content_type", "size" }] }. in = from the customer, internal: true = internal note (never sent to the customer).
Reply: POST /conversations/{id}/messages with { "text": "…" } — on the same channel and account as in the inbox (email with signature, subject “Re:” and quote; WhatsApp; SMS; Messenger; Instagram; web chat). On WhatsApp outside the 24-hour window only an approved template works: { "template": { "name": "appointment_reminder", "language": "en", "params": ["Maria"] } }. Response 201 { "id", "conversation_id", "delivery", "message" } — delivery as in the inbox (sent, simulated without a configured channel, failed with delivery_info). The message shows the author “API: <key name>” and counts like a reply from the inbox (monthly limit on the Free plan, first response).
The same rules as for a reply in the inbox apply: a normal reply (text or service template) is sent even if the contact opted out of the channel or unsubscribed from emails – as in the inbox, you (or your workflow) decide. A marketing template (category “Marketing”) is only sent with explicit consent. The reply is not sent (409) on: window_closed (24-hour window closed and free text on WhatsApp, Messenger or Instagram – on WhatsApp a template works then), no_optin or consent_off (marketing template only: no explicit consent or channel opted out), wa_thread_owned_by_other (another responder handles the WhatsApp conversation), no_mailbox, recipient_suppressed, channel_not_supported. 403 limit_reached = monthly limit on the Free plan reached.
Status / assignee: PATCH /conversations/{id} with { "status": "closed" }, { "status": "snoozed", "snooze_until": "…" } or { "assignee_user_id": "<ID from GET /users>" | null }. The conversation history shows “API (<name>) closed the conversation”.
Deals (since 1.1.62)
GET /pipelines → pipelines with stages (id, name, sort_order, probability, is_won, is_lost). GET /deals/{id} reads one deal. POST /deals with { "title": "Website relaunch", "value": 4800, "currency": "EUR", "stage_id": "…", "contact_id": "…", "custom": { … } } (without a stage: first stage of the default pipeline). PATCH /deals/{id} with { "stage_id": "…" } — the pipeline follows the stage, won / lost follow from the stage. IDs from another account → 400 invalid_reference with field.
Tasks, notes, team (since 1.1.62)
POST /taskswith{ "title", "description", "due_at", "priority": "low|normal|high|urgent", "kind": "todo|callback|call|email|follow_up", "assignee_user_id", "contact_id" | "company_id" | "deal_id" | "conversation_id" }(at most one target). The person who created the key is the task's creator.POST /noteswith{ "text", "contact_id" | "company_id" | "deal_id" | "conversation_id" }(exactly one target) — on a conversation it is an internal note.GET /users→{ "data": [{ "id", "name", "email", "roles" }] }(active team members only).GET /me→ name, scopes and limits of the key itself – handy as a connection test.
Outbound webhooks (events)
Instead of polling, have events pushed to your URL. Under Settings → Integrations → "Send data (webhook)" you set a target URL and the events. The CRM creates the signing secret.
Register via the API (since 1.1.62): POST /webhooks with { "url": "https://…", "events": ["message.received", "deal.won"], "name": "My system" } — "events": ["*"] = all. Response 201 { "id", "secret": "whsec_…", "webhook" }. The secret is only in this response, never again (list and single read don't show it). DELETE /webhooks/{id} removes it. At most 100 webhooks per account.
| Event | When | data |
|---|---|---|
contact.created | contact created — by hand, via the API, from WhatsApp, email, SMS, calls, web chat, bookings, appointments; CSV imports only with the box “Run automations, … campaigns and webhooks …” ticked | contact + source (whatsapp, email, import, api, …) |
contact.updated | changed in the form, the inbox or via the API | contact + changed |
message.received | a customer writes | message: text, conversation_id, channel, contact_id, from { name, address }, first |
conversation.created | a customer or the team starts a conversation | conversation + started_by (customer / team) |
conversation.closed / conversation.assigned | closed / new assignee | conversation (+ previous_status / previous_assignee_id) |
deal.created, deal.stage_changed, deal.won, deal.lost | deals | deal (+ from_stage, to_stage on stage changes) |
task.created | task created | task |
- Body: The-Y sends a
POSTwith JSON to your URL, e.g.{ "id": "evt_4b0c…", "event": "contact.created", "tenant": "<account ID>", "at": "2026-11-08T12:00:00.000Z", "data": { … } }.idis the event ID (since 1.1.62), the same as in theX-TheY-Event-Idheader. Contacts have the same fields indataas via the API (id,name,first_name,last_name,emailandphone= the first entry,emails,phones,company, …).data.originsays who caused it (customer,user,system,automation,api) — a workflow can skip events it caused itself through the API. - What doesn't arrive (yet): conversations the CRM starts by itself with a message (phone system, flow) don't send
conversation.created. - Target: public
http(s)addresses only. The CRM rejects internal targets (home or company network,localhost, Docker services, cloud metadata) when saving and never calls them when sending – not even after a redirect (self-hosted,WEBHOOK_PRIVATE_TARGETS=onallows targets in your own network). At most 4 deliveries at the same time per webhook, the rest follows in order. - Retries: on
429,5xx, a network error or if your endpoint doesn't answer within 8 seconds: up to 3 attempts in quick succession – with the same event ID (X-TheY-Event-Idandidin the body), the sameX-TheY-DeliveryID, the same timestamp and the same signature. If your endpoint answers too slowly, the same delivery arrives more than once: remember the event IDs of the last hours and process each one only once. Best: answer2xxright away and process afterwards. - Paused after failures: if delivery fails 50 times in a row (per event, after all retries), the webhook pauses: the CRM stops sending there and shows “Paused after 50 failures in a row” with the last error under Settings → Integrations. Everyone who may manage webhooks gets a notification (in the app, by email if email notifications are on). It continues with “Send again” (resets the counter and sends a test delivery right away), by editing or switching the webhook on, or by “Renew secret”. In addition, the CRM sends a test delivery every 6 hours by itself – if it arrives, the webhook sends again. Events from the paused period are not delivered later.
- Test delivery: event
webhook.pingwith{ "webhook_id": "…" }indata, signed like every event. Simply answer events you don't know with2xx.
message.received, conversation.* and contact.*, message texts, names, phone numbers and email addresses of your customers go to the address you enter (for example your automation tool). The CRM only sends what you subscribe to, and only to targets an admin has entered. Check that the target system may process this data (data processing agreement, server location) and subscribe only to the events you need. The same applies to API keys with conversations:read and users:read (email addresses of your team). Only send webhooks over https://.Verify the webhook signature (since 1.1.60)
Every delivery is signed, so your system can check that the data really comes from The-Y CRM and wasn't changed on the way.
Secret: it is shown once when you create the webhook (whsec_…). Afterwards it is only stored encrypted and not visible anywhere. Lost it? “Renew secret” – the old one stops working immediately.
| Header | Content |
|---|---|
X-TheY-Timestamp | time of the delivery in seconds since 1970 (Unix time) |
X-TheY-Signature | v1=<hex> – HMAC-SHA256 with the secret over <X-TheY-Timestamp>.<body> (timestamp, a dot, the unchanged body) |
X-TheY-Event | e.g. contact.created |
X-TheY-Event-Id | event ID (evt_…, since 1.1.62). The same on every retry and for all webhooks of the same event; also in the signed body as id. Use it to detect duplicate deliveries |
X-TheY-Delivery | ID of this delivery to this webhook (stays the same on retries) |
X-KSCRM-Signature, X-KSCRM-Event | old: HMAC-SHA256 over the body only, without a timestamp. Still sent so existing receivers don't break |
X-KSCRM-Signature header will be removed with version 1.2.0. Until then, verify X-TheY-Signature as shown below.How to verify: compute the signature yourself and compare in constant time, and reject deliveries whose timestamp is more than 5 minutes off your clock (protects against replaying intercepted deliveries). Important: sign the raw body as received – don't parse it as JSON and serialise it again first.
# Node.js (Express)
import crypto from "node:crypto";
import express from "express";
const SECRET = process.env.THEY_WEBHOOK_SECRET; // whsec_…
const app = express();
const alreadyProcessed = new Set(); // in real life rather a table/Redis entry that expires after e.g. 24 h
app.post("/the-y/webhook", express.raw({ type: "application/json" }), (req, res) => {
const ts = Number(req.get("X-TheY-Timestamp"));
const sig = (req.get("X-TheY-Signature") || "").split(",").map((s) => s.trim()).find((s) => s.startsWith("v1="))?.slice(3) || "";
if (!Number.isInteger(ts) || Math.abs(Date.now() / 1000 - ts) > 300) return res.status(400).send("too old");
const want = crypto.createHmac("sha256", SECRET).update(`${ts}.${req.body.toString("utf8")}`).digest("hex");
const a = Buffer.from(sig, "utf8"), b = Buffer.from(want, "utf8");
if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) return res.status(401).send("bad signature");
const event = JSON.parse(req.body.toString("utf8"));
if (alreadyProcessed.has(event.id)) return res.sendStatus(204); // retry – process only once
alreadyProcessed.add(event.id);
// … process event.event, event.data
res.sendStatus(204);
});
# PHP
<?php
$secret = getenv('THEY_WEBHOOK_SECRET'); // whsec_…
$body = file_get_contents('php://input');
$ts = (int)($_SERVER['HTTP_X_THEY_TIMESTAMP'] ?? 0);
$sigHdr = $_SERVER['HTTP_X_THEY_SIGNATURE'] ?? '';
$sig = '';
foreach (explode(',', $sigHdr) as $part) { $part = trim($part); if (str_starts_with($part, 'v1=')) $sig = substr($part, 3); }
if (abs(time() - $ts) > 300) { http_response_code(400); exit('too old'); }
$want = hash_hmac('sha256', $ts . '.' . $body, $secret);
if (!hash_equals($want, $sig)) { http_response_code(401); exit('bad signature'); }
$event = json_decode($body, true);
// … process $event['event'], $event['data']
http_response_code(204);
Inbound webhooks
External systems can create/update data in The-Y via a token URL: POST /api/hooks/<token> (token created in Integrations). Per webhook you choose the access level: upsert (create/update only, deletions ignored — anti-lock-in) or full (incl. delete).
