Search…
Resources
We break a Resource into two concepts; a resource as a reusable asset and a retail resource that is meant to be sold.
If not specified, an asset resource is created.
Changes since API version2019-02-01

2019-09-18 - `image` type changed to Object

image changed to Image Object.

2019-09-02 - `image_url` Deprecated

We are deprecating the old image_urland replacing it with Image Object.

Asset Resource Object

Attribute
Type
Description
method
string
The resource type. asset or retail.
user
object
User associated with the resource.
name
string
Name of the resource item.
description
string
Description of the resource item.
image
object
Imageobject for this resource.
product
object
Product associated with the resource.
tags
array
An array of tags.
human_id
string
6 character ID.
status
string
Status of the resource. Default is CREATED, other options are listed below.

Retail Resource Object

In addition to the attributes in the asset resource, the retailresource has the following attributes.
Attribute
Type
Description
_sub_products
array
An array with sub-products associated with the resource.
base_price
number
The sum of the product.price and price in all the _sub_products.
retail_price
number
The amount that this resource is sold for.
currency
string
The currency in the main product in the resource.
vat
number
The VAT from the main product in the resource. A decimal value between 0 and 1, e.g. 0.25 = 25%.

Resource Status

Default status for the resource is CREATED. Change the status by updating the resource.
Status
CREATED
PROCESSING
UTILIZED
IDLE
ON_THE_WAY_FROM
ON_THE_WAY_TO
DONE

User Role

Create a new Resource*

Parameters
HTTP
Core SDK / Node SDK
Body Parameters
Type
Description
name
string
Name of the resource item.
product
string
Product ID to be associated with the resource.
description
string
Description of the resource item.
status
string
Status of the resource, default is CREATED other options are PROCESSING, UTILIZED, IDLE.
image
string
Image ID for this resource.
reference_id
string
Customizable ID for the resource
Request --
1
POST /resources 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
"name": "Electric Scooter W3E7IB",
9
"description": "Rent this electric scooter"
10
}
Copied!
Response --
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {"$oid": "596c643ed57ba203be2cf1c9"},
6
"method" "asset",
7
"name": "Electric Scooter W3E7IB",
8
"description": "Rent this electric scooter",
9
[...]
10
}
Copied!
1
builton.resources.create({
2
name: 'Electric Scooter W3E7IB',
3
description: 'Rent this electric scooter',
4
}).then(console.log);
5
6
/*
7
Resource {
8
id: '596c643ed57ba203be2cf1c9',
9
method: 'asset',
10
name: 'Electric Scooter W3E7IB',
11
description: 'Rent this electric scooter',
12
[...]
13
}
14
*/
Copied!

Update a Resource*

Parameters
HTTP
Core SDK / Node SDK
Path Parameter
Type
Description
resource_id
string
The resource’s ID
Body Parameters
Type
Description
name
string
Name of the resource item.
description
string
Description of the resource item.
user
string
User ID to be associated with a user.
status
string
Status of the resource. Default is CREATED; other options are PROCESSING, UTILIZED or IDLE.
product
string
Product ID to be associated with the resource.
image
string
Image object for this resource.
reference_id
string
Customizable ID for the resource.
Request --
1
PUT /resources/596c643ed57ba203be2cf1c9 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": "Electric Scooter Q2EW6UV",
9
}
Copied!
Response --
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {"$oid": "596c643ed57ba203be2cf1c9"},
6
"method" "asset",
7
"name": "Electric Scooter Q2EW6UV",
8
"description": "Rent this electric scooter",
9
[...]
10
}
Copied!
1
builton.resources.update('596c643ed57ba203be2cf1c9', {
2
name: 'Electric Scooter Q2EW6UV',
3
}).then(console.log);
4
5
/*
6
Resource {
7
id: '596c643ed57ba203be2cf1c9',
8
method: 'asset',
9
name: 'Electric Scooter Q2EW6UV',
10
description: 'Rent this electric scooter',
11
[...]
12
}
13
*/
Copied!

Retrieve a Resource by ID*

Parameters
HTTP
Core SDK / Node SDK
Path Parameter
Type
Description
resource_id
string
The resource’s ID.
Request --
1
GET /resources/596c643ed57ba203be2cf1c9 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!
Response --
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {"$oid": "596c643ed57ba203be2cf1c9"},
6
"method" "asset",
7
"name": "Electric Scooter Q2EW6UV",
8
"description": "Rent this electric scooter",
9
"product": {"$oid": "58f9f856b70e2a56c4a0db3d"},
10
"image": {"$oid": "596c643ed57ba203be2cf2c9"},
11
[...]
12
}
Copied!
1
builton.resources.get('596c643ed57ba203be2cf1c9').then(console.log);
2
3
/*
4
Resource {
5
id: '596c643ed57ba203be2cf1c9',
6
method: 'asset',
7
name: 'Electric Scooter Q2EW6UV',
8
description: 'Rent this electric scooter',
9
[...]
10
}
11
*/
Copied!

List All Resources*

Parameters
HTTP
Core SDK / Node SDK
Query Parameters
Type
Description
include_deleted
boolean
If true, the request also returns deleted resources.
size
number
Number of resources per page. Default is 10.
page
number
Defines which page to retrieve. Default is 0.
from_date
number
Start date, timestamp format. Default is None.
to_date
number
End date, timestamp format. Default is None.
sort
string
Field used to sort results. Default is -created.
status
string
Status of the resource. Default is CREATED; other options are PROCESSING, UTILIZED or IDLE
Request --
1
GET /resources 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!
Response --
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
[
5
{
6
"_id": {"$oid": "596c643ed57ba203be2cf1c9"},
7
"method" "asset",
8
"name": "Electric Scooter Q2EW6UV",
9
"description": "Rent this electric scooter",
10
"product": {"$oid": "58f9f856b70e2a56c4a0db3d"},
11
"image": {"$oid": "596c643ed57ba203be2cf2c9"},
12
[...]
13
},
14
[...]
15
]
Copied!
1
builton.resources.get().then(page => {
2
console.log(page.current); // First page
3
});
4
5
/*
6
[
7
Resource {
8
id: '596c643ed57ba203be2cf1c9',
9
method: 'asset',
10
name: 'Electric Scooter Q2EW6UV',
11
description: 'Rent this electric scooter',
12
[...]
13
},
14
[...]
15
]
16
*/
Copied!

Search Resources by Keywords*

Search by _id, name, reference_id, description and image_url. Returns an array that matches the query. Filter the query by using pagination.
Parameters
HTTP
Core SDK / Node SDK
Query Parameters
Type
Description
query
string
Partial or full string of name, reference_id, description or image_url.
include_deleted
boolean
If true, the request also returns deleted resources.
size
number
Number of resources per page. Default is 10.
page
number
Defines which page to retrieve. Default is 0.
from_date
number
Start date, timestamp format. Default is None.
to_date
number
End date, timestamp format. Default is None.
sort
string
Field used to sort results. Default is created.
Request --
1
GET /resources/search?query=electric 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!
Response --
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
[
5
{
6
"_id": {"$oid": "596c643ed57ba203be2cf1c9"},
7
"method" "asset",
8
"name": "Electric Scooter Q2EW6UV",
9
"description": "Rent this electric scooter",
10
"product": {"$oid": "58f9f856b70e2a56c4a0db3d"},
11
"image": {"$oid": "596c643ed57ba203be2cf2c9"},
12
[...]
13
},
14
[...]
15
]
Copied!
1
builton.resources.get().then(page => {
2
console.log(page.current); // First page
3
});
4
5
/*
6
[
7
Resource {
8
id: '596c643ed57ba203be2cf1c9',
9
method: 'asset',
10
name: 'Electric Scooter Q2EW6UV',
11
description: 'Rent this electric scooter',
12
[...]
13
},
14
[...]
15
]
16
*/
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 new Resources in Bulk

Parameters
HTTP
Body Parameters
Type
Description
name
string
Name of the resource item.
description
string
Description of the resource item.
user
string
User ID to be associated with a User.
status
string
Status of the resource _default is CREATED other options are PROCESSING, UTILIZED, IDLE
product
string
Product ID to be associated with the resource.
image
string
Image ID for this resource.
reference_id
string
Customizable ID for the resource.
Request --
1
POST /resources/bulk 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
{
9
"product": "58f9f856b70e2a56c4a0db3d",
10
"method": "asset",
11
"name": "First resource"
12
},
13
{
14
"product": "58f9f856b70e2a56c4a0db3d",
15
"method": "asset",
16
"name": "Second resource"
17
}
18
]
Copied!
Response --
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
[
5
{
6
"_id": {"$oid": "596c643ed57ba203be2cf1c9"},
7
"product": "58f9f856b70e2a56c4a0db3d",
8
"method" "asset",
9
"name": "First resource",
10
[...]
11
},
12
{
13
"_id": {"$oid": "57ee9c71d76d431f8511142f"},
14
"product": "58f9f856b70e2a56c4a0db3d",
15
"method" "asset",
16
"name": "Second resource",
17
[...]
18
}
19
]
Copied!

Delete a Resource

Parameters
HTTP
Node SDK
Path Parameters
Type
Description
<resource_id>
string
ID of the resource to be deleted.
Request --
1
DELETE /resources/596c643ed57ba203be2cf1c9 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
Copied!
Response --
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"_id": {"$oid": "596c643ed57ba203be2cf1c9"},
6
"method" "asset",
7
"name": "Electric Scooter W3E7IB",
8
"description": "Rent this electric scooter",
9
"deleted": true,
10
}
Copied!
1
builton.resources.del('5e5e7580a66b2a00089308b5').then(console.log);
2
3
/*
4
Resource {
5
id: '596c643ed57ba203be2cf1c9',
6
method: 'asset',
7
name: 'Electric Scooter Q2EW6UV',
8
description: 'Rent this electric scooter',
9
delete: true
10
}
11
*/
Copied!
Last modified 1yr ago