Search…
Orders

Order Object

Not that you need the concept of an Order explained to you, but we're going to do it anyway. It is what is made when a User picks a bunch of things, or just one, that they want to buy.
The total_amount is set by the items and the resources. See sections below for more details.
An order can include only one currency, which means you can not create an order containing two products with two different currencies. Otherwise, you will get the following error:
Error code 400, message: An order can not have products with different currencies
Attributes
Type
Description
currency
string
The currency will be define by the Item(s). 3 letter ISO currency code as defined by ISO 4217.
pickup_address
object
Address used to pickup a pac
delivery_address
object
Address used for delivery.
delivery_status
string
See delivery statuses. Default is PENDING.
delivery_time
object
Expected arrival time for delivery, timestampformat.
pickup_time
object
Expected arrival time for pickup, timestampformat.
order_status
string
See order statuses. Default is CREATED.
items
array
List of items in an order.
human_id
string
Human readable ID that identifies the order easily, e.g. 3AG7UA.
payments
array
List of Payment objects associated with the order.
resources
array
The resources in the order.
total_amount
float
Amount with two decimals. e.g., 12.34. The amount is automatically calculated based on the items in the order.
total_quantity
number
Total number of products in an order, e.g. 3 spoons and 2 forks = 5 products.
units
number
Number of product 'types' in an order, e.g. 3 spoons and 2 forks = 2 product units.
accounting_reference
string
An accounting reference ID.
subscription
object
Associated subscription referenced by subscription_id.
user
object
User associated with order (current user if order is created by a non-admin).
note
string
A note of the order.
coupons
object
See Coupon for more info on the payment method object.
Total Amount Calculation
How we calculate the total_amount is a little complicated due to the flexibility of our products' (and sub products') prices and discounts. However, we keep it simple for you. Just usesum(items.final_price)to calculate total_amount.
An item is a product and any sub_products that are included with that product. When you get the final_price for that item,this is the equation:(item.price + sum(sub_products.price)) * (1 - item.discount) * item.quantity
To show you an example of an order that includes a product and a product along with its sub product, consider the following:
Product A
1
id = productA
2
price = 40
3
discount = 0.10
4
currency = EUR
Copied!
Product B
1
id = productB
2
price = 10
3
discount = 0
4
currency = EUR
Copied!
Sub Product B1 (for Product B)
1
id = subProductB1
2
price = 5
3
discount = 0
4
currency = EUR
Copied!
If we make an order for two Product As with a 10% discount and one Product B with Sub Product B1:
Create an Order
1
{
2
"items": [
3
{
4
"product": "productA",
5
"quantity": 2
6
},
7
{
8
"product": "productB",
9
"quantity": 1,
10
"sub_products": ["subProductB1"]
11
}
12
],
13
[...]
14
}
Copied!
The total_amount will be: 87 EUR

Product A's final price:

40 * (1 - 0.1) * 2 = 72

Product B's (with sub product B1) final price:

(10 + 5) * (1 - 0.0) * 1 = 15

Order Total Amount:

72 + 15 = 87

Order Items

Changes since API version 2019-02-01

2020-03-13 - New attribute `reserved_price`

Since we implemented a new Payment type, Reserved Payment, we introduced this new attribute. It is used to calculate the amount of a Reserved Payment when it is in an Order.
We are deprecating the old image_urland replacing it with Image Object
The attribute items in the Order Object is where you put the products your user wants to buy. These items are stored in an array. Each item has the below attributes. See Updating Items in an Order for more details on how this is used.
All the followings attributes are not editable: name, price, final_price, discount, vat, currency. The goal of these attributes it's to take a snapshot the product at the moment the order is created. Updating a product later will not affect the orders containing it.
Attributes
Type
Description
product
string
A Productunique ID.
quantity
number
The quantity of the product.
sub_products
array
An array of sub-product ID’s associated in the order.
name
string
The Product's name
price
float
The Product's price
reserved_price
float
The Product's reserved price
final_price
float
Calculated value: (price * (1 - discount)) * quantity
discount
float
The Product's discount. A decimal value between 0 and 1, e.g. 0.25 = 25%.
vat
float
The Product's vat. A decimal value between 0 and 1, e.g. 0.25 = 25%.
currency
string
The Product's currency
Percentages are calculated on your behalf when creating an Order Item through the Dashboard.

Order Arguments and Statuses

The table below shows possible values for the attributes date_filter, order_status, and delivery_status used in the Order Object and various order methods.
date_filter
order_status
delivery_status
Possible Values
Description
created
Shows orders by date of creation
delivery
Shows orders by delivery time
Possible Values
Description
CREATED
Order is created
PROCESSING
Order is being processed
DECLINED
Order is declined for some reason
FAILED
Order has failed for some reason
SUCCESS
Order has succeeded
CANCELLED
Order is cancelled
Possible Values
Description
CREATED
Delivery is created
PENDING
Delivery is pending
PROCESSING
Delivery is being processed
ASSIGNING
Delivery has been assigned to a provider
PICKUP_STARTED
Pickup from customer has been sent
PICKUP_ARRIVED
Pickup from customer is complete
DROPOFF_STARTED
Dropoff to customer has been sent
DROPOFF_ARRIVED
Dropoff to customer is complete
CANCELLED
Delivery is cancelled
DONE
Delivery task is done
UNKNOWN
Delivery is unknown
QUEUED
Delivery is in queue

User Role

Create an Order

Parameters
Request
Response
Body Parameters
Type
Description
delivery_address
object
Address used for delivery.
items*
array
List of items associated with an order.
subscription*
object
Associated subscription referenced by subscription_id.
billing_address
object
Address used for billing purposes.
pickup_address
object
Address used to pickup a package.
delivery_status
int
See delivery statuses. Default is PENDING.
delivery_time
int
Expected arrival time for delivery, timestampformat.
pickup_time
string
Expected arrival time for pickup, timestampformat.
note
string
Note field.
resources
array
The resources in the order.
coupon
string
A Coupon ID or code
Either theitemsor the subscriptionparameter should be included in the request.
1
POST /orders HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
6
7
{
8
"items": [
9
{
10
"product": "5703fce3308714000dea1ff1",
11
"quantity": 1
12
},
13
{
14
"product": "5703fcde308714000dea1fe8",
15
"quantity": 3
16
}
17
],
18
"delivery_time": 1472022000000,
19
"delivery_address": {
20
"city": "Oslo",
21
"geo": [
22
59.9294087,
23
10.7643042
24
],
25
"zip_code": "0557",
26
"street_name": "Christies gate 34A",
27
"country": "Norway"
28
},
29
"billing_address": {
30
"city": "Oslo",
31
"geo": [
32
59.9294087,
33
10.7643042
34
],
35
"zip_code": "0557",
36
"street_name": "Christies gate 34A",
37
"country": "Norway"
38
},
39
"note": "some type of note"
40
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"created": {"$date": 1488475795244},
6
"company": {"$oid": "586faf7445ed910006373513"},
7
"delivery_address": {
8
"city": "Oslo",
9
"geo": [
10
59.9294087,
11
10.7643042
12
],
13
"zip_code": "0557",
14
"street_name": "Christies gate 34A",
15
"country": "Norway"
16
},
17
"billing_address": {
18
"city": "Oslo",
19
"geo": [
20
59.9294087,
21
10.7643042
22
],
23
"zip_code": "0557",
24
"street_name": "Christies gate 34A",
25
"country": "Norway"
26
},
27
"_id": {"$oid": "58b85693d76d439fdacea41b"},
28
"total_amount": 40.0,
29
"delivery_time": {"$date": 1472022000000},
30
"note": "some type of note",
31
"total_quantity": 4,
32
"order_status": "CREATED",
33
"items": [
34
{
35
"product": "5703fce3308714000dea1ff1",
36
"quantity": 1,
37
"name": "name of the product",
38
"price": 20,
39
"final_price": 10,
40
"discount": 0.5,
41
"vat": 0.0,
42
"currency": "NOK"
43
},
44
{
45
"product": "5703fcde308714000dea1fe8",
46
"quantity": 3,
47
"name": "name of the product",
48
"price": 10,
49
"final_price": 30,
50
"discount": 0.0,
51
"vat": 0.0,
52
"currency": "NOK"
53
}
54
],
55
"user": {"$oid": "57ee9c72d76d431f85111432"},
56
"units": 2,
57
"delivery_status": "PENDING",
58
"modified": {"$date": 1488475795244},
59
"currency": "NOK"
60
}
Copied!

Update an Order*

Parameters
Request
Response
Path Parameter
Type
Description
order_id
string
ID of the queried order.
Body Parameters
Type
Description
resources
array
An array of resources associated with the order.
1
PUT /orders/<order_id> HTTP/1.1
2
Content-Type: application/json
3
authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
6
7
{
8
"note": "Delivery before 4PM"
9
}
Copied!
1
HTTP/1.1 200 OK
2
Content-type: application/json
3
4
{
5
"user": {
6
"$oid": "5a2fd321ca79e20013ffc7bc"
7
},
8
"delivery_status": "PENDING",
9
"note": "Delivery before 4PM",
10
"created": {
11
"$date": 1552311677532
12
},
13
"_id": {
14
"$oid": "5c86657da4e8ad0009430245"
15
},
16
"total_quantity": 4,
17
"modified": {
18
"$date": 1553673658490
19
},
20
"order_status": "CREATED",
21
"top_up_vat": 0.25,
22
"delivery_address": {
23
"street_name": "Christies gate 34A",
24
"country": "Norway",
25
"zip_code": "0557",
26
"alias": "",
27
"service": "google",
28
"city": "Oslo",
29
"geo": [
30
59.9294087,
31
10.7643042
32
]
33
},
34
"total_amount": 40,
35
"billing_address": {
36
"street_name": "Christies gate 34A",
37
"country": "Norway",
38
"zip_code": "0557",
39
"alias": "",
40
"service": "google",
41
"city": "Oslo",
42
"geo": [
43
59.9294087,
44
10.7643042
45
]
46
},
47
"top_up_amount": 0,
48
"deleted": false,
49
"items": [
50
{
51
"product": {"$oid": "5703fce3308714000dea1ff1"},
52
"quantity": 1,
53
"name": "name of the product",
54
"price": 20,
55
"final_price": 10,
56
"discount": 0.5,
57
"vat": 0.0,
58
"currency": "NOK"
59
},
60
{
61
"product": "5703fcde308714000dea1fe8",
62
"quantity": 3,
63
"name": "name of the product",
64
"price": 10,
65
"final_price": 30,
66
"discount": 0.0,
67
"vat": 0.0,
68
"currency": "NOK"
69
}
70
],
71
"units": 2,
72
"company": {
73
"$oid": "59ce1e0a9d3bde0006fa45a9"
74
},
75
"resources": [],
76
"payments": [],
77
"override_company_take": -1,
78
"human_id": "2DX29Y",
79
"currency": "NOK",
80
"accounting_reference": "3533HW7"
81
}
Copied!
Important: Updating the list of items overwrites the current list instead of adding additional items to it.

Retrieve an Order*

Parameters
Request
Response
Path Parameter
Type
Description
order_id
string
ID of the queried order.
1
GET /orders/<order_id> HTTP/1.1
2
Content-Type: application/json
3
authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-type: application/json
3
4
{
5
"units":1,
6
"delivery_status":"ACCEPTED",
7
"currency":"NOK",
8
"human_id":"51Q4LN",
9
"payments":[],
10
"modified":{"$date":1495196003948},
11
"top_up_amount":0.0,
12
"order_status":"CREATED",
13
"company":{"$oid":"591ee15db70e2a10acb65362"},
14
"billing_address":{
15
"city":"Danielsen",
16
"service":"google",
17
"alias":"",
18
"country":"Paraguay",
19
"zip_code":"0556",
20
"state":"Oslo",
21
"street_name":"Iversenstien 7"
22
},
23
"deliveries":[],
24
"resources": [],
25
"items":[
26
{
27
"quantity":60,
28
"product": {"$oid": "5a2948b0d57ba22d228b1767"},
29
"name": "name of the product",
30
"price": 20,
31
"final_price": 120,
32
"discount": 0.0,
33
"vat": 0.0,
34
"currency": "NOK"
35
}
36
],
37
"note":"",
38
"created":{"$date":1495264401233},
39
"delivery_address":{
40
"city":"Danielsen",
41
"service":"google",
42
"alias":"",
43
"country":"Paraguay",
44
"zip_code":"0556",
45
"state":"Oslo",
46
"street_name":"Iversenstien 7"
47
},
48
"total_quantity":60,
49
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
50
"total_amount":1200.0,
51
"override_company_take":-1.0,
52
"user":{...},
53
"delivery_time":{"$date":1497009600000}
54
}
Copied!

List all Orders*

Retrieves a list of all Orders associated with the current user (or all users if called from an Admin Role). It is also possible to filter the search using pagination.
Parameters
Request
Response
Query Parameters
Type
Description
from_date
number
Start date, timestamp format. Default is None.
to_date
number
End date, timestamp format. Default is None.
date_filter
string
Date field used to filter results. Default is CREATED.
size
number
Number of items to retrieve. Default is 10.
page
number
Which page to retrieve. Default is 0.
order_status
string
Return orders with a specific order status.
delivery_status
string
Return orders with a specific delivery status.
sort
string
Field used for sorting results.
1
GET /orders HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
[
5
{
6
"units":1,
7
"delivery_status":"ACCEPTED",
8
"currency":"NOK",
9
"human_id":"51Q4LN",
10
"payments":[],
11
"modified":{"$date":1495196003948},
12
"top_up_amount":0.0,
13
"order_status":"CREATED",
14
"company":{"$oid":"591ee15db70e2a10acb65362"},
15
"billing_address":{
16
"city":"Danielsen",
17
"service":"google",
18
"alias":"",
19
"country":"Paraguay",
20
"zip_code":"0556",
21
"state":"Oslo",
22
"street_name":"Iversenstien 7"
23
},
24
"deliveries":[],
25
"resources": [],
26
"items":[
27
{
28
"quantity":60,
29
"product": {"$oid": "5a2948b0d57ba22d228b1767"},
30
"name": "name of the product",
31
"price": 20,
32
"final_price": 120,
33
"discount": 0.0,
34
"vat": 0.0,
35
"currency": "NOK"
36
}
37
],
38
"note":"",
39
"created":{"$date":1495264401233},
40
"delivery_address":{
41
"city":"Danielsen",
42
"service":"google",
43
"alias":"",
44
"country":"Paraguay",
45
"zip_code":"0556",
46
"state":"Oslo",
47
"street_name":"Iversenstien 7"
48
},
49
"total_quantity":60,
50
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
51
"total_amount":1200.0,
52
"override_company_take":-1.0,
53
"user":{...},
54
"delivery_time":{"$date":1497009600000}
55
}
56
]
Copied!

Search Orders*

Retrieves a list of all Orders associated with the search parameters for the current user. It is possible to search for _id or human_id associated with the current user's orders.
Parameters
Request
Response
Query Parameters
Type
Description
query
string
The search query. One of human_id, user name or id
from_date
number
Start date, timestamp format. Default is None.
to_date
number
End date, timestamp format. Default is None.
date_filter
string
Date field used to filter results. Default is CREATED.
size
number
Number of items to retrieve. Default is 10.
page
number
Which page to retrieve. Default is 0.
order_status
string
Return orders with a specific order status.
delivery_status
string
Return orders with a specific delivery status.
sort
string
Field used for sorting results.
1
GET /orders/search?query=51Q4LN HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
[
5
{
6
"units":1,
7
"delivery_status":"ACCEPTED",
8
"currency":"NOK",
9
"human_id":"51Q4LN",
10
"payments":[],
11
"modified":{"$date":1495196003948},
12
"top_up_amount":0.0,
13
"order_status":"CREATED",
14
"company":{"$oid":"591ee15db70e2a10acb65362"},
15
"billing_address":{
16
"city":"Danielsen",
17
"service":"google",
18
"alias":"",
19
"country":"Paraguay",
20
"zip_code":"0556",
21
"state":"Oslo",
22
"street_name":"Iversenstien 7"
23
},
24
"deliveries":[],
25
"resources": [],
26
"items":[
27
{
28
"quantity":60,
29
"product": {"$oid": "5a2948b0d57ba22d228b1767"},
30
"name": "name of the product",
31
"price": 20,
32
"final_price": 120,
33
"discount": 0.0,
34
"vat": 0.0,
35
"currency": "NOK"
36
}
37
],
38
"note":"",
39
"created":{"$date":1495264401233},
40
"delivery_address":{
41
"city":"Danielsen",
42
"service":"google",
43
"alias":"",
44
"country":"Paraguay",
45
"zip_code":"0556",
46
"state":"Oslo",
47
"street_name":"Iversenstien 7"
48
},
49
"total_quantity":60,
50
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
51
"total_amount":1200.0,
52
"override_company_take":-1.0,
53
"user":{...},
54
"delivery_time":{"$date":1497009600000}
55
}
56
]
Copied!

Cancel an Order*

Orders that haven't been completed or delivered can be cancelled.
Parameters
Request
Response
Path Parameter
Type
Description
order_id
string
ID of the queried order.
1
POST /orders/<order_id>/cancel HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
Copied!
1
HTTP/1.1 200 OK
2
Content-type: application/json
3
4
{
5
"units":1,
6
"delivery_status":"ACCEPTED",
7
"currency":"NOK",
8
"human_id":"51Q4LN",
9
"payments":[],
10
"modified":{"$date":1495196003948},
11
"top_up_amount":0.0,
12
"order_status":"CANCELED",
13
"company":{"$oid":"591ee15db70e2a10acb65362"},
14
"billing_address":{
15
"city":"Danielsen",
16
"service":"google",
17
"alias":"",
18
"country":"Paraguay",
19
"zip_code":"0556",
20
"state":"Oslo",
21
"street_name":"Iversenstien 7"
22
},
23
"deliveries":[],
24
"resources": [],
25
"items":[
26
{
27
"quantity":60,
28
"product": {"$oid": "5a2948b0d57ba22d228b1767"},
29
"name": "name of the product",
30
"price": 20,
31
"final_price": 120,
32
"discount": 0.0,
33
"vat": 0.0,
34
"currency": "NOK"
35
}
36
],
37
"note":"",
38
"created":{"$date":1495264401233},
39
"delivery_address":{
40
"city":"Danielsen",
41
"service":"google",
42
"alias":"",
43
"country":"Paraguay",
44
"zip_code":"0556",
45
"state":"Oslo",
46
"street_name":"Iversenstien 7"
47
},
48
"total_quantity":60,
49
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
50
"total_amount":1200.0,
51
"override_company_take":-1.0,
52
"user":{...},
53
"delivery_time":{"$date":1497009600000}
54
}
Copied!

Admin Role

*Paths listed above and denoted with a star are accessible to both Users and Admins. Additional Admin Role paths are listed below.

Create an Order

In order to create a new Standard Order or Recurring Order as an Admin you must specify the User. This means that user is required field.
Parameters
Request
Response
Body Parameters
Type
Description
user
string
ID of the User associated with the order.
delivery_address
object
Address used for delivery.
billing_address
object
Address used for billing purposes
pickup_address
object
Addressused to pickup a package.
delivery_status
string
See delivery statuses. Default is PENDING
delivery_time
int
Expected arrival time for delivery, timestampformat.
pickup_time
int
Expected arrival time for pickup, timestampformat.
items
string
List of Items associated with an order.
note
string
Note field.
resources
array
The Resources in the order.
subscription
string
Associated Subscription referenced by a Subscription ID
coupon
string
A Coupon ID or code
1
POST /orders HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer <service-account-key>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
6
7
{
8
"user": "57ee9c72d76d431f85111432",
9
"items": [
10
{
11
"product": "5703fce3308714000dea1ff1",
12
"quantity": 1
13
},
14
{
15
"product": "5703fcde308714000dea1fe8",
16
"quantity": 3
17
}
18
],
19
"delivery_time": 1472022000000,
20
"delivery_address": {
21
"city": "Oslo",
22
"geo": [
23
59.9294087,
24
10.7643042
25
],
26
"zip_code": "0557",
27
"street_name": "Christies gate 34A",
28
"country": "Norway"
29
},
30
"billing_address": {
31
"city": "Oslo",
32
"geo": [
33
59.9294087,
34
10.7643042
35
],
36
"zip_code": "0557",
37
"street_name": "Christies gate 34A",
38
"country": "Norway"
39
},
40
"note": "some type of note"
41
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"created": {"$date": 1488475795244},
6
"company": {"$oid": "586faf7445ed910006373513"},
7
"delivery_address": {
8
"city": "Oslo",
9
"geo": [
10
59.9294087,