CRM admin API (API key)

Manage the LeadSuite HQ CRM from outside the portal — scripts, n8n, Zapier, Claude Code — with the same sd_mcp_ API key that the MCP server uses. Everything here also works from a logged-in browser session; the API key is just another way in.

Base URL: https://www.leadsuitehq.com


1. Create a key#

  1. Open /portal/settings/api-keys.
  2. Click New key, give it a name, and pick the scopes:
    • crm:read — list and read contacts, tags, custom fields, SMS consent
    • crm:write — create/edit contacts and tags, bulk edits, custom field values, SMS consent
    • crm:* or * — both
  3. Copy the sd_mcp_… value. It is shown once; only a SHA-256 hash is stored.

Keep the key in an environment variable or secret store, never in code or a repository:

export LEADSUITE_KEY='sd_mcp_…'

A key acts for the company it was created in. Every request is limited to that company's data — there is no parameter that reaches another company.

2. Authentication#

Send the key on every request:

Authorization: Bearer sd_mcp_…
SituationResult
Valid key with the needed scoperequest runs
Valid key without the needed scope403 { "success": false, "error": "insufficient_scope", "required_scope": "crm:write" }
Missing, unknown, revoked or expired key401 { "success": false, "message": "Unauthorized" }
Company has no active CRM subscription (writes only)403 { "success": false, "message": "This feature requires an active crm subscription.", "requiresService": "crm" }

Revoking a key in the settings page takes effect on the next request.

3. Endpoints#

All responses use the envelope { "success": true, "data": … } or { "success": false, "message" | "error": … }.

MethodPathScopeWhat it does
GET/api/portal/crm/contactscrm:readList contacts (paged)
POST/api/portal/crm/contactscrm:writeCreate a contact
GET/api/portal/crm/contacts/{id}crm:readOne contact with tags, custom fields, recent activity
PUT/api/portal/crm/contacts/{id}crm:writeUpdate fields; tagIds replaces the whole tag set
DELETE/api/portal/crm/contacts/{id}crm:writeDelete a contact
POST/api/portal/crm/contacts/bulkcrm:writeAdd/remove tags and set custom fields on up to 500 contacts
GET/api/portal/crm/contacts/{id}/sms-consentcrm:readSMS consent of the contact's phone
PUT/api/portal/crm/contacts/{id}/sms-consentcrm:writeRecord consent (accepted: true/false)
GET/api/portal/crm/tagscrm:readList tags
POST/api/portal/crm/tagscrm:writeCreate a tag
DELETE/api/portal/crm/tags/{id}crm:writeDelete a tag
GET/api/portal/crm/custom-fields?entityType=contactcrm:readList custom field definitions
POST/api/portal/crm/custom-fieldscrm:writeCreate a custom field
PUT / DELETE/api/portal/crm/custom-fields/{id}crm:writeEdit / delete a custom field
GET/api/portal/crm/custom-fields/values?entityType=contact&entityId={id}crm:readValues of one contact
PUT/api/portal/crm/custom-fields/valuescrm:writeSet values on one contact/company/deal

List contacts#

Query parameters: page (default 1), limit (1–100, default 25), search, status, tagId, title, smartList.

curl -s "https://www.leadsuitehq.com/api/portal/crm/contacts?limit=100&page=1" \
  -H "Authorization: Bearer $LEADSUITE_KEY"

Update one contact#

curl -s -X PUT "https://www.leadsuitehq.com/api/portal/crm/contacts/573" \
  -H "Authorization: Bearer $LEADSUITE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "title": "Owner", "tagIds": [12, 13] }'

tagIds replaces the contact's tags. To add or remove without touching the others, use the bulk route below with a single id.

Tags#

# list
curl -s "https://www.leadsuitehq.com/api/portal/crm/tags" -H "Authorization: Bearer $LEADSUITE_KEY"

# create
curl -s -X POST "https://www.leadsuitehq.com/api/portal/crm/tags" \
  -H "Authorization: Bearer $LEADSUITE_KEY" -H "Content-Type: application/json" \
  -d '{ "name": "Mobile", "color": "#16a34a" }'

The REST create does not de-duplicate names — list first if you may run a script twice. (The MCP tool crm_tags_create is idempotent by name.)

Bulk edit contacts#

POST /api/portal/crm/contacts/bulk
{
  "contactIds": [573, 574, 575],
  "addTagIds": [12],
  "removeTagIds": [13],
  "setCustomFields": { "7": "mobile" }
}
  • contactIds — required, 1 to 500 ids.
  • addTagIds, removeTagIds, setCustomFields — at least one is required. A tag may not be in both lists. setCustomFields keys are contact custom field ids; null clears a value.
  • If any tag or custom field id is not this company's, the whole request is rejected with 400 and nothing is written.
  • Contacts are handled one by one. Each id comes back as:
    • updated — with addedTagIds, removedTagIds, fieldsSet
    • skipped / no_changes — it already had exactly that state (safe to re-run)
    • failed / not_found — not a contact of this company
    • failed / error — the write failed; message says why. Other contacts are not affected.
  • Adding a tag fires the same tag added automations as tagging in the portal.

Response:

{
  "success": true,
  "data": {
    "summary": { "updated": 2, "skipped": 0, "failed": 1 },
    "results": [
      { "contactId": 573, "status": "updated", "addedTagIds": [12], "removedTagIds": [], "fieldsSet": [7] },
      { "contactId": 574, "status": "updated", "addedTagIds": [12], "removedTagIds": [13], "fieldsSet": [7] },
      { "contactId": 999, "status": "failed", "reason": "not_found" }
    ]
  }
}

Custom field values (one contact)#

curl -s -X PUT "https://www.leadsuitehq.com/api/portal/crm/custom-fields/values" \
  -H "Authorization: Bearer $LEADSUITE_KEY" -H "Content-Type: application/json" \
  -d '{ "entityType": "contact", "entityId": 573, "values": { "7": "mobile" } }'
# read
curl -s "https://www.leadsuitehq.com/api/portal/crm/contacts/573/sms-consent" \
  -H "Authorization: Bearer $LEADSUITE_KEY"

# record (source is stored as "admin")
curl -s -X PUT "https://www.leadsuitehq.com/api/portal/crm/contacts/573/sms-consent" \
  -H "Authorization: Bearer $LEADSUITE_KEY" -H "Content-Type: application/json" \
  -d '{ "accepted": true }'

Only record accepted: true when the person actually agreed to receive texts. A number that replied STOP returns 409 on accepted: true — only the person can opt back in by texting START.

4. Example: tag mobile vs. landline numbers#

Create the two tags once, then tag in bulk (ids below are examples — use the ids the first two calls return):

curl -s -X POST "https://www.leadsuitehq.com/api/portal/crm/tags" \
  -H "Authorization: Bearer $LEADSUITE_KEY" -H "Content-Type: application/json" \
  -d '{ "name": "Mobile" }'          # → data.id = 21

curl -s -X POST "https://www.leadsuitehq.com/api/portal/crm/tags" \
  -H "Authorization: Bearer $LEADSUITE_KEY" -H "Content-Type: application/json" \
  -d '{ "name": "Landline" }'        # → data.id = 22

curl -s -X POST "https://www.leadsuitehq.com/api/portal/crm/contacts/bulk" \
  -H "Authorization: Bearer $LEADSUITE_KEY" -H "Content-Type: application/json" \
  -d '{ "contactIds": [573, 574], "addTagIds": [21] }'

curl -s -X POST "https://www.leadsuitehq.com/api/portal/crm/contacts/bulk" \
  -H "Authorization: Bearer $LEADSUITE_KEY" -H "Content-Type: application/json" \
  -d '{ "contactIds": [575], "addTagIds": [22] }'

An SMS campaign with audience Tag → Mobile then goes only to the mobile numbers (consent, STOP and do-not-disturb rules still apply at send time).

5. Error codes#

StatusMeaning
200 / 201OK / created
400Invalid body or ids; a tag or custom field from another company
401No key, or the key is unknown, revoked or expired
403Key lacks the scope (insufficient_scope), or no CRM subscription
404Contact / tag / field not found in this company
409SMS consent: the number replied STOP
500Server error — safe to retry the bulk route; finished contacts come back skipped

6. Limits#

  • Bulk: 500 contacts per request. Split larger lists.
  • Contact list: 100 per page.
  • Send requests one after another rather than in parallel; there is no per-key rate limit yet, so be gentle.

MCP equivalent#

The same operations exist as MCP tools — crm_contacts_update (with tagIds), crm_tags_list, crm_tags_create, crm_contact_tags_set, crm_custom_field_values_get/set. See mcp.md.