Creates a User
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user: {
email: '<string>',
password: '<string>',
password_confirmation: '<string>',
first_name: '<string>',
last_name: '<string>',
selected_locale: '<string>',
ship_address_id: '<string>',
bill_address_id: '<string>',
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/users', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "136",
"type": "user",
"attributes": {
"email": "rex_champlin@breitenberg.com",
"first_name": "Zenia",
"last_name": "King",
"selected_locale": "pl",
"created_at": "2022-11-08T19:35:54.351Z",
"updated_at": "2022-11-08T19:35:54.351Z",
"public_metadata": {},
"private_metadata": {},
"average_order_value": [],
"lifetime_value": [],
"store_credits": []
},
"relationships": {
"bill_address": {
"data": null
},
"ship_address": {
"data": null
}
}
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Show child attributes
Record created
Show child attributes
Was this page helpful?
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user: {
email: '<string>',
password: '<string>',
password_confirmation: '<string>',
first_name: '<string>',
last_name: '<string>',
selected_locale: '<string>',
ship_address_id: '<string>',
bill_address_id: '<string>',
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/users', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "136",
"type": "user",
"attributes": {
"email": "rex_champlin@breitenberg.com",
"first_name": "Zenia",
"last_name": "King",
"selected_locale": "pl",
"created_at": "2022-11-08T19:35:54.351Z",
"updated_at": "2022-11-08T19:35:54.351Z",
"public_metadata": {},
"private_metadata": {},
"average_order_value": [],
"lifetime_value": [],
"store_credits": []
},
"relationships": {
"bill_address": {
"data": null
},
"ship_address": {
"data": null
}
}
}
}