Create Lead
Creates a new lead in Sodtrack for a given service.
/api/integration/leadRequest
curl -X POST "https://dev.integration.cl.sodtrack-shared.sodtrack.com/api/integration/lead" \
-H "Authorization: Bearer $SODTRACK_TOKEN" \
-H "origin: <your-origin>"Base URL: https://dev.integration.cl.sodtrack-shared.sodtrack.com · other environments
Headers
| Name | Type | Description |
|---|---|---|
origin | string | — |
Responses
{
"id": 4,
"customer_id": 15
}Error responses for this endpoint follow the shared error reference.
Purpose
Creates a new lead in Sodtrack for a given service.
The lead is created with customer information, required qualifying questions (dynamic form field values tied to the service’s lead form), and optional provider assignment and dynamic forms (additional info). Address is optional only for in-store services; for non in-store services, a valid location input is required (see Address and coordinates in Business Rules).
When address is sent without coordinates, Sodtrack may attempt to geocode it automatically (when auto-geocoding is enabled for external integration). For services that are not in-store, the lead creation requires a valid location input: coordinates, address text, or zip code; otherwise the request fails with REQUIRES_ADDRESS_OR_ZIP_CODE (see Address and coordinates in Business Rules).
Provider assignment and dynamic form snapshots are applied after the lead is created; failures in those steps do not fail the request—the lead is still returned.
Field Definitions
🧍 Customer
| Field | Type | Required | Description |
|---|---|---|---|
customer | object | ✅ | Customer or contact information for the lead. |
customer.name | string | ✅ | Customer's first name. |
customer.lastName | string | ❌ | Customer's last name. |
customer.phoneNumber | string | ❌ | Contact phone number in international format. |
customer.email | string | ❌ | Customer's email address. |
customer.identificationNumber | string | ❌ | National ID or tax identification number. |
customer.identificationNumberCountry | string | ❌ | ISO 3166-1 alpha-2 country code for the identification number. |
customer.reference | string | ❌ | External reference of the customer. |
🏠 Address
| Field | Type | Required | Description |
|---|---|---|---|
address | object | ❌ | Service or lead location. Required for non in-store services (see Business Rules). |
address.address | string | ❌ | Main address or street. Used for geocoding when coordinates are not provided. |
address.extraInfo | string | ❌ | Additional address details (e.g., apartment, suite number). |
address.coordinate | object | ❌ | Geographic coordinates of the service location. |
address.coordinate.lat | number | ❌ | Latitude. When provided, must be between -90 and 90. |
address.coordinate.lng | number | ❌ | Longitude. When provided, must be between -180 and 180. |
address.associateAddressToCustomer | boolean | ❌ | Whether the address should be stored and associated to the customer. Defaults to true when omitted. |
address.zipCode | string | ❌ | Optional zip/postal code. Can be used as location input for non in-store services. |
If coordinates are not provided but
address.addressis sent, Sodtrack may attempt to geocode the address automatically if its part of your active features.
If the service is not in-store and the request has no coordinates, no address text, and no zip code, the request fails withREQUIRES_ADDRESS_OR_ZIP_CODE.
📋 Lead context
| Field | Type | Required | Description |
|---|---|---|---|
salesChannelId | number | ✅ | Sodtrack sales channel ID. Must exist and be valid. |
serviceId | number | ✅ | Sodtrack service ID. Must exist and have an associated lead form. |
reference | string | ❌ | External reference for the lead. Stored for your tracking; uniqueness is not enforced by this endpoint. |
🧩 Qualifying questions
| Field | Type | Required | Description |
|---|---|---|---|
qualifyingQuestions | array[object] | ✅ | Answers to the lead form’s qualifying (dynamic) fields. Each entry must reference a dynamic field of the service’s lead form. |
qualifyingQuestions[].fieldReference | string | ✅ | Field reference of the dynamic field in the lead form. Must match a field belonging to the lead form of the given serviceId. |
qualifyingQuestions[].value | string | ✅ | Value for the field. |
Each
fieldReferencemust correspond to a dynamic field of the lead form associated with the request’s service. Invalid or mismatched references cause the request to fail withINVALID_QUALIFYING_QUESTION_WITH_ID_REFERENCE.
📄 Dynamic forms (additional info)
| Field | Type | Required | Description |
|---|---|---|---|
dynamicForms | array[object] | ❌ | Additional dynamic form snapshots to attach to the lead after creation. Processed after the lead is created; errors are logged and do not fail the request. |
dynamicForms[].formReference | string | ✅ when dynamic form sent | Reference of the form. |
dynamicForms[].values | array[object] | ✅ when dynamic form sent | Field values for the form. |
dynamicForms[].values[].fieldReference | string | ✅ | Reference of the field. |
dynamicForms[].values[].value | string | ✅ | Value for the field. |
👷 Provider assignment
| Field | Type | Required | Description |
|---|---|---|---|
providerAssignment | object | ❌ | How to assign a provider to the lead. Applied after the lead is created; errors are logged and do not fail the request. |
providerAssignment.type | string | ✅ when providerAssignment sent | Assignment type: "direct" (specific provider) or "automatic". |
providerAssignment.provider | object | ✅ when type = "direct" | Provider to assign. Omitted when type is "automatic". |
providerAssignment.provider.type | string | ✅ when direct | Identifier type: "providerId" or "providerReference". |
providerAssignment.provider.value | string | number | ✅ when direct |
Example Request (with address and provider assignment)
{
"customer": {
"name": "María",
"lastName": "García",
"phoneNumber": "+56912345678",
"email": "maria.garcia@example.com",
"reference": "CUST-EXT-001"
},
"address": {
"address": "Av. Providencia 1234, Santiago",
"extraInfo": "Depto 501",
"coordinate": {
"lat": -33.4372,
"lng": -70.6506
},
"zipCode": "7500000"
},
"salesChannelId": 1,
"serviceId": 42,
"reference": "LEAD-EXT-200",
"qualifyingQuestions": [
{
"fieldReference": "1",
"value": "high"
}
],
"providerAssignment": {
"type": "direct",
"provider": {
"type": "providerId",
"value": 10
}
}
}
Example Request (with zip_code)
{
"customer": {
"name": "María",
"lastName": "García",
"phoneNumber": "+56912345678",
"email": "maria.garcia@example.com",
"reference": "CUST-EXT-001"
},
"address": {
"zipCode": "7500000"
},
"salesChannelId": 1,
"serviceId": 42,
"reference": "LEAD-EXT-201",
"qualifyingQuestions": [
{
"fieldReference": "1",
"value": "high"
}
]
}
Example Request (minimal)
{
"customer": {
"name": "Juan Pérez"
},
"salesChannelId": 1,
"serviceId": 42,
"qualifyingQuestions": [
{
"fieldReference": "1",
"value": "high"
}
]
}
Response Example
{
"id": 1001,
"customer_id": 502
}
Response Fields
| Field | Type | Description |
|---|---|---|
id | number | Unique Sodtrack lead ID. |
customer_id | number | Sodtrack customer ID associated with the lead. |
Error Responses
| HTTP Status | Error | Description |
|---|---|---|
400 Bad Request | INVALID_SERVICE | The given serviceId does not exist or has no associated lead form. |
400 Bad Request | INVALID_SALES_CHANNEL | The given salesChannelId does not exist or is invalid. |
400 Bad Request | INVALID_LATITUDE_OR_LONGITUDE | address.coordinate was sent with lat/lng outside valid ranges (lat -90–90, lng -180–180). |
400 Bad Request | REQUIRES_ADDRESS_OR_ZIP_CODE | The service is not an in-store service and the request did not include coordinates, address text, or zip code. |
400 Bad Request | INVALID_QUALIFYING_QUESTION_WITH_ID_REFERENCE: {fieldReference} | A qualifying question fieldReference does not match any dynamic field for the service’s lead form. |
400 Bad Request | FIELD_REFERENCE_IS_REQUIRED | A qualifying question entry is missing fieldReference. |
400 Bad Request | InvalidParameters | One or more required fields are missing or invalid (e.g. validation pipeline). |
401 Unauthorized | — | Authentication token missing or expired. |
403 Forbidden | — | The API key or origin is not authorized. |
500 Internal Server Error | — | Unexpected server error. Contact Sodtrack support. |
Business Rules & Constraints
Service and sales channel
-
serviceIdmust identify an existing Sodtrack service that has an associated lead form. Otherwise the request fails withINVALID_SERVICE. -
salesChannelIdmust identify an existing sales channel. Otherwise the request fails withINVALID_SALES_CHANNEL. -
For in-store services, Sodtrack uses the sales channel address and the request
addresscan be omitted. -
For non in-store services, a valid location input is required: coordinates, address text, or zip code.
Address and coordinates
-
When
addressis sent withcoordinate****: The system validate those to be valid coordinates. Otherwise the request fails withINVALID_LATITUDE_OR_LONGITUDE. -
When
addressis sent withaddress(street) but no coordinates: Sodtrack may attempt to geocode the address automatically when enabled for external integration. If geocoding succeeds, coordinates are filled in; if it fails, they remain missing. -
When the service is not an in-store service: The lead creation step requires at least one valid location input: coordinates (
address.coordinate), address text (address.address), or zip code (address.zip_code). If none of these are provided, the request fails withREQUIRES_ADDRESS_OR_ZIP_CODE.
Qualifying questions
-
Each element in
qualifyingQuestionsmust have afieldReferencethat matches a dynamic field of the lead form associated with the request’s service. -
If a
fieldReferencedoes not exist or belongs to a different form, the request fails withINVALID_QUALIFYING_QUESTION_WITH_ID_REFERENCE(including the invalid reference or a message that the field is not associated with the service’s lead form). -
The array can be empty if the lead form has no required qualifying fields.
Provider assignment and dynamic forms
-
Provider assignment and dynamic form snapshots are applied after the lead is created.
-
Failures during provider assignment or dynamic form creation are logged but do not cause the endpoint to return an error; the response still returns the created lead (
idandcustomer_id). -
For direct provider assignment,
providerwithtypeandvaluemust be provided; for automatic, noproviderobject is needed.
Lead reference
referenceis an optional external identifier stored with the lead. This endpoint does not enforce uniqueness onreference.
Data and format
-
All timestamps follow the ISO 8601 format (UTC) where applicable.
-
Customer and address data are stored as provided; identification country should be ISO 3166-1 alpha-2 where applicable.