Create a User
Create a new user by providing an email address and password. Email addresses must be unique within a database. You may provide an optional preferredName
for the user.
Create User Request
cURL
POST- /workspaces/:workspaceSlug/databases/:databaseName/users
curl 'https://api.thenile.dev/workspaces/<string>/databases/<string>/users' \
--data-raw '{
"email": "<string>",
"password": "<string>",
"preferredName": "<string>"
}'
The response includes the user id and an access token for the user. The access token can be used to perform API operations on the user's behalf.
Response
201
{
"id": "018b6216-27a1-7e2b-aa83-67d7ba500982",
"tenants": [],
"token": {
"jwt": "eyEhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3RoZW5pbGUuZGV2IiwiYXVkIjpbImRhdGFiYXNlOjAxOGI2MWJjLWNmMmMtNzM5Mi05MmE2LWYxYTgxMWNmNDQxOSIsIm5pbGUiXSwiaWF0IjoxNjk4MTU3NzAxLCJleHAiOjE2OTgxNjEzMDEsInN1YiI6IjAxOGI2MjE2LTI3YTEtN2UyYi1hYTgzLTY3ZDdiYTUwMDk4MiIsImp0aSI6ImM1OGU0MjExLTJkMTItNDEwZS05MDYwLTRhYjUyYmYxOGQ4MiIsIm5hbWUiOiJwc2NrYXVnaHQiLCJlbWFpbCI6InNjb3R0aWN1c0Btc24uY29tIiwic2NvcGUiOiJkYXNoYm9hcmQifQ.XrdLCZX7VxpTtaKx-Ho2sAB2thOTr2bOo8PzxvjnfdmT9KdBVWBtullOmrUcz18Txo_8S960JxPo4LWYdYw91pdLJ2PNcuFNEFiRLQFmkpOH7v7TjJ6cdm9pniE8aOGkWJpjAMuLg767vEFJIsoRRFPR9v30dN0Sh0OgDpUIYWn6ngW16Y6OhpiNPHveQ-And4vAlS3-cc0sI_uDMyEke_BoZ-8mKXCB3JqtZrmcAXqYeiubxdd8WdEEDCSrwE9Tr9sUkQORV-O6CsIvKxBKx32KaFiFWs5izjqityvKOvGpNF-h3dAsVVK1Y0GgDmgWHu0TWi6ctdH2wGtkMMeNFw",
"maxAge": 3600,
"type": "ACCESS_TOKEN"
}
}
You can also create a user and a new tenant for that user in a single request by specifying the newTenant
attribute.
Create User with Tenant Request
cURL
POST- /workspaces/:workspaceSlug/databases/:databaseName/users
curl 'https://api.thenile.dev/workspaces/<string>/databases/<string>/users' \
--data-raw '{
"email": "<string>",
"password": "<string>",
"preferredName": "<string>",
"newTenant": "<string>"
}'
The response includes the user id and an access token, and the tenants
array includes the id of the new tenant.
Create User with Tenant Response
201
{
"id": "018b6216-27a1-7e2b-aa83-67d7ba500982",
"tenants": [
"018b61ec-af9e-77e5-b27f-77239cd4a0bc"
],
"token": {
"jwt": "eyEhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3RoZW5pbGUuZGV2IiwiYXVkIjpbImRhdGFiYXNlOjAxOGI2MWJjLWNmMmMtNzM5Mi05MmE2LWYxYTgxMWNmNDQxOSIsIm5pbGUiXSwiaWF0IjoxNjk4MTU3NzAxLCJleHAiOjE2OTgxNjEzMDEsInN1YiI6IjAxOGI2MjE2LTI3YTEtN2UyYi1hYTgzLTY3ZDdiYTUwMDk4MiIsImp0aSI6ImM1OGU0MjExLTJkMTItNDEwZS05MDYwLTRhYjUyYmYxOGQ4MiIsIm5hbWUiOiJwc2NrYXVnaHQiLCJlbWFpbCI6InNjb3R0aWN1c0Btc24uY29tIiwic2NvcGUiOiJkYXNoYm9hcmQifQ.XrdLCZX7VxpTtaKx-Ho2sAB2thOTr2bOo8PzxvjnfdmT9KdBVWBtullOmrUcz18Txo_8S960JxPo4LWYdYw91pdLJ2PNcuFNEFiRLQFmkpOH7v7TjJ6cdm9pniE8aOGkWJpjAMuLg767vEFJIsoRRFPR9v30dN0Sh0OgDpUIYWn6ngW16Y6OhpiNPHveQ-And4vAlS3-cc0sI_uDMyEke_BoZ-8mKXCB3JqtZrmcAXqYeiubxdd8WdEEDCSrwE9Tr9sUkQORV-O6CsIvKxBKx32KaFiFWs5izjqityvKOvGpNF-h3dAsVVK1Y0GgDmgWHu0TWi6ctdH2wGtkMMeNFw",
"maxAge": 3600,
"type": "ACCESS_TOKEN"
}
}