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#
- Open
/portal/settings/api-keys. - Click New key, give it a name, and pick the scopes:
crm:read— list and read contacts, tags, custom fields, SMS consentcrm:write— create/edit contacts and tags, bulk edits, custom field values, SMS consentcrm:*or*— both
- 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_…
| Situation | Result |
|---|---|
| Valid key with the needed scope | request runs |
| Valid key without the needed scope | 403 { "success": false, "error": "insufficient_scope", "required_scope": "crm:write" } |
| Missing, unknown, revoked or expired key | 401 { "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": … }.
| Method | Path | Scope | What it does |
|---|---|---|---|
| GET | /api/portal/crm/contacts | crm:read | List contacts (paged) |
| POST | /api/portal/crm/contacts | crm:write | Create a contact |
| GET | /api/portal/crm/contacts/{id} | crm:read | One contact with tags, custom fields, recent activity |
| PUT | /api/portal/crm/contacts/{id} | crm:write | Update fields; tagIds replaces the whole tag set |
| DELETE | /api/portal/crm/contacts/{id} | crm:write | Delete a contact |
| POST | /api/portal/crm/contacts/bulk | crm:write | Add/remove tags and set custom fields on up to 500 contacts |
| GET | /api/portal/crm/contacts/{id}/sms-consent | crm:read | SMS consent of the contact's phone |
| PUT | /api/portal/crm/contacts/{id}/sms-consent | crm:write | Record consent (accepted: true/false) |
| GET | /api/portal/crm/tags | crm:read | List tags |
| POST | /api/portal/crm/tags | crm:write | Create a tag |
| DELETE | /api/portal/crm/tags/{id} | crm:write | Delete a tag |
| GET | /api/portal/crm/custom-fields?entityType=contact | crm:read | List custom field definitions |
| POST | /api/portal/crm/custom-fields | crm:write | Create a custom field |
| PUT / DELETE | /api/portal/crm/custom-fields/{id} | crm:write | Edit / delete a custom field |
| GET | /api/portal/crm/custom-fields/values?entityType=contact&entityId={id} | crm:read | Values of one contact |
| PUT | /api/portal/crm/custom-fields/values | crm:write | Set 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.setCustomFieldskeys are contact custom field ids;nullclears a value.- If any tag or custom field id is not this company's, the whole request is rejected with
400and nothing is written. - Contacts are handled one by one. Each id comes back as:
updated— withaddedTagIds,removedTagIds,fieldsSetskipped/no_changes— it already had exactly that state (safe to re-run)failed/not_found— not a contact of this companyfailed/error— the write failed;messagesays why. Other contacts are not affected.
- Adding a tag fires the same
tag addedautomations 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" } }'
SMS consent#
# 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#
| Status | Meaning |
|---|---|
| 200 / 201 | OK / created |
| 400 | Invalid body or ids; a tag or custom field from another company |
| 401 | No key, or the key is unknown, revoked or expired |
| 403 | Key lacks the scope (insufficient_scope), or no CRM subscription |
| 404 | Contact / tag / field not found in this company |
| 409 | SMS consent: the number replied STOP |
| 500 | Server 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.