Batch create orders¶
POST
*base*/orders
You are able to insert multiple orders at the same time by changing the endpoint from <base>/order
to <base>/orders
and sending data for each order inside an object with defined keys. You will get back responses for each order using the same defined keys you sent.
Parameters¶
The request consists of a JSON object with names for each element. The content of each element should be an order object, specified in Create Order. The name for each element is then used in the response to map against either a success response or an error for each order.
order object
required
|
The name of each element could be anything you like. The content of each element are exactly like the parameters for Create Order. |
Request example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | POST <base>/orders HTTP/1.1
Content-type: application/json
{
"x123": {
"invoiceAddress": {
"country": "SE",
"firstName": "John",
"lastName": "Smith",
"address": "12 Alto Road",
"coaddress": "c/o Peter",
"zipcode": "90212",
"city": "San Francisco",
"email": "x@example.com"
},
"deliveryAddress": {
"country": "US",
"firstName": "John",
"lastName": "Smith",
"address": "1500 California St",
"coaddress": "c/o Peter",
"zipcode": "90210",
"city": "San Francisco",
"state": "CA"
},
"products": [
{
"qty": 2,
"ean": "ABCDEFGHIJKL",
"unitPrice": 14.11,
"originalPrice": 100.11,
"itemText" : {
"sku": "SPECIAL-SKU-FOR-THIS-ONE",
"product": "A special product",
"variant": ""
}
},
{
"qty": 1,
"sku": "SKUASKUBSKUC",
"unitPrice": 12.11,
"originalPrice": 50.22
}
]
},
"a1": {
"...": "..."
}
}
|
Response¶
200
Content-type: application/json
object
|
Object with fields for each order using the names from the request.
|
Response examples¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | {
"x123": {
"status": "ok",
"orders": [
1234
]
},
"a1": {
"status": "ok",
"orders": [
1235
]
}
}
|
Response if createOnly
is true
:
1 2 3 4 5 6 7 8 9 10 | {
"x123": {
"status": "ok",
"order": 1234
},
"a1": {
"status": "ok",
"order": 1235
}
}
|
Error examples¶
1 2 3 4 5 6 7 8 9 10 | {
"x123": {
"status": "no",
"msg": "Message about why the order failed to be created."
},
"a1": {
"status": "no",
"msg": "Message about why the order failed to be created."
}
}
|
Since you can insert multiple orders at the same time, some orders might succeed where others fail. Here’s an example with two orders that failed and one that succeeded:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | {
"x123": {
"status": "no",
"msg": "Message about why the order failed to be created."
},
"a1": {
"status": "no",
"msg": "Message about why the order failed to be created."
},
"a2": {
"status": "ok",
"orders": [
1235
]
}
}
|