The User Object holds all the usual info you'd expect, name, phone number, address, etc. You can also add tags to users, which can be used to search, and come in handy when you get into our ML tools.
Human readable ID that identifies the order easily, e.g. 3AG7UA.
image
object
Image object for this user.
User Role
Changes since API version 2019-02-01
2020-02-13 - Create a User - New route
The route/v2/usersis now deprecated: to create a user you must use/users.
Create a User*
And on the 6th day, you can make pancakes and watch cartoons, cuz creating new users is super easy. Just use POST /users.
We use the JWT in the header to identify a User. According to the JWT specs, the subclaim is the identifier of the subject, i.e. the user. So, whenever you send us a JWT, we extract the subvalue and use that as the user ID.
See Authentication for how to get a JWT. With the route POST /users, you could both create a new user with a JWT and login a user with their JWT.
POST /users HTTP/1.1Content-Type:application/jsonAuthorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibGFzdF9uYW1lIjoiRG9lIiwiZmlyc3RfbmFtZSI6IkpvaG4iLCJpYXQiOjE1MTYyMzkwMjJ9.YEqWlNmcheENbeSTjXhA-LMfULwa7t_Ab71tDmLGUxAX-Builton-Api-Key:<builton-api-key>Host:api.builton.dev{"first_name":"Jone","last_name":"Doe","email":"jane@email.com"}
builton.users.get('me').then(console.log);// OR, if you already have a user stored in a variable:builton.users.setMe().get().then(console.log);/*User { id: '5a25250cd57ba213edcba515', first_name: Jane, last_name: Doe, email: jane@email.com, [...]*/
To retrieve, update, or delete your currently logged-in user, you can replace the user id in the query parameter with me.
Update a User
Path Parameter
Type
Description
<user_id>
string
User ID
Body Parameters
Type
Description
first_name
string
First name of the user.
last_name
string
Last name of the user.
salutation
string
Title of the user.
email
string
E-mail of the user.
mobile_phone_number
string
Phone number of the user.
default_payment_method
string
Default payment method of the user.
addresses
array
An arrayof Addressesassociated with the user.
billing_address
object
Address used for billing purposes.
bio
string
Biographical note about the user.
tags
array
List of tags associated with the user.
note
string
Additional notes regarding the user.
Request --
PUT /users/me HTTP/1.1Content-Type:application/jsonAuthorization:Bearer <jwt>X-Builton-Api-Key:<builton-api-key>Host:api.builton.dev{"first_name":"Oliver"}
*Paths listed above and denoted with a star are accessible to both Users and Admins. Additional Admin Role paths are listed below.
Retrieve a User
Path Parameter
Type
Description
<user_id>
string
User ID
Request --
GET /users/5a25250cd57ba213edcba515 HTTP/1.1Content-Type:application/jsonAuthorization:Bearer <service-account-key>X-Builton-Api-Key:<builton-api-key>Host:api.builton.dev
PUT /users/5a25250cd57ba213edcba515 HTTP/1.1Content-Type:application/jsonAuthorization:Bearer <service-account-key>X-Builton-Api-Key:<builton-api-key>Host:api.builton.dev{"first_name":"Oliver"}
builton.users.update('5a25250cd57ba213edcba515', { first_name:"Oliver"});// OR, if you already have a user stored in a variable:user.update({ first_name:'Oliver'}).then(console.log);/*User { id: '5a25250cd57ba213edcba515', first_name: Oliver, last_name: Doe, email: jane@email.com, [...]*/
Update a User's Addresses
Path Parameter
Type
Description
<user_id>
string
User ID
Body Parameters
Type
Description
addresses
array
An arrayof Addressesassociated with the user.
Request --
PUT /users/5a25250cd57ba213edcba515/addresses HTTP/1.1Content-Type:application/jsonAuthorization:Bearer <service-account-key>X-Builton-Api-Key:<builton-api-key>Host:api.builton.dev[ {"city":"Oslo","service":"google","alias":"","country":"Norway","zip_code":"0182","street_name":"Hausmanns gate 29" }]
builton.users.update('5a25250cd57ba213edcba515', { addresses: [{"street_name":"Nadderudåsen 30","city":"Bekkestua","zip_code":"1357","country":"Norway" }]});// OR, if you already have a user stored in a variable:user.update({ addresses: [{"street_name":"Nadderudåsen 30","city":"Bekkestua","zip_code":"1357","country":"Norway" }]});
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.
order_status
string
Orders with a specific status are also listed. Values can be separated by a comma, e.g., success, processing.
delivery_status
string
Orders with a specific delivery status are also listed. Values can be separated by a comma, e.g., assigned, done, created.
Request --
GET /users/5a25250cd57ba213edcba515/orders HTTP/1.1Content-Type:application/jsonAuthorization:Bearer <service-account-key>X-Builton-Api-Key:<builton-api-key>Host:api.builton.dev
builton.users.set('5a25250cd57ba213edcba515').getOrders().then(page => {console.log(page.current); // First page });/*[ Order { id: '5c815f19ce39da0008e83eae', total_amount: 42, items: [...] [...] }, [...]]*/
List All Payment Methods for a User
Path Parameters
Type
Description
<user_id>
string
User ID
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.
Request --
GET /users/5a25250cd57ba213edcba515/payment_methods HTTP/1.1 Content-Type:application/jsonAuthorization:Bearer <jwt>X-Builton-Api-Key:<builton-api-key>Host:api.builton.dev
If true, the request also returns all deleted subscriptions.
size
number
Number of subscriptions per page. Default is 10.
page
number
Which page to retrieve. Default is 0.
sort
string
Field used to sort results. Default is -modified.
status
string
The subscription status Default is ACTIVE.
Request --
GET /users/5a25250cd57ba213edcba515/subscriptions HTTP/1.1Content-Type:application/jsonAuthorization:Bearer <jwt>X-Builton-Api-Key:<builton-api-key>Host:api.builton.dev