Developers
CRM

Create a lead from a website

Contact form → lead: key limited to leads, email deduplication, idempotency, automatic assignment, conversion.

The most common CRM integration: your website’s contact form creates a lead in QuoSuite, which the sales team then qualifies. The API goes through the same service as the screen: entry rules, “new lead” automations (assignment, call task) and webhooks apply.

1. A key limited to leads

In Settings › API & Integrations, create a key with the single scope crm_leads:write (which covers crm_leads:read). It creates and reads leads, but sees neither the team’s accounts, contacts nor deals (crm:read): the right key for an exposed web server.

2. Deduplicate by email

Before creating, look for a lead that already carries this email (case-insensitive comparison):

GET/crm/leads

curl 'https://quosuite.com/api/public/v1/quosuite/crm/leads?email=rania%40example.tn' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY"

If data.items is not empty, the lead exists: complete it (PATCH /crm/leads/{id}, for example its notes) rather than creating a second one.

3. Create the lead

POST/crm/leads

# One key per operation, reused as is on every retry.
curl -X POST 'https://quosuite.com/api/public/v1/quosuite/crm/leads' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY" \
  -H 'Idempotency-Key: 3f1c2a9e-5b7d-4e8a-9c1f-2d6b8e4a7c30' \
  -H 'Content-Type: application/json' \
  -d '{
  "firstName": "Rania",
  "lastName": "Ben Amor",
  "company": "Boulangeries Ben Amor",
  "email": "rania@example.tn",
  "phone": "+216 98 112 340",
  "city": "Tunis",
  "source": "Website",
  "notes": "Quote request: 3 deck ovens, delivery before March.",
  "tags": [
    "contact-form"
  ],
  "estimatedAmount": 18500,
  "currency": "TND"
}'
  • At least a name, a company or an email: otherwise 422 BUSINESS_RULE_VIOLATION.
  • Idempotency-Key (one UUID per form submission): a retry after a network cut replays the first response, without a second lead.
  • Without ownerId, the lead has no owner: a “New lead › Assign” automation (round robin between salespeople) assigns it right away. To assign it yourself, ownerId must be a user of the workspace (GET /crm/owners).

The response is the lead, in its public form (status: NEW, statusLabel in the requested language).

4. Follow what it becomes

Subscribe to crm_lead.converted to know when the team converts it: data.conversion gives the account, contact, ERP customer record and deal created. See Receive CRM webhooks.

An integration that converts by itself (automatic qualification tool) calls POST /crm/leads/{id}/convert with a key that also carries crm:write:

POST/crm/leads/{id}/convert

# One key per operation, reused as is on every retry.
curl -X POST 'https://quosuite.com/api/public/v1/quosuite/crm/leads/aac39e3a-0c40-44b2-8697-b597f357c5a9/convert' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY" \
  -H 'Idempotency-Key: 3f1c2a9e-5b7d-4e8a-9c1f-2d6b8e4a7c30' \
  -H 'Content-Type: application/json' \
  -d '{
  "account": {
    "mode": "create"
  },
  "contact": {
    "mode": "create"
  },
  "erpClient": {
    "mode": "none"
  },
  "deal": {
    "title": "3 deck ovens",
    "amount": 18500,
    "currency": "TND"
  }
}'

Errors to expect

Statuscodedetail.ruleWhen
400VALIDATION_FAILED—malformed email, unknown field
422BUSINESS_RULE_VIOLATION—no name, company or email; converted lead edited
422BUSINESS_RULE_VIOLATIONCRM_ACCOUNT_NOT_CLIENT, CRM_PARTNER_ALREADY_LINKEDconversion to an ERP record impossible
409CONFLICT—two simultaneous conversions of the same lead