Search…
Templates and Attributes
Now you can extend our existing models with attributes that match your specific business logic.
Templates and Attributes are still in beta. Please use them with caution. Currently, Templates can only use the Product model, but we'll be releasing it for Resources, Users, Coupons, Orders, Payments, Subscriptions and Plans.

Template Object

Templates let you create the attributes you need for your specific use case. Create a Template of a Product and give it any attributes you need that aren't included in the existing, default Product Object list of attributes.
Attributes
Type
Description
name
string
The name of the template.
model
string
The model this template is going to use. Current choices:Product
attributes
array
Definitions of the attributes you want to add.

Attribute Definitions

Attributes
Type
Description
key
string
The name of the attribute.
kind
string
The type of attribute. Choices:string, url,email,int,float,boolean
human_id
string
Read only, human readable id for each attribute you create.

Create a Template

Parameters
Request
Response
Body Parameters
Type
Description
name
string
The name of the template.
model
string
The model this template is going to use.
attributes
array
Definitions of the attributes you want to add.
1
POST /templates 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
"name": "Android Phone",
9
"model": "Product",
10
"attributes": [
11
{
12
"key": "RAM_size",
13
"kind": "int"
14
},{
15
"key": "OS_version",
16
"kind": "string"
17
},{
18
"key": "dual_SIM",
19
"kind": "boolean"
20
}
21
]
22
}
Copied!
1
HTTP/1.1 200 OK
2
Content-type: application/json
3
4
{
5
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
6
"name": "Android Phone",
7
"model": "Product",
8
"attributes": [
9
{
10
"key": "RAM_size",
11
"kind": "int",
12
"human_id": "3DR29S"
13
},{
14
"key": "OS_version",
15
"kind": "string",
16
"human_id": "TY13PR"
17
},{
18
"key": "dual_SIM",
19
"kind": "boolean",
20
"human_id": "5O9P3C"
21
}
22
]
23
}
Copied!
While this feature is in beta, we only support 1 Template per model.

Update a Template*

Parameters
Request
Response
Path Parameter
Type
Description
template_id
string
ID of the queried order.
Body Parameters
Type
Description
name
string
The name of the template.
model
string
Which model is going to use this template.
attributes
array
Definitions of the attributes you want to add.
1
PUT /templates/591ee163b70e2a10acb653a7 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
"name": "My new name for Android Phone Template",
9
"attributes": [
10
{
11
"key": "RAM_size",
12
"kind": "int",
13
"human_id": "3DR29S"
14
},{
15
"key": "OS_version",
16
"kind": "string",
17
"human_id": "TY13PR"
18
},{
19
"key": "dual_SIM",
20
"kind": "boolean",
21
"human_id": "5O9P3C"
22
},{
23
"key": "phone_screen",
24
"kind": "float"
25
}
26
]
27
}
Copied!
1
HTTP/1.1 200 OK
2
Content-type: application/json
3
4
{
5
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
6
"name": "My new name for Android Phone Template",
7
"model": "Product",
8
"attributes": [
9
{
10
"key": "RAM_size",
11
"kind": "int",
12
"human_id": "3DR29S"
13
},{
14
"key": "OS_version",
15
"kind": "string",
16
"human_id": "TY13PR"
17
},{
18
"key": "dual_SIM",
19
"kind": "boolean",
20
"human_id": "5O9P3C"
21
},{
22
"key": "phone_screen",
23
"kind": "float"
24
}
25
]
26
}
Copied!
There are some restrictions on updating the templates.
    You can edit the name of the template.
    You can add more attributes to the template.
    You can not change the model of the template.
    You can not remove attributes from the template.
    You can not edit an attribute's key or kindin the template.
    When updating a template, you need to send existing attributes with their human_id .

List all Templates

Parameters
Request
Response
Query Parameters
Type
Description
size
number
Number of items to retrieve.
page
number
Which page to retrieve. Default is 10.
sort
string
Field used for sorting results. Default is created.
from_date
number
Start date, timestamp format. Default is current date minus 15 days.
to_date
number
End date, timestamp format. Default is current date plus 15 days.
date_filter
string
Date field used to filter results. Default is created.
1
GET /templates 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
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
7
"name": "Android Phone",
8
"model": "Product",
9
"attributes": [
10
{
11
"key": "RAM_size",
12
"kind": "int",
13
"human_id": "3DR29S"
14
},{
15
"key": "OS_version",
16
"kind": "string",
17
"human_id": "TY13PR"
18
},{
19
"key": "dual_SIM",
20
"kind": "boolean",
21
"human_id": "5O9P3C"
22
}
23
]
24
}
25
]
Copied!

Delete a Template

Parameters
Request
Response
Path Parameter
Type
Description
template_id
string
ID of the queried order.
1
DELETE /templates/591ee163b70e2a10acb653a7 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
"_id":{"$oid":"591ee163b70e2a10acb653a7"},
6
"name": "Android Phone",
7
"model": "Product",
8
"attributes": [
9
{
10
"key": "RAM_size",
11
"kind": "int",
12
"human_id": "3DR29S"
13
},{
14
"key": "OS_version",
15
"kind": "string",
16
"human_id": "TY13PR"
17
},{
18
"key": "dual_SIM",
19
"kind": "boolean",
20
"human_id": "5O9P3C"
21
}
22
],
23
"deleted":true
24
}
Copied!
When you delete a template, all the related attributes will be deleted from all instances of that model.

How to use Attributes

This is very easy! You can add, update or remove attributes via your POSTor PUT request's body.
Request
Response
1
POST /products 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
"description": "It is a test product",
9
"currency": "NOK",
10
"price": 3.14,
11
"name": "Product Name",
12
"vat": 0.15,
13
"external_reference": "123456abcd"
14
15
"attributes": {
16
"RAM_size": 6,
17
"OS_version": "7.1.0",
18
"dual_SIM": false
19
}
20
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {"$oid": "5c7fc967383117000d193a91"},
6
"max_distance":0,
7
"created":{
8
"$date":1492777046366
9
},
10
"default_position":[-1, -1],
11
"_cls":"Product",
12
"description":"",
13
"modified":{
14
"$date":1492777046369
15
},
16
"_sub_products":[],
17
"name":"Product Name",
18
"properties":{},
19
"price":3.14,
20
"active":false,
21
"tags":[],
22
"vat": 0.15,
23
"company":{"$oid":"57ee9c71d76d431f8511142f"},
24
"deleted":false,
25
"company_take":-1.0,
26
"parents":[],
27
"main_product":true,
28
"currency":"NOK",
29
"path":"/",
30
"external_reference": "123456abcd",
31
32
"attributes": {
33
"RAM_size": 6,
34
"OS_version": "7.1.0",
35
"dual_SIM": false
36
}
37
}
Copied!
Last modified 1yr ago