Update order via API

You can easily update existing order by adding comments or changing its preparation state through TWICE Admin API

Written by
Karri Hiekkanen
Published on
Dec 20, 2024
Updated on
Dec 20, 2024

You can update an existing order by adding internal comments and changing its prepared state.

You do it by using PATCH call to the /orders/{id} endpoint.

Parameters

The only required parameter is the id, which is used to identify, which order you want to update.

You can use the following parameters, depending on what you want to update:

  • prepared, which changes the preparation state between prepared and unprepared. It uses boolean (true or false).
  • staffComment, which enables you to change the comment field for the order. It uses string.

Example response

If the order id is correct and you have proper access to the API, you'll receive similar 200 response to the example below with the updated properties (staffComment and/or prepared).

{
  "id": "12ckKcHWl70HEF3uadzd",
  "createdAt": "2024-12-12T15:12:45.711Z",
  "startDate": "2024-12-13T15:00:00.000Z",
  "initialStartDate": "2024-12-13T15:00:00.000Z",
  "endDate": "2024-12-14T15:00:00.000Z",
  "payment": {
    "paid": 10000,
    "refunded": 0,
    "authorised": 10000,
    "cancelled": 0,
    "captured": 10000
  },
  "deposit": {
    "paid": 10000,
    "refunded": 0,
    "authorised": 10000,
    "cancelled": 0,
    "captured": 10000
  },
  "cancellationPolicy": [
    {
      "hoursBefore": 24,
      "refundPercentage": 50,
      "displayAs": "days"
    }
  ],
  "channel": "admin",
  "state": "booked",
  "store": {
    "name": "ACME Store",
    "storeId": "Ll7mWWQmhmAnbgSUZdLn",
    "address": {
      "address": "123 Main St",
      "zipCode": "12345",
      "city": "New York",
      "country": "United States",
      "state": "New York"
    }
  },
  "customerDetails": {
    "firstName": "John",
    "lastName": "Doe",
    "phone": "+1555555555",
    "email": "john@doe.com",
    "marketingConsent": true,
    "language": "en",
    "address": {
      "address": "123 Main St",
      "zipCode": "12345",
      "city": "New York",
      "country": "United States",
      "state": "New York"
    },
    "customerId": "xiCwjojw2iLzjKIjh4lc"
  },
  "terms": {
    "accepted": true,
    "timestamp": "2024-12-12T15:12:45.711Z"
  },
  "staffComment": "Customer will arrive 30 minutes late.",
  "orderNumber": 1507,
  "prepared": false,
  "pricing": {
    "total": 10000,
    "currency": "USD",
    "subtotal": 10000,
    "totalTaxes": 2400,
    "totalDiscounts": 0,
    "taxExcluded": false,
    "taxLines": [
      {
        "price": 2400,
        "rate": 0.24
      }
    ],
    "deposit": {
      "value": 0,
      "type": "payment"
    }
  },
  "items": [
    {
      "id": "1Lml7QAhnlCP2KFwilfa",
      "productId": "miR5bIalgvWHABPCutO4",
      "name": {
        "def": "E-bike package"
      },
      "itemCodes": [
        "E-1"
      ],
      "variantId": "XCNX4I3UCJ100VA7Ebqr",
      "variantValues": [
        {
          "def": "Small"
        }
      ],
      "startDate": "2024-12-13T15:00:00.000Z",
      "endDate": "2024-12-14T15:00:00.000Z",
      "cancelled": false,
      "payment": {
        "paid": 10000,
        "refunded": 0,
        "authorised": 10000,
        "cancelled": 0,
        "captured": 10000
      },
      "deposit": {
        "paid": 10000,
        "refunded": 0,
        "authorised": 10000,
        "cancelled": 0,
        "captured": 10000
      },
      "pricing": {
        "total": 10000,
        "currency": "USD",
        "subtotal": 10000,
        "totalTaxes": 2400,
        "totalDiscounts": 0,
        "taxExcluded": false,
        "taxLines": [
          {
            "price": 2400,
            "rate": 24
          }
        ],
        "manualDiscount": 0,
        "deposit": 0,
        "listPrice": 10000,
        "originalListPrice": 10000
      },
      "purchaseType": "rental",
      "itemSkus": [
        {
          "units": 1,
          "skuId": "qvfNAMW7aYvDLJYPtBPf",
          "type": "single",
          "itemCodes": [
            "E-1"
          ]
        }
      ],
      "packageItems": [
        {
          "id": "1Lml7QAhnlCP2KFwilfa",
          "productId": "miR5bIalgvWHABPCutO4",
          "name": {
            "def": "Bicycle helmet"
          },
          "itemCodes": [
            "E-1"
          ],
          "variantId": "XCNX4I3UCJ100VA7Ebqr",
          "variantValues": [
            {
              "def": "Small"
            }
          ],
          "startDate": "2024-12-13T15:00:00.000Z",
          "endDate": "2024-12-14T15:00:00.000Z",
          "cancelled": false,
          "payment": {
            "paid": 10000,
            "refunded": 0,
            "authorised": 10000,
            "cancelled": 0,
            "captured": 10000
          },
          "deposit": {
            "paid": 10000,
            "refunded": 0,
            "authorised": 10000,
            "cancelled": 0,
            "captured": 10000
          },
          "pricing": {
            "total": 10000,
            "currency": "USD",
            "subtotal": 10000,
            "totalTaxes": 2400,
            "totalDiscounts": 0,
            "taxExcluded": false,
            "taxLines": [
              {
                "price": 2400,
                "rate": 24
              }
            ],
            "manualDiscount": 0,
            "deposit": 0,
            "listPrice": 10000,
            "originalListPrice": 10000
          },
          "purchaseType": "rental",
          "itemSkus": [
            {
              "units": 1,
              "skuId": "qvfNAMW7aYvDLJYPtBPf",
              "type": "single",
              "itemCodes": [
                "E-1"
              ]
            }
          ],
          "removedFromPackage": false
        }
      ]
    }
  ],
  "persons": [
    {
      "firstName": "John",
      "lastName": "Doe",
      "phone": "+1555555555",
      "email": "john@doe.com",
      "marketingConsent": true,
      "language": "en",
      "address": {
        "address": "123 Main St",
        "zipCode": "12345",
        "city": "New York",
        "country": "United States",
        "state": "New York"
      },
      "customerId": "xiCwjojw2iLzjKIjh4lc",
      "id": "kCrBAzNy5Xoty6q1EfOl",
      "createdAt": "2024-12-12T15:12:45.713Z",
      "isLiableCustomer": true,
      "additionalDetails": [],
      "staffComment": "This customer will arrive 15min late",
      "itemIds": [
        "1Lml7QAhnlCP2KFwilfa"
      ]
    }
  ],
  "delivery": {
    "name": {
      "def": "Express delivery"
    },
    "pricing": {
      "total": 10000,
      "currency": "USD",
      "subtotal": 10000,
      "totalTaxes": 2400,
      "totalDiscounts": 0,
      "taxExcluded": false,
      "taxLines": [
        {
          "price": 2400,
          "rate": 24
        }
      ],
      "manualDiscount": 0,
      "deposit": 0,
      "listPrice": 10000,
      "originalListPrice": 10000
    },
    "payment": {
      "paid": 10000,
      "refunded": 0,
      "authorised": 10000,
      "cancelled": 0,
      "captured": 10000
    },
    "deliveryOptionId": "T6aqb6c2yBxbSnRL43d7",
    "to": {
      "timeslot": {
        "startDate": "2024-12-12T15:12:00.000Z",
        "endDate": "2024-12-12T18:12:00.000Z"
      },
      "pricing": {
        "total": 10000,
        "currency": "USD",
        "subtotal": 10000,
        "totalTaxes": 2400,
        "totalDiscounts": 0,
        "taxExcluded": false,
        "taxLines": [
          {
            "price": 2400,
            "rate": 24
          }
        ],
        "manualDiscount": 0,
        "deposit": 0,
        "listPrice": 10000,
        "originalListPrice": 10000
      },
      "handlingTimeMinutes": 120,
      "location": {
        "address": {
          "address": "123 Main St",
          "zipCode": "12345",
          "city": "New York",
          "country": "United States",
          "state": "New York"
        }
      },
      "carrierId": "zjGNRwidgsygaFGsZFBU",
      "carrierName": {
        "def": "Van F255"
      },
      "trackingId": "NyaAuun1Yg4S9U8F2HwK"
    },
    "from": {
      "timeslot": {
        "startDate": "2024-12-12T15:12:00.000Z",
        "endDate": "2024-12-12T18:12:00.000Z"
      },
      "pricing": {
        "total": 10000,
        "currency": "USD",
        "subtotal": 10000,
        "totalTaxes": 2400,
        "totalDiscounts": 0,
        "taxExcluded": false,
        "taxLines": [
          {
            "price": 2400,
            "rate": 24
          }
        ],
        "manualDiscount": 0,
        "deposit": 0,
        "listPrice": 10000,
        "originalListPrice": 10000
      },
      "handlingTimeMinutes": 120,
      "location": {
        "address": {
          "address": "123 Main St",
          "zipCode": "12345",
          "city": "New York",
          "country": "United States",
          "state": "New York"
        }
      },
      "carrierId": "zjGNRwidgsygaFGsZFBU",
      "carrierName": {
        "def": "Van F255"
      },
      "trackingId": "NyaAuun1Yg4S9U8F2HwK"
    }
  },
  "customCheckoutFields": [
    {
      "label": {
        "def": "I have ridden an electric bike before"
      },
      "value": true
    }
  ]
}

Check out our full API documentation for updating an order.

On this page

Start your circular business  with TWICE