Assign provider

This endpoint assigns a lead to a specific provider (direct) or switches the lead to automatic provider assignment (automatic).

PATCH/api/integration/lead/assign-provider

Request

cURL
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

NameTypeDescription
Originstring

Request body

application/json
{
  "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

FieldTypeRequiredDescription
leadExternalIntegrationLeadIdentifierRequestDTOYesLead identifier object. Supports lookup by lead ID or lead reference.
providerAssignmentProviderAssignmentFromExternalIntegrationRequestDTOYesProvider assignment strategy. Use direct to assign a specific provider or automatic to trigger automatic provider flow.

ExternalIntegrationLeadIdentifierRequestDTO

FieldTypeRequiredDescription
typeenumYesType of lead identifier. Must be one of: leadId or leadReference.
valuestringYesThe lead ID (if type is leadId) or lead reference (if type is leadReference).

ProviderAssignmentFromExternalIntegrationRequestDTO

FieldTypeRequiredDescription
typeenumYesAssignment strategy. Must be one of: direct or automatic.
providerproviderInputToSearchInExternalIntegrationRequestDTONoProvider selector. Required when type is direct; ignored when type is automatic.

providerInputToSearchInExternalIntegrationRequestDTO

FieldTypeRequiredDescription
typeenumYesType of provider identifier. Must be one of: providerId or providerReference.
valuestringnumberYes

Business Rules & Constraints

  • The lead must exist (leadId or leadReference lookup). If not found, the endpoint returns LEAD_NOT_FOUND.

  • For direct assignment:

    • Provider must be resolvable from provider.type + provider.value.

    • provider.type must be one of: providerId, providerReference.

    • Lead status must not be CANCELLED or DONE.

  • For automatic assignment:

    • Lead status must not be CANCELLED or DONE.

    • Lead must not already have a booking or project.

  • If lead assignment constraints fail, the endpoint returns 400 Bad Request with the corresponding validation/business error.


Example Request (Direct Assignment)

json
{
  "lead": {
    "type": "leadReference",
    "value": "LEAD-EXT-001"
  },
  "providerAssignment": {
    "type": "direct",
    "provider": {
      "type": "providerReference",
      "value": "PROV-001"
    }
  }
}

Example Request (Automatic Assignment)

json
{
  "lead": {
    "type": "leadId",
    "value": "342"
  },
  "providerAssignment": {
    "type": "automatic"
  }
}

Example Response

http
HTTP/1.1 200 OK

Example Error Response

json
{
  "statusCode": 400,
  "message": "Lead cannot be updated to automatic provider assignment, it has a booking already",
  "error": "Bad Request"
}