Create a user
POST/users
Base URL: https://api.tinkermode.com
Description
When a project is created on MODE, developer must specify how user accounts should be handled. By default, a project uses the built-in user account system provided by MODE. But a project can also implement its own separate account system for its users. So based on the type of the project, this API call does one of the following.
Project Uses the Built-In Account System (Based on Phone Numbers)
Register a new user. The request body must be a valid user object containing the projectId, phoneNumber and name fields. The phone number must not be in use by a current user of the project. An SMS text containing a verification code will be sent to the user to confirm the registration.
However, if request is made using an Admin User/Project API Key, the user is "pre-verified", and no confirmation text will be sent.
Project Uses the Built-In Account System (Based on Email Addresses)
If used for registering a new user, the request body must be a valid user object containing the projectId, email and name fields. In addition, a password field must also be present. The email address must not be in use by a current user of the project. An email message containing a verification URL will be sent to the user to confirm the registration.
However, if request is made using an Admin User/Project API Key, only the projectId and email fields are required for the request.
An invitation email will be sent to the user, and an "activation token" will be returned. The invitation email should contain an activation link for the user to
activate their account, but in case the user has trouble receiving the email, the caller may share the link with them directly (constructed from the activation token returned).
Project is BYOU ("Bring-Your-Own-Users")
Create an entry in MODE that corresponds to an existing user in the project's own account system. The request object only needs to contain the projectId field. An optional externalKey field can be used to associate the user with an existing unique identifier. The request must also come with an Authorization header that contains a User/Project API Key with the permission to handle BYOU. The returned user object contains a unique user ID. The caller should store this user ID for future MODE API calls.
Authentication
Send an Authorization header of the form ModeCloud <AUTH_CODE>.
The API key of a user who has permission to create users, or a Project API Key with the BYOU or Admin permission is required, if the project is BYOU, or restricts user registration. Otherwise, anyone can register as a user and no Authorization header is need.
Request body
Content type: application/json
| Property | Type | Required | Constraints | Description |
|---|---|---|---|---|
accessControlGroupIds | array<integer> | No | Access Control Groups of the new user. Note This parameter is allowed only if the request is made by a user with permission to create users in the group, or a project API key with "Admin" privileges. | |
email | string | No | Email of the new user. Note Required if the project is configured to have email-based user accounts. | |
externalKey | string | No | An existing unique identity associated with the new user. Note Optional and used only if project is configured to be BYOU. | |
managedExternally | boolean | No | Optional and available when project is configured to use alternative authentication method for users to log in such as via OpenID Connect. This option is used if the project doesn't want users to store passwords in MODE. Users created with this option cannot update or delete user account information (email, password, etc.) themselves. Also, created users are "pre-verified", and no confirmation text/email will be sent. To use this option, the request must be made by a project API key with "Admin" privileges. | |
name | string | No | The name of the new user. | |
password | string | No | Password of the new user. Note Required if the project is configured to have email-based user accounts. | |
phoneNumber | string | No | Phone number of the new user. Note Required if the project is configured to have phone number-based user accounts. | |
projectId | integer | Yes | The unique id for a project. |
Request example
{
"email": "jane@example.com",
"name": "Jane Doe",
"password": "a_secure_password",
"projectId": 1264
}Responses
201 Successfully created the user. The created object is returned in the response body. For an invited user,
an "activation token" is also included in the returned object.
Content type: application/json
| Property | Type | Required | Constraints | Description |
|---|---|---|---|---|
auth2FActivated | boolean | No | read-only (server-generated) | True if user has activated two-factor authentication. |
creationTime | string | No | read-only (server-generated); format: date-time | The time when the user was created. |
email | string | No | read-only (server-generated) | A valid email address. Present if project uses email addresses to uniquely identify users. |
externalKey | string | No | read-only (server-generated) | If present, this is the unique key used in an external system to identify this user. This field is relevant only if project is using BYOU. |
id | integer | Yes | read-only (server-generated) | This is a unique user ID assigned at time of creation. |
managedExternally | boolean | No | read-only (server-generated) | True if user account is managed by an external ID provider such as Microsoft Entra ID. |
name | string | Yes | Display name of the user. | |
password | string | No | A valid password. This is used only when creating or updating a user who logs in by email and password. | |
passwordUpdateTime | string | No | read-only (server-generated); format: date-time | The time when the password was last changed. Present only if user account is based on email/password. |
phoneNumber | string | No | read-only (server-generated); pattern: ^(\+)([0-9]{5,})$ | A valid phone number with country code (beginning with the '+' symbol). Present if project uses phone numbers to uniquely identify users. |
projectId | integer | Yes | read-only (server-generated) | The project ID that this user belongs to. |
verified | boolean | No | read-only (server-generated) | Displays true if the user has verified their account. |
Response example
{
"creationTime": "2019-12-17T02:55:59.483Z",
"email": "jane@example.com",
"id": 2076,
"name": "Jane Doe",
"projectId": 1264,
"verified": true
}401 Authorization is required to access this resource.
Content type: application/json
| Property | Type | Required | Constraints | Description |
|---|---|---|---|---|
data | object | No | read-only (server-generated) | Any relevant data related to error. |
reason | string | Yes | read-only (server-generated) | Reason of error. |
403 Request failed because of invalid data or denied permission.
Content type: application/json
| Property | Type | Required | Constraints | Description |
|---|---|---|---|---|
data | object | No | read-only (server-generated) | Any relevant data related to error. |
reason | string | Yes | read-only (server-generated) | Reason of error. |
429 Request failed because of rate limit.
Content type: application/json
| Property | Type | Required | Constraints | Description |
|---|---|---|---|---|
data | object | No | read-only (server-generated) | Any relevant data related to error. |
reason | string | Yes | read-only (server-generated) | Reason of error. |
500 An unexpected error has occurred.
Content type: application/json
| Property | Type | Required | Constraints | Description |
|---|---|---|---|---|
data | object | No | read-only (server-generated) | Any relevant data related to error. |
reason | string | Yes | read-only (server-generated) | Reason of error. |
503 The service is temporarily unavailable.
Content type: application/json
| Property | Type | Required | Constraints | Description |
|---|---|---|---|---|
data | object | No | read-only (server-generated) | Any relevant data related to error. |
reason | string | Yes | read-only (server-generated) | Reason of error. |