XM

Order Query

Path:

POST https://{baseurl}/api-order/orders/query

This API is primarily used to build/create the Orders listing page to display orders in a paginated response based on the filter criteria in the request body.

Headers

Content-Type : application/json

x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

x-api-key : d41d8cd98f00b204e9800998ecf8427e

Parameters

Type: body

Name: The pagination and order filtering criteria.

Required: true

Sample Request

Path:

POST https://{baseurl}/api-order/orders/query
{
"offset": 0,
"limit": 2,
"sortBy": "createdAt",
"sortDirection": "asc",
"filters": {
"date": {
"gte": "2020-05-03T00:00:00.000Z",
"lte": "2020-12-03T23:59:59.999Z"
},
"status": ["ORDER_CREATED", "ORDER_CONFIRMED", "ORDER_CANCELLED", "ORDER_PARTIALLY_SHIPPED", "ORDER_SHIPPED", "ORDER_PARTIALLY_DELIVERED", "ORDER_DELIVERED", "ORDER_RETURNED", "ORDER_PARTIALLY_RETURNED", "ORDER_PAYMENT_AUTHORIZED", "ORDER_PAYMENT_INVALID"]
}
}

Response

Response Code: 200

Message: OK

Description: You will see this message when the order is successfully retrieved based on the specified criteria.

{
"query": {
"limit": 2,
"offset": 0,
"count": 11057,
"orderTotalSum": 7798910.03,
"orderAverage": 705.34,
"totalQuantitySum": 35334,
"statusCounts": {
"ORDER_CREATED": 304,
"ORDER_CONFIRMED": 0,
"ORDER_CANCELLED": 0,
"ORDER_PARTIALLY_SHIPPED": 263,
"ORDER_SHIPPED": 960,
"ORDER_PARTIALLY_DELIVERED": 0,
"ORDER_DELIVERED": 0,
"ORDER_RETURNED": 0,
"ORDER_PARTIALLY_RETURNED": 0,
"ORDER_PAYMENT_AUTHORIZED": 7981,
"ORDER_PAYMENT_INVALID": 1549
}
},
"orders": [
{
"_id": "5ee8ca841e926a0008de19db",
"tags": [],
"cartId": "5ee8ca2071209a0007897b43",
"customerEmail": "[email protected]",
"customerPhone": {
"number": "9179758841",
"kind": "Mobile"
},
"orderCurrency": "USD",
"orderTotal": 31.26,
"taxTotal": 2.32,
"channel": 12,
"status": "ORDER_PAYMENT_AUTHORIZED",
"statusLog": "Order has been placed",
"orderId": "6069-8919-73523",
"shipTo": [
{
"address": {
"name": {
"first": "Alex",
"last": "Weininger"
},
"phone": {
"number": "9179758841",
"kind": "mobile"
},
"email": "[email protected]",
"street1": "125 Millbrook Rd",
"street2": "general delivery",
"city": "Claverack",
"state": "NY",
"country": "US",
"zipCode": "12513-9999",
"kind": "shipping"
},
"promosApplied": [],
"_id": "5ee8ca55a5005e0008ab0c40",
"shipToType": "SHIP_TO_ADDRESS",
"taxCode": "FR020000",
"shipToId": 396,
"price": 10.94,
"currency": "USD",
"shipmentMethodId": "5d8cbfd3164e448ba1d12f7501141027",
"estimatedTax": 0.88,
"shipmentCarrier": "FedEx",
"shipmentMethod": "Ground®",
"total": 11.82,
"id": "5ee8ca55a5005e0008ab0c40"
}
],
"items": [
{
"group": [
"5e2cf73f45570b000863c48b"
],
"promosApplied": [],
"_id": "5ee8ca2071209a0007897b44",
"price": 18,
"weightUnit": "lb",
"itemId": 1000002892,
"quantity": 1,
"sku": "1561664",
"taxCode": "PE090100",
"title": "Bud Vase Dark Blue",
"weight": 0.5,
"lineItemId": 1,
"currency": "USD",
"shipToId": 396,
"discount": 0,
"estimatedTax": 1.44,
"total": 19.44,
"id": "5ee8ca2071209a0007897b44"
}
],
"shipments": [],
"revision": 1,
"totalQuantity": 1,
"events": [],
"createdAt": "2020-06-16T13:35:00.637Z",
"updatedAt": "2020-06-16T13:35:03.836Z",
"__v": 0
},
{
"_id": "5ee8cb191e926a0008de19e3",
"tags": [],
"cartId": "5ee8bdfe71209a0007897ad7",
"customerUserId": "5ec8155d2c1cb500076e2d02",
"customerEmail": "[email protected]",
"customerPhone": {
"number": "9179758841",
"kind": "Mobile"
},
"orderCurrency": "USD",
"orderTotal": 31.26,
"taxTotal": 2.32,
"channel": 12,
"status": "ORDER_PAYMENT_AUTHORIZED",
"statusLog": "Order has been placed",
"orderId": "2216-3946-51595",
"shipTo": [
{
"address": {
"name": {
"first": "alex",
"last": "weininger"
},
"phone": {
"number": "9179758841",
"kind": "mobile"
},
"email": "[email protected]",
"street1": "125 Millbrook Rd",
"street2": "general delivery",
"city": "Claverack",
"state": "NY",
"country": "US",
"zipCode": "12513-9999",
"kind": "shipping"
},
"promosApplied": [],
"_id": "5ee8caf3a5005e0008ab0c42",
"shipToType": "SHIP_TO_ADDRESS",
"taxCode": "FR020000",
"shipToId": 398,
"price": 10.94,
"currency": "USD",
"shipmentMethodId": "fd618d13fa44413393f6a565d7a61edb",
"estimatedTax": 0.88,
"shipmentCarrier": "FedEx",
"shipmentMethod": "Ground®",
"total": 11.82,
"id": "5ee8caf3a5005e0008ab0c42"
}
],
"items": [
{
"group": [
"5e2cf73f45570b000863c48b"
],
"promosApplied": [],
"_id": "5ee8bdfe71209a0007897ad8",
"price": 18,
"weightUnit": "lb",
"itemId": 1000002892,
"quantity": 1,
"sku": "1561664",
"taxCode": "PE090100",
"title": "Bud Vase Dark Blue",
"weight": 0.5,
"lineItemId": 1,
"currency": "USD",
"shipToId": 398,
"discount": 0,
"estimatedTax": 1.44,
"total": 19.44,
"id": "5ee8bdfe71209a0007897ad8"
}
],
"shipments": [],
"revision": 1,
"totalQuantity": 1,
"events": [],
"createdAt": "2020-06-16T13:37:29.646Z",
"updatedAt": "2020-06-16T13:37:30.835Z",
"__v": 0
}
]
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the status provided is an invalid status.

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in body: /filters/status/0 should be equal to one of the allowed values"
}

Error Code: 403

Message: Forbidden

Description: You will see this error when the account number is incorrect in the x-site-context (for a multi-tenent client).

{
"message": "Forbidden"
}

Change Log

  • June - 2021

  • July - 2020 First updated