API
CRM integration API
Delegate scoped lead, client, project, task, and pipeline preparation with strict inputs, conflict checks, and durable retry receipts.
Choose explicit access
Create a temporary integration key in the dashboard. Each selected business has independent CRM grants: leads, clients, projects, and pipeline, each none, view, or edit. Tasks use the projects grant; pipeline uses the issuer's settings permission. Edit includes read. Current membership and feature/billing checks still apply. Existing keys without CRM grants have no CRM access. Form access is separate and can be none for a CRM-only task.
{"businessId":"BUSINESS_ID","forms":"none","crm":{"leads":"view","clients":"edit","projects":"edit","pipeline":"none"}}Discover the live contract
- 1Send Authorization: Bearer ik_… to GET /api/agent-integration/businesses and select the intended business.
- 2Send X-Business-Id on every following call. GET /api/agent-integration/crm/capabilities returns the routes, input schemas, scope, risk, and returned fields currently available to this key and issuer.
- 3Use the live schemas as the execution contract. The documentation catalog at /docs/catalog.json discovers articles; it does not grant or enumerate execution authority.
Read and prepare CRM records
| Path under /api/agent-integration/crm | Methods | Grant |
|---|---|---|
| /leads and /leads/:id | GET list/detail; POST create; PATCH update | leads view/edit |
| /leads/:id/convert-to-client | POST with an empty object and retained action identity | leads view and clients edit |
| /clients and /clients/:id | GET list/detail; POST create; PATCH update | clients view/edit |
| /projects and /projects/:id | GET list/detail; POST create; PATCH update | projects view/edit; linking a contact additionally requires clients view |
| /tasks and /tasks/:id | GET list/detail; POST create; PATCH update | projects view/edit; an active same-business project is required |
| /pipeline | GET columns and revision | pipeline view |
| /pipeline/preview and /pipeline/apply | POST preview; POST apply | pipeline edit |
| /receipts/:id | GET this key's mutation status and readback link | current read access for the affected resource |
Lists accept limit 1–50 (default 20) and a before ObjectId cursor. They return entities and nextCursor, sorted by descending ID. Tasks can additionally filter by projectId. Follow returned cursors; do not assume a single page contains every record. Detail and mutation IDs must belong to the selected business. Reads use explicit projections and omit credentials, hidden private fields, and internal execution context.
Create inputs cover contact information and basic CRM preparation. The live manifest lists exact fields. Server-owned IDs, business scope, assignment, scoring, timestamps, and deletion fields cannot be supplied. Lead creation scores and flags same-source duplicates but deliberately sends no email. Lead conversion reuses a canonical client, links the lead, and records activity without changing its stage or sending notifications. It requires separate leads view and clients edit grants. Task completion, stock consumption, financial changes, deletion, publication, sending campaigns, and billing are unavailable through this API.
Create once and retain the receipt
Every CRM write requires Idempotency-Key: 16–128 URL-safe letters, digits, underscores, or hyphens. Generate one per intended action, retain it locally, and reuse it only for an exact retry. Receipts bind the key, business, operation/target, and validated body. Reusing the identity with different arguments fails. Concurrent requests claim one execution; a second request cannot rerun it. A lost response is not permission to generate another idempotency key.
const headers = {
Authorization: "Bearer " + process.env.INFLOW_INTEGRATION_KEY,
"X-Business-Id": businessId,
"Content-Type": "application/json",
"Idempotency-Key": savedActionId,
};
const response = await fetch(apiBase + "/api/agent-integration/crm/projects", {
method: "POST",
headers,
body: JSON.stringify({ name: "Portfolio website", status: "planning" }),
});
const result = await response.json();
// Retain result.receipt.id and read back result.entity._id.
// Inspect errors and receipt state before attempting any further write.Update with a conflict check
Fetch the entity first. PATCH requires expectedUpdatedAt equal to its returned updatedAt and a nonempty patch. The atomic update is scoped to business, ID, nondeleted state, and that timestamp. A stale update returns 409 revision_conflict. Read again, reconcile the proposed change, and use a new action identity for the revised request; do not change arguments while reusing an old idempotency key.
{"expectedUpdatedAt":"2026-10-04T12:00:00.000Z","patch":{"status":"in-progress"}}Preview and apply a pipeline
- 1GET /pipeline to read columns and revision. Preserve every existing column ID.
- 2POST /pipeline/preview with expectedRevision and the complete proposed columns. Columns require unique id and position, a nonempty label, and a six-digit hex color.
- 3Review returned columns and added IDs. Apply the exact preview through POST /pipeline/apply with expectedRevision, columns, previewToken, and a retained Idempotency-Key.
- 4A stale revision or changed preview returns 409. Read and preview again rather than incrementing a revision blindly.
Errors and verification
| Response | Recovery |
|---|---|
| 400 invalid_args | Use the current schema; unknown fields and invalid bounds are rejected |
| 401 / 403 | Check credential, expiry/revocation, selected business, grants, current membership and billing/feature access |
| 404 | Check the exact business and record ID; foreign or unavailable records are not returned |
| 409 | Inspect conflict, preview, or idempotency receipt; reconcile and read back before further writes |
| 429 / 503 | Respect Retry-After or service recovery; retain the same action identity for an exact retry |
The integration IP/key/account budgets also apply to CRM. Verify returned IDs, business and linked records, then read back the saved state. Report partial outcomes and remaining user decisions. For multi-agent work, assign one writer per asset and share IDs, revisions, and receipts without sharing secrets. See Working with agents and Integration API.