Create Incident

Creates a new incident in Sodtrack and associates it with a booking, a lead, or a work order.

POST/api/integration/incident

Request

cURL
curl -X POST "https://dev.integration.cl.sodtrack-shared.sodtrack.com/api/integration/incident" \
  -H "Authorization: Bearer $SODTRACK_TOKEN"

Base URL: https://dev.integration.cl.sodtrack-shared.sodtrack.com Β· other environments

Responses

Create Incident
{
  "id": 71,
  "entityType": "lead",
  "entityId": 278,
  "incidentStatus": {
    "id": 1,
    "name": "Create",
    "description": "Created status",
    "isFinalStatus": false,
    "isInitialStatus": true,
    "bookingStatusUpdate": ""
  },
  "reference": "INC-EXT-2026-001"
}

Error responses for this endpoint follow the shared error reference.

Purpose

Creates a new incident in Sodtrack and associates it with a booking, a lead, or a work order.

The target entity is identified by entityType (booking, lead, or work_order) and by entity (using entityId or entityReference). The incident requires a description and an incident reason (by ID; reference is not yet supported). You can optionally set the reporter, creator, and accountable users, an external reference, and dynamic forms data.

Incidents are used to track issues, complaints, or follow-ups. Only booking, lead and work_order are supported for creation.


Field Definitions

πŸ“‹ Request body

FieldTypeRequiredDescription
entityTypestringβœ…Entity type the incident is associated with: "booking", "lead" or "work_order".
entityobjectβœ…Entity identifier: how to find the booking, lead, or work order (by ID or reference).
descriptionstringβœ…Description of the incident.
incidentReasonobjectβœ…Incident reason identifier. Only reasonId is supported; reasonReference is not yet supported.
reporterUserobject❌User who reported the incident. If provided and not resolved, the request fails.
creatorUserobject❌User who created the incident. If provided and not resolved, the request fails.
accountableUserobject❌User accountable for resolving the incident. Optional.
referencestring❌External reference for the incident.
dynamicFormsarray[object]❌Optional form data (if configured for incident creation). See Dynamic forms below.

πŸ“ Dynamic forms

FieldTypeRequiredDescription
dynamicFormsarray[object]❌List of form snapshots to submit.
dynamicForms[].formReferencestringβœ… when form sentIdentifier of the form (must match a form configured for the incident creation flow).
dynamicForms[].valuesarray[object]βœ… when form sentList of field values for this form.
dynamicForms[].values[].fieldReferencestringβœ…Identifier of the form field (must match a field in the form).
dynamicForms[].values[].valuestringβœ…Submitted value for the field. Numbers are accepted and converted to string.

πŸ”— Entity identifier

FieldTypeRequiredDescription
entity.typestringβœ…How the entity is identified: "entityId" or "entityReference".
entity.valuestringβœ…The entity ID (if type is entityId) or the entity reference (if type is entityReference) for the selected entityType (booking, lead, or work order). Must be non-empty.

πŸ“Œ Incident reason identifier

FieldTypeRequiredDescription
incidentReason.typestringβœ…Must be "reasonId". "reasonReference" is not yet supported.
incidentReason.valuestringβœ…Numeric ID of the incident reason (must exist in Sodtrack).

πŸ‘€ User information (reporter, creator, accountable)

FieldTypeRequiredDescription
typestringβœ… when user object sentUser identifier type: "userId", "userEmail", or "userReference".
valuestringβœ… when user object sentThe user ID, email, or reference according to type.

Example Request (booking by reference)

json
{
  "entityType": "booking",
  "entity": {
    "type": "entityReference",
    "value": "BOOK-REF-001"
  },
  "description": "TΓ©cnico no llevΓ³ el equipo correcto.",
  "incidentReason": {
    "type": "reasonId",
    "value": "2"
  },
  "reporterUser": {
    "type": "userEmail",
    "value": "soporte@example.com"
  },
  "creatorUser": {
    "type": "userReference",
    "value": "USER-EXT-001"
  },
  "reference": "INC-EXT-2025-001"
}

Example Request (lead by reference)

json
{
  "entityType": "lead",
  "entity": {
    "type": "entityReference",
    "value": "LEAD-EXT-342"
  },
  "description": "Queja por demora en agendamiento.",
  "incidentReason": {
    "type": "reasonId",
    "value": "2"
  },
  "reporterUser": {
    "type": "userEmail",
    "value": "soporte@example.com"
  },
  "creatorUser": {
    "type": "userEmail",
    "value": "soporte@example.com"
  },
  "reference": "INC-LEAD-001",
  "dynamicForms": [
    {
      "formReference": "incident_creation_form",
      "values": [
        {
          "fieldReference": "incident_creation_form_field_1",
          "value": "Yes"
        }
      ]
    }
  ]
}

Example Request (work order by reference)

json
{
  "entityType": "work_order",
  "entity": {
    "type": "entityReference",
    "value": "WO-EXT-778"
  },
  "description": "Repuesto incorrecto enviado en la orden de trabajo.",
  "incidentReason": {
    "type": "reasonId",
    "value": "3"
  },
  "reporterUser": {
    "type": "userEmail",
    "value": "soporte@example.com"
  },
  "reference": "INC-WO-001"
}

Example Request (minimal)

json
{
  "entityType": "booking",
  "entity": {
    "type": "entityId",
    "value": "12345"
  },
  "description": "Incidente reportado por integraciΓ³n.",
  "incidentReason": {
    "type": "reasonId",
    "value": "1"
  }
}

Response Example

json
{
  "id": 100,
  "entityType": "booking",
  "entityId": 12345,
  "bookingId": 12345,
  "incidentStatus": {
    "id": 1,
    "name": "Open",
    "description": "Incident is open",
    "isFinalStatus": false,
    "isInitialStatus": true,
    "bookingStatusUpdate": ""
  },
  "reference": "INC-EXT-001"
}

When entityType is "work_order", the response carries the work order id in entityId and omits bookingId:

json
{
  "id": 101,
  "entityType": "work_order",
  "entityId": 778,
  "incidentStatus": {
    "id": 1,
    "name": "Open",
    "description": "Incident is open",
    "isFinalStatus": false,
    "isInitialStatus": true,
    "bookingStatusUpdate": ""
  },
  "reference": "INC-WO-001"
}

Response Fields

FieldTypeDescription
idnumberUnique Sodtrack incident ID.
entityTypestringEntity type: "booking", "lead", or "work_order".
entityIdnumberEntity ID (booking id, lead id, or work order id).
bookingIdnumberPresent only when entityType is "booking".
incidentStatusobjectInitial incident status (id, name, description, isFinalStatus, isInitialStatus, bookingStatusUpdate).
referencestringExternal reference if provided in the request.

*Error Responses *

HTTP StatusErrorDescription
400 Bad RequestENTITY_IDENTIFIER_REQUIREDentity.value is missing or empty.
400 Bad RequestENTITY_TYPE_NOT_SUPPORTEDentityType is not supported for creation. Only booking, lead, and work_order are supported.
400 Bad RequestBOOKING_NOT_FOUND_FOR_IDNo booking found for the given entity ID.
400 Bad RequestBOOKING_NOT_FOUND_FOR_REFERENCENo booking found for the given entity reference.
400 Bad RequestMULTIPLE_BOOKINGS_FOUND_FOR_REFERENCEMore than one booking shares the given reference.
400 Bad RequestLEAD_NOT_FOUND_FOR_IDNo lead found for the given entity ID.
400 Bad RequestLEAD_NOT_FOUND_FOR_REFERENCENo lead found for the given entity reference.
400 Bad RequestINVALID_WORK_ORDER_IDentity.value is not a number when resolving a work order by ID.
400 Bad RequestWORK_ORDER_NOT_FOUND_FOR_IDNo work order found for the given entity ID.
400 Bad RequestWORK_ORDER_NOT_FOUND_FOR_REFERENCENo work order found for the given entity reference.
400 Bad RequestINVALID_REPORTER_USERreporterUser was provided but could not be resolved.
400 Bad RequestINVALID_CREATOR_USERcreatorUser was provided but could not be resolved.
400 Bad RequestINVALID_USER_TYPEInvalid user identifier type.
400 Bad RequestINVALID_INCIDENT_REASON_IDReason id must be a number.
400 Bad RequestINCIDENT_REASON_NOT_FOUNDThe incident reason ID does not exist in Sodtrack.
400 Bad RequestINCIDENT_REASON_REFERENCE_NOT_SUPPORTEDResolution by reasonReference is not yet supported. Use reasonId.
400 Bad RequestINVALID_INCIDENT_REASON_TYPEInvalid incident reason identifier type.
400 Bad RequestInvalidParametersOne or more required fields are missing or invalid.
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

Entity identification

  • entityType and entity are required. Supported values for creation are booking, lead, and work_order. The enum may also include project; it is not supported for this endpoint and returns ENTITY_TYPE_NOT_SUPPORTED.
  • entity.value must be non-empty (after trim). Otherwise the request fails with ENTITY_IDENTIFIER_REQUIRED.

Booking resolution

When entityType is booking:

  • entity.type = entityId: value is the booking ID. The booking must exist; otherwise the API returns BOOKING_NOT_FOUND_FOR_ID.
  • entity.type = entityReference: value is the booking reference. No match returns BOOKING_NOT_FOUND_FOR_REFERENCE; multiple matches return MULTIPLE_BOOKINGS_FOUND_FOR_REFERENCE.

Lead resolution

When entityType is lead:

  • entity.type = entityId: value is the lead ID. The lead must exist; otherwise the API returns LEAD_NOT_FOUND_FOR_ID.
  • entity.type = entityReference: value is the lead reference. The lead must exist; otherwise the API returns LEAD_NOT_FOUND_FOR_REFERENCE.

Work order resolution

When entityType is work_order:

  • entity.type = entityId: value is the work order ID and must be numeric; a non-numeric value returns INVALID_WORK_ORDER_ID. The work order must exist; otherwise the API returns WORK_ORDER_NOT_FOUND_FOR_ID.
  • entity.type = entityReference: value is the work order external reference. No match returns WORK_ORDER_NOT_FOUND_FOR_REFERENCE.

User resolution

  • reporterUser and creatorUser are optional and can be sent as null. When either is provided with a non-null value, it must resolve to an existing user by the given identifier (userId, userEmail, or userReference). If the user cannot be resolved, the request fails with INVALID_REPORTER_USER or INVALID_CREATOR_USER respectively.
  • accountableUser is optional. When provided, it is resolved if possible; if it cannot be resolved, the incident may be created without an accountable user (behavior may depend on configuration).
  • Invalid user identifier type returns INVALID_USER_TYPE.

Incident reason

  • incidentReason is required. Only type = reasonId is supported; reasonReference is not yet supported and returns INCIDENT_REASON_REFERENCE_NOT_SUPPORTED.
  • value must be a valid numeric reason ID that exists in Sodtrack. Invalid number returns INVALID_INCIDENT_REASON_ID; non-existent reason returns INCIDENT_REASON_NOT_FOUND.

Data and format

  • Dynamic form data (when provided) is validated and stored for the incident according to the incident creation flow configuration.
  • All timestamps in responses follow ISO 8601 format (UTC) where applicable.