Create work order

Creates one or more work orders in Sodtrack from an external system.

POST/api/integration/work-order

Request

cURL
curl -X POST "https://dev.integration.cl.sodtrack-shared.sodtrack.com/api/integration/work-order" \
  -H "Authorization: Bearer $SODTRACK_TOKEN" \
  -H "origin: <your-origin>"

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

Headers

NameTypeDescription
originstring

Responses

Create work order
[
  {
    "id": 1024,
    "externalReference": "EXT-WO-0001",
    "customer": {
      "id": 2001,
      "name": "María",
      "lastname": "Gómez",
      "email": "maria.gomez@example.com"
    },
    "provider": {
      "id": 3001,
      "name": "Taller Motos Racing"
    },
    "stakeholder": null,
    "workOrderServiceVariant": {
      "id": 18,
      "name": "Service 10.000 km"
    },
    "product": {
      "id": 1,
      "sku": "MOTO-HND-CG125",
      "name": "Honda CG 125"
    },
    "productUnit": {
      "id": 1,
      "serialNumber": "CG125-CHS-2401"
    },
    "executionDateTime": null
  }
]

Error responses for this endpoint follow the shared error reference.

Purpose

Creates one or more work orders in Sodtrack from an external system.

A single request targets one product and a quantity; one work order is created per unit of quantity, and the response is an array with one entry per created work order.

The customer is resolved or created automatically. The service variant and product are resolved from the references you provide. Optionally, you can assign an existing provider, attribute the work orders to a sales channel, and associate specific product units to the first work orders.


Authentication

HeaderRequiredDescription
x-api-keyExternal integration API key provided by Sodtrack.

Field Definitions

🧾 Work order

FieldTypeRequiredDescription
referencestringExternal reference stored on every created work order.
quantityintegerNumber of work orders to create (minimum 1).

🧍 Customer

The customer is matched by email first, then by reference; if no match exists it is created.

FieldTypeRequiredDescription
customer.namestringCustomer first name / name.
customer.lastNamestringCustomer last name.
customer.emailstringUsed as the primary identity to match an existing customer.
customer.referencestringExternal reference; used to match a customer when email does not match.
customer.identificationTypestringOne of: "PASSPORT", "DRIVER_LICENSE", "NATIONAL_ID", "TAX_ID", "OTHER".
customer.identificationNumberstringIdentification number.
customer.identificationNumberCountrystringCountry of the identification number.
customer.phoneTypestringOne of: "MOBILE", "HOME", "WORK".
customer.phoneNumberstringPhone number.

🧩 Service variant

FieldTypeRequiredDescription
workOrderServiceVariant.typestringOne of: "variantId", "externalReference". Determines how value is interpreted.
workOrderServiceVariant.valuestringInternal variant id when type is "variantId", or the variant external reference when type is "externalReference".

📦 Product

FieldTypeRequiredDescription
product.typestringOne of: "productId", "productSku", "productSerialNumber".
product.valuestringProduct id / sku / unit serial number, per type. When a serial number is sent, the product that owns that unit is used.

📦 Product units (optional)

FieldTypeRequiredDescription
productUnitsarrayUnits to associate. Length must be <= quantity; the first work orders are associated at product-unit level, the rest only at product level.
productUnits[].typestring✅ when a unit is sentOne of: "productUnitId", "productSerialNumber".
productUnits[].valuestring✅ when a unit is sentProduct unit id or unit serial number, per type.

👷 Provider assignment (optional)

FieldTypeRequiredDescription
providerReferencestringReference of an existing provider to assign to all created work orders. If omitted, the work orders are created without a provider.

📣 Sales channel (optional)

FieldTypeRequiredDescription
saleChannel.typestring✅ when object sentOne of: "reference", "id". Determines how value is interpreted.
saleChannel.valuestring✅ when object sentSales channel reference when type is "reference", or the numeric sales channel id (sent as a string) when type is "id".

The sales channel is applied to every created work order. It is not echoed back in the response.

🧍 Stakeholder (optional)

FieldTypeRequiredDescription
stakeholder.namestring✅ when stakeholder sentStakeholder name.
stakeholder.lastnamestringStakeholder last name.
stakeholder.referencestringExternal reference.
stakeholder.emailstringEmail.
stakeholder.phonestringPhone.
stakeholder.identificationNumberstringIdentification number.
stakeholder.identificationNumberCountrystringCountry of the identification number.

Example Request

json
{
  "reference": "EXT-WO-0001",
  "quantity": 1,
  "customer": {
    "name": "María",
    "lastName": "Gómez",
    "email": "maria.gomez@example.com",
    "reference": "EXT-CUSTOMER-002"
  },
  "providerReference": "PROVIDER-REF-A",
  "workOrderServiceVariant": { "type": "externalReference", "value": "SERVICE-VARIANT-REF" },
  "saleChannel": { "type": "reference", "value": "SALES-CHANNEL-WEB" },
  "product": { "type": "productSku", "value": "MOTO-HND-CG125" },
  "productUnits": [{ "type": "productSerialNumber", "value": "CG125-CHS-2401" }]
}

Minimal valid request

json
{
  "reference": "EXT-WO-0002",
  "quantity": 1,
  "customer": { "name": "Juan" },
  "workOrderServiceVariant": { "type": "variantId", "value": "18" },
  "product": { "type": "productId", "value": "6" }
}

Response Example

json
[
  {
    "id": 1024,
    "externalReference": "EXT-WO-0001",
    "customer": { "id": 2001, "name": "María", "lastname": "Gómez", "email": "maria.gomez@example.com" },
    "provider": { "id": 3001, "name": "Taller Motos Racing" },
    "stakeholder": null,
    "workOrderServiceVariant": { "id": 18, "name": "Service 10.000 km" },
    "product": { "id": 1, "sku": "MOTO-HND-CG125", "name": "Honda CG 125" },
    "productUnit": { "id": 1, "serialNumber": "CG125-CHS-2401" },
    "executionDateTime": null
  }
]

Response Fields

FieldTypeDescription
idnumberUnique Sodtrack identifier of the created work order.
externalReferencestringThe reference sent in the request.
customerobjectCustomer summary (id, name, last name, email).
providerobjectAssigned provider summary, or null if no provider was assigned.
stakeholderobjectStakeholder summary, or null if none was sent.
workOrderServiceVariantobjectResolved service variant summary.
productobjectResolved product data (id, sku, name, …).
productUnitobjectAssociated product unit, or null if the work order is only at product level.
executionDateTimestringScheduled execution date-time, or null. This endpoint assigns a provider but does not schedule, so it is null.

One response entry is returned per created work order (quantity entries).


Error Responses

HTTP StatusErrorDescription
400 Bad RequestInvalidParametersA required field is missing or invalid (e.g. quantity < 1, or type not in the allowed values for variant / product / product units).
400 Bad RequestA referenced entity could not be resolved: service variant, product (by sku), product unit (by serial), or providerReference not found. Also when productUnits length exceeds quantity.
400 Bad RequestINVALID_SALES_CHANNELsaleChannel.value is not a valid sales channel reference, or is not a positive integer when type is "id".
401 UnauthorizedMissing or invalid x-api-key.
404 Not FoundsaleChannel.type is "id" and no sales channel exists with that id.
500 Internal Server ErrorUnexpected server error. Contact Sodtrack support.

Business Rules & Constraints

Quantity and response

quantity work orders are created for the product, and the response is an array with one entry per work order.

Customer resolution

The customer is matched by email first, then by reference. If a match is found it is reused as-is; if not, a new customer is created. Sending the same email repeatedly resolves to the same customer.

Provider assignment

providerReference must match an existing provider — this endpoint does not create providers. When provided, the provider is assigned to every created work order. When omitted, the work orders are created without a provider (it can be assigned later). Scheduling is not performed here, so executionDateTime is null.

Sales channel attribution

saleChannel is optional. When sent, the resolved sales channel is applied to every work order created by the request; when omitted, the work orders are created without one.

Selectorvalue containsNot found
saleChannel.type = "reference"Sales channel reference.400 Bad Request with INVALID_SALES_CHANNEL.
saleChannel.type = "id"Numeric sales channel id, sent as a string.404 Not Found. A non-numeric or non-positive value returns 400 Bad Request with INVALID_SALES_CHANNEL.

The sales channel is not returned in the response.

Service variant and product resolution

Selectorvalue contains
workOrderServiceVariant.type = "variantId"Internal variant id.
workOrderServiceVariant.type = "externalReference"Variant external reference.
product.type = "productId"Internal product id.
product.type = "productSku"Product sku.
product.type = "productSerialNumber"A unit serial number; the product that owns that unit is used.

Product unit association

productUnits length must be <= quantity. The first work orders are associated at product-unit level (in the order provided); any remaining work orders are associated only at product level. Each unit is identified by productUnitId or productSerialNumber.