Assign provider
This endpoint assigns a lead to a specific provider (direct) or switches the lead to automatic provider assignment (automatic).
/api/integration/lead/assign-providerRequest
curl -X PATCH "https://dev.integration.cl.sodtrack-shared.sodtrack.com/api/integration/lead/assign-provider" \
-H "Authorization: Bearer $SODTRACK_TOKEN" \
-H "Content-Type: application/json" \
-H "Origin: <your-origin>" \
-d '{
"lead": {
"type": "leadReference",
"value": "LEAD-EXT-342"
},
"providerAssignment": {
"type": "direct",
"provider": {
"type": "providerReference",
"value": "PROV-001"
}
}
}'Base URL: https://dev.integration.cl.sodtrack-shared.sodtrack.com · other environments
Headers
| Name | Type | Description |
|---|---|---|
Origin | string | — |
Request body
{
"lead": {
"type": "leadReference",
"value": "LEAD-EXT-342"
},
"providerAssignment": {
"type": "direct",
"provider": {
"type": "providerReference",
"value": "PROV-001"
}
}
}General Description
This endpoint assigns a lead to a specific provider (direct) or switches the lead to automatic provider assignment (automatic). The lead is identified in the request body by either lead ID or lead reference.
Field Definitions
Request Body: ExternalIntegrationAssignProviderLeadRequestDTO
| Field | Type | Required | Description |
|---|---|---|---|
lead | ExternalIntegrationLeadIdentifierRequestDTO | Yes | Lead identifier object. Supports lookup by lead ID or lead reference. |
providerAssignment | ProviderAssignmentFromExternalIntegrationRequestDTO | Yes | Provider assignment strategy. Use direct to assign a specific provider or automatic to trigger automatic provider flow. |
ExternalIntegrationLeadIdentifierRequestDTO
| Field | Type | Required | Description |
|---|---|---|---|
type | enum | Yes | Type of lead identifier. Must be one of: leadId or leadReference. |
value | string | Yes | The lead ID (if type is leadId) or lead reference (if type is leadReference). |
ProviderAssignmentFromExternalIntegrationRequestDTO
| Field | Type | Required | Description |
|---|---|---|---|
type | enum | Yes | Assignment strategy. Must be one of: direct or automatic. |
provider | providerInputToSearchInExternalIntegrationRequestDTO | No | Provider selector. Required when type is direct; ignored when type is automatic. |
providerInputToSearchInExternalIntegrationRequestDTO
| Field | Type | Required | Description |
|---|---|---|---|
type | enum | Yes | Type of provider identifier. Must be one of: providerId or providerReference. |
value | string | number | Yes |
Business Rules & Constraints
-
The lead must exist (
leadIdorleadReferencelookup). If not found, the endpoint returnsLEAD_NOT_FOUND. -
For
directassignment:-
Provider must be resolvable from
provider.type+provider.value. -
provider.typemust be one of:providerId,providerReference. -
Lead status must not be
CANCELLEDorDONE.
-
-
For
automaticassignment:-
Lead status must not be
CANCELLEDorDONE. -
Lead must not already have a booking or project.
-
-
If lead assignment constraints fail, the endpoint returns
400 Bad Requestwith the corresponding validation/business error.
Example Request (Direct Assignment)
{
"lead": {
"type": "leadReference",
"value": "LEAD-EXT-001"
},
"providerAssignment": {
"type": "direct",
"provider": {
"type": "providerReference",
"value": "PROV-001"
}
}
}
Example Request (Automatic Assignment)
{
"lead": {
"type": "leadId",
"value": "342"
},
"providerAssignment": {
"type": "automatic"
}
}
Example Response
HTTP/1.1 200 OK
Example Error Response
{
"statusCode": 400,
"message": "Lead cannot be updated to automatic provider assignment, it has a booking already",
"error": "Bad Request"
}