Skip to content
Browse documentation

API

CRM integration API

Delegate scoped lead, client, project, task, and pipeline preparation with strict inputs, conflict checks, and durable retry receipts.

Open Markdown

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.

json
{"businessId":"BUSINESS_ID","forms":"none","crm":{"leads":"view","clients":"edit","projects":"edit","pipeline":"none"}}
This is one grant inside the dashboard-authorized key-creation request, not a complete request. Use only permissions required by the task. CRM reads can reveal real customer data; grant them deliberately. Keep the secret in a gitignored local environment file. Never give an external agent a dashboard session as a substitute.

Discover the live contract

  1. 1Send Authorization: Bearer ik_… to GET /api/agent-integration/businesses and select the intended business.
  2. 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.
  3. 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/crmMethodsGrant
/leads and /leads/:idGET list/detail; POST create; PATCH updateleads view/edit
/leads/:id/convert-to-clientPOST with an empty object and retained action identityleads view and clients edit
/clients and /clients/:idGET list/detail; POST create; PATCH updateclients view/edit
/projects and /projects/:idGET list/detail; POST create; PATCH updateprojects view/edit; linking a contact additionally requires clients view
/tasks and /tasks/:idGET list/detail; POST create; PATCH updateprojects view/edit; an active same-business project is required
/pipelineGET columns and revisionpipeline view
/pipeline/preview and /pipeline/applyPOST preview; POST applypipeline edit
/receipts/:idGET this key's mutation status and readback linkcurrent 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.

ts
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.
A pending or uncertain receipt blocks automatic re-execution, including after a process restart. Read its status and the affected entity; a partial save may have occurred. A receipt contains identifiers and status, not a retained snapshot of customer data. Successful replay reads current authorized state, so the entity may have changed since the original 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.

json
{"expectedUpdatedAt":"2026-10-04T12:00:00.000Z","patch":{"status":"in-progress"}}

Preview and apply a pipeline

  1. 1GET /pipeline to read columns and revision. Preserve every existing column ID.
  2. 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.
  3. 3Review returned columns and added IDs. Apply the exact preview through POST /pipeline/apply with expectedRevision, columns, previewToken, and a retained Idempotency-Key.
  4. 4A stale revision or changed preview returns 409. Read and preview again rather than incrementing a revision blindly.
You can add, rename, and reorder columns. Removing existing IDs requires a separate lead migration and is rejected, including empty columns that concurrent writes or restored leads may reference. The dashboard uses the same preservation and revision rules. Lead stage updates must target a configured column.

Errors and verification

ResponseRecovery
400 invalid_argsUse the current schema; unknown fields and invalid bounds are rejected
401 / 403Check credential, expiry/revocation, selected business, grants, current membership and billing/feature access
404Check the exact business and record ID; foreign or unavailable records are not returned
409Inspect conflict, preview, or idempotency receipt; reconcile and read back before further writes
429 / 503Respect 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.