Delivery routes

Create 1 to 100 draft delivery routes from one JSON array. Each route links every delivery entry to an existing Order and starts unassigned. Duplicate externalId values are rejected; each item is returned in the batch results.

POSThttp://localhost:3000/api/v1/order-delivery/routes
Method
POST
Content type
application/json
Authentication
Required · active locations · non-expired key
Maximum payload
1 MiB
Request frequency
30 requests per 60 seconds

Request headers

Send these headers with every POST request.

Content-Type: application/json
Authorization: Bearer y3m_ABCD2345_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

To get the authorization key, open Dashboard, use the three-dot menu on the company card, and select API integrations. Under Secret keys, select Create secret key, enable the Order Delivery scope, and assign at least one active location. Copy the full key when it is created because it is shown only once, then send it after Bearer in the Authorization header.

Request fields

Required and optional fields accepted in the JSON request body. Unknown fields are rejected at every level.

FieldTypeRequirementDescription
externalIdstringRequiredCaller-controlled source-system route identifier; it does not need to be a UUID. A value already used by a non-deleted Order Delivery returns ORDER_DELIVERY_ALREADY_EXISTS. A value used only by deleted routes creates a new DRAFT route with a new internal Y3M UUID v7. Maximum 200 characters.
routeobject | nullOptionalOptional route identification. When provided, code is required.
route.codestringOn createRequired when route is provided on create. External route code, stored unchanged. Maximum 100 characters.
route.typestringOptionalOptional external route type, stored exactly as received. Maximum 100 characters.
route.namestringOptionalOptional external route name, stored unchanged. Maximum 200 characters.
datesobjectOn createDocument dates required on create.
dates.scheduleddateOn createFirst scheduled delivery date required on create in YYYY-MM-DD format.
dates.enddateOptionalLast scheduled delivery date in YYYY-MM-DD format. Must not be earlier than dates.scheduled and defaults to dates.scheduled when omitted.
descriptionstring | nullOptionalOptional document description or note. Maximum 1,000 characters.
ordersarrayOn createBetween 1 and 1,000 delivery orders required on create.
orders[].externalIdstringOn createExternal Order identifier required on create. Values must be unique within the route. The route links to the existing Order and uses its stored data rather than copying Order data into Order Delivery. Maximum 200 characters.
orders[].positionintegerOptionalPositive source order position. Supplied positions must be unique; omitted positions are assigned automatically. Orders are stored and displayed by their final position, which may be recalculated by configured delivery route sorting.

Error responses

Possible errors returned by this endpoint and how to resolve them.

StatusCodeMeaningResolution
400INVALID_JSONThe request body is not valid JSON.Send one correctly formatted JSON object.
400INVALID_PAYLOADThe JSON body is not an object.Send a JSON object instead of an array, string, number, or null.
401UNAUTHORIZEDThe Authorization header is missing, malformed, or contains an invalid API key.Send a valid API key using the Bearer authorization scheme.
401API_KEY_EXPIREDThe API key has reached its expiration date.Create a new API key and retry the request.
403FORBIDDENThe API key cannot access this module or is not assigned to an active company location.Assign an active location, enable the required module, or use another key.
409ORDER_WORKFLOW_NOT_FOUNDThe Order has no workflow.Check the Order and its workflow in Y3M.
409ORDER_WORKFLOW_CANCELEDThe Order workflow is canceled.Restore the Order to CONFIRMED before retrying.
409ORDER_NOT_QUEUED_FOR_MODULEThe Order is not queued for the requested module, or the module is inactive.Wait for earlier enabled stages to complete and check module availability.
409ORDER_ALREADY_IN_MODULE_PROCESSThe Order is already in a process for the requested module.Manage the existing process in Y3M before retrying.
409ORDER_WORKFLOW_STAGE_MISMATCHThe workflow state does not allow the operation or changed concurrently.Check the workflow state and retry if appropriate.
409ORDER_DELIVERY_ALREADY_EXISTSA non-deleted Order Delivery already uses this externalId.Use another externalId or delete the existing route before creating a new one.
413PAYLOAD_TOO_LARGEThe request body exceeds the 1 MiB limit.Reduce the JSON payload size to 1 MiB or less.
415UNSUPPORTED_MEDIA_TYPEThe Content-Type header is not application/json.Send Content-Type: application/json.
422VALIDATION_ERRORThe JSON is valid but one or more fields do not satisfy the endpoint contract.Use each { path, message } entry in error.details to correct the specified field.
429RATE_LIMIT_EXCEEDEDMore than 30 requests were sent within 60 seconds.Wait for the number of seconds specified by the Retry-After header.
500INTERNAL_ERRORRequest infrastructure, authentication, or rate-limit processing is temporarily unavailable.Retry later. Contact support if the error continues.
500STORAGE_ERRORThe validated payload could not be stored.Retry later. Contact support if the error continues.

Example request

Send this JSON object in the POST request body.

[
  {
    "externalId": "DELIVERY-ROUTE-001",
    "route": {
      "code": "947",
      "type": "Monday",
      "name": "South route"
    },
    "dates": {
      "scheduled": "2026-10-19",
      "end": "2026-10-19"
    },
    "description": "Route description",
    "orders": [
      {
        "externalId": "ORDER-001",
        "position": 1
      },
      {
        "externalId": "ORDER-002",
        "position": 2
      }
    ]
  }
]