Saltar al contenido principal

Create Lead

This endpoint creates a new lead associated with your organization. It is typically invoked by a flow stage, a form submission, or directly by your integration.

🔹 Endpoint Details​

POST /api/v1/leads

🔒 Authentication​

HeaderRequiredDescription
Content-TypeYesMust be application/json
AuthorizationYesFormat: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature

📝 Request Body​

FieldTypeRequiredDescription
phonestringConditionalLead's phone number. Required when email is not provided
emailstring (email)ConditionalLead's email address. Required when phone is not provided
namestringNoLead's full name
firstNamestringNoLead's first name
lastNamestringNoLead's last name
userGroupIdstring (UUID)NoUUID of the user group the lead is routed to
labelsarray of stringsNoFree-form labels (no special characters)
extraFieldsobjectNoCustom metadata bag
locationobjectNoGeo location captured at lead capture time
deviceobjectNoDevice fingerprint captured at lead capture time
originobjectNoOrigin information captured at lead capture time
statusstringNoLead status label (currently only created)
organizationIdstring (UUID)NoDeprecated — server derives from the security context
userIdstring (UUID)NoDeprecated — use actorIds via update for multi-agent assignment

📤 Request Example​

curl -X POST "https://openapi.onlive.site/api/v1/leads" \
-H "Content-Type: application/json" \
-H "Authorization: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature" \
-d '{
"name": "John Doe",
"firstName": "John",
"lastName": "Doe",
"email": "<[email protected]>",
"phone": "+33612345678",
"userGroupId": "550e8400-e29b-41d4-a716-446655440000",
"labels": [
"hotlead",
"enterprise"
],
"extraFields": {
"source": "landing-page",
"campaign": "spring-2026"
},
"location": {
"country": "FR",
"city": "Paris"
},
"device": {
"type": "mobile",
"os": "iOS"
},
"origin": {
"name": "Website contact form",
"channel": "web"
}
}'

📥 Response​

Success Response (201 Created)​

FieldTypeDescription
idstring (UUID)Unique identifier for the newly created lead
organizationIdstring (UUID)Organization ID
organizationNamestringDenormalized organization name
namestringLead's full name
firstNamestringLead's first name
lastNamestringLead's last name
phonestringLead's phone
emailstringLead's email
statusenumLead status
userGroupIdstring (UUID)Assigned user group ID
userGroupstringDenormalized user group name
actorIdsarray of stringsAssigned agent IDs
labelsarray of stringsLabels
extraFieldsobjectCustom metadata
qualificationnumber (0-1)Lead qualification score
sentToIntegrationbooleanWhether the lead has been forwarded to integration
externalIdstringExternal identifier
devicestring (UUID)Primary device ID
locationstring (UUID)Primary location ID
originstring (UUID)Primary origin ID
locationsarray of objectsAll location records
devicesarray of objectsAll device records
originsarray of objectsAll origin records
interactionsarray of objectsAll interactions
historicsarray of objectsHistoric events
createdAtstring (ISO 8601)Creation timestamp
updatedAtstring (ISO 8601)Last update timestamp

See Lead Properties for the full schema and sub-entity structures.

Response Example​

{
"id": "123e4567-e89b-12d3-a456-426614174000",
"organizationId": "123e4567-e89b-12d3-a456-426614174001",
"organizationName": "Acme Inc.",
"name": "John Doe",
"firstName": "John",
"lastName": "Doe",
"phone": "+33612345678",
"email": "[email protected]",
"status": "created",
"userGroupId": "550e8400-e29b-41d4-a716-446655440000",
"userGroup": "Sales Team",
"labels": ["hotlead", "enterprise"],
"extraFields": { "source": "landing-page" },
"qualification": 0,
"sentToIntegration": false,
"locations": [],
"devices": [],
"origins": [],
"interactions": [],
"historics": [],
"createdAt": "2025-05-13T15:00:00Z",
"updatedAt": "2025-05-13T15:00:00Z"
}

❌ Error Responses​

This endpoint follows the standard error format.

🔍 Validation Rules​

  1. Contact channel
    • At least one of phone or email must be provided
    • email is lowercased and validated against RFC format when present
    • phone whitespace is stripped when present
  2. Format
    • userGroupId must be a valid UUID
    • organizationId / userId (deprecated) must be valid UUIDs when present
  3. Labels
    • Cannot contain special characters: ^ ` ~ ! @ # $ % ^ & * ( ) | + - = ? ; : ' " , . < > { } [ ] \ / and spaces
  4. Objects
    • extraFields, location, device, origin must be objects when present

💡 Best Practices​

  1. Contact
    • Always send at least email or phone — never both empty
    • Send name + firstName/lastName when available to enrich the lead
  2. Capture context
    • Use location, device, origin to enrich at lead capture time
    • Use extraFields for integration-specific data
  3. Classification
    • Set labels (no special chars) for filtering and routing
    • Pre-assign userGroupId to route the lead to the right team
  4. Avoid deprecated fields
    • Do not send organizationId (server-derived)
    • Do not send userId (use actorIds via update)

📘 Notes​

  • The organizationId is enforced server-side from the security context
  • sentToIntegration defaults to false
  • qualification defaults to 0
  • Sub-entity lists (locations, devices, origins, interactions, historics) are server-populated

✅ Common Use Cases​

  • 📝 Form Submissions: Capture leads from a "Contact us" form
  • 🔁 Flow Integrations: Persist leads generated by an Onlive flow stage
  • 🧩 CRM Sync: Use externalId to link with your CRM
  • 📊 Segmentation: Apply labels to segment by source or campaign