Orders

Update Order by ID

Change some of the details of an existing order in your depot. Only the fields you send are changed. Everything else keeps its stored value. The response is {order, errors}, where order is the updated order in the same shape as GET /orders/{id}.

List fields replace the stored list instead of merging with it:

  • Sending line_items, custom_fields, capacities, tags, skills or emails replaces the order's whole list. An empty array clears it.
  • Line items are matched to existing ones by product_code. Stored line items that are missing from the list are removed.
  • Sending any time-window field (delivery_time_windows, pickup_time_windows or time_windows) replaces all of the order's time windows, both delivery and pickup.

If you change the delivery or pickup address without sending new coordinates, the new address is geocoded. A geocoding failure doesn't fail the update. The change is saved, and the failure is returned in errors with name GEOCODING_FAILED.

You get 400 INVALID_INPUT if:

  • the new order_number already belongs to another order in your depot
  • a skill, vehicle or third party doesn't exist
  • a type change would leave the order without the address its new type needs

If the order isn't in your depot, you get 404 RESOURCE_NOT_FOUND. The order's customer can't be changed here. order_exchange can only change the reference of an existing exchange pair. Pairs are created with POST /orders.

put/orders/{id}

Request

  • Base URL: https://api.smartroutes.io/v2
  • URL: https://api.smartroutes.io/v2/orders/{id}
  • Auth: none declared

Path parameters

idstring required

ID of the order to update.

Response

Successful response

Example response

{
  "order": {
    "order_number": "ORD123",
    "type": "delivery",
    "delivery_contact_name": "John Doe",
    "delivery_contact_number": "+123456789",
    "delivery_contact_email": "john.doe@example.com",
    "delivery_address": "123 Main St",
    "delivery_postcode": "12345",
    "delivery_lat": 40.7128,
    "delivery_lng": -74.006,
    "delivery_duration": 30,
    "delivery_notes": "Leave at the doorstep",
    "delivery_date": "2023-12-31",
    "delivery_available_days": [
      "MONDAY",
      "TUESDAY",
      "THURSDAY"
    ],
    "pickup_address": "456 Oak St",
    "pickup_postcode": "54321",
    "pickup_duration": 30,
    "pickup_lat": 40.73061,
    "pickup_lng": -73.935242,
    "pickup_notes": "Call upon arrival",
    "pickup_contact_name": "Jane Smith",
    "pickup_contact_number": "+987654321",
    "pickup_contact_email": "jane@example.com",
    "pickup_available_days": [
      "MONDAY",
      "WEDNESDAY",
      "FRIDAY"
    ],
    "parts": 2,
    "vehicle_assignment": {
      "vehicle_id": 1986
    },
    "emails": [
      {
        "email": "example@email.com"
      },
      {
        "email": "example2@email.com"
      }
    ],
    "third_party": {
      "id": 134
    },
    "tags": [
      "Tag1",
      "Tag2"
    ],
    "order_value": 23.5,
    "currency": "EUR",
    "value_source": "DERIVED",
    "line_items": [
      {
        "product_code": "P001",
        "product_name": "Product 1",
        "product_quantity": 2,
        "product_unit_price": 4.25,
        "product_value": 8.5,
        "product_value_source": "DERIVED",
        "quantity_outstanding": 0.5,
        "status": "PARTIALLY_DELIVERED",
        "date": "2024-01-01",
        "custom_fields": [
          {
            "id": 123,
            "value": "Value 1",
            "name": "Custom Field 1"
          }
        ]
      },
      {
        "product_code": "P002",
        "product_name": "Product 2",
        "product_quantity": 1,
        "product_value": 15,
        "product_value_source": "MANUAL",
        "capacities": [
          {
            "id": 201,
            "type": "WEIGHT",
            "capacity": 100
          }
        ],
        "status": "DELIVERED",
        "date": "2024-01-01",
        "custom_fields": [
          {
            "id": 321,
            "value": "Value 1",
            "name": "Custom Field 2"
          }
        ]
      }
    ],
    "time_windows": [
      {
        "from": "08:00",
        "to": "12:00",
        "type": "pickup"
      },
      {
        "from": "14:00",
        "to": "18:00",
        "type": "delivery"
      }
    ],
    "skills": [
      "skill1",
      "skill2"
    ],
    "custom_fields": [
      {
        "id": 123,
        "value": "Value 1"
      },
      {
        "id": 234,
        "value": "Value 2"
      }
    ],
    "capacities": [
      {
        "id": 1,
        "capacity": 100
      },
      {
        "id": 2,
        "capacity": 50
      }
    ]
  },
  "errors": []
}

Changes

No recorded changes to this operation across all 1 revision of this API.