Invite user
Request description
Endpoint: /users/invite-to-organization
Method: POST
Header
{
"Content-Type": "application/json",
"Authorization": "Bearer <accessToken>"
}
Note: the <accessToken> is obtained as a result of the authentication. The authentication flow you have to follow depends on the access mode, see Access modes.
Access modes
This endpoint accepts two kinds of access token, and the request body depends on which one you use:
| Access token | Creates a user in | Identified by |
|---|---|---|
| Platform user | Your platform organization | email |
| Dictation service | Your organization's corporate dictation server | login |
The endpoint, method and headers are identical in both cases. The payload and the possible errors are not.
appId:apiKey) and sent as Basic <token> to the /api/v1/token endpoint. See AI Services — Credentials for the full procedure and code examples.Platform user
Payload
{
"fullName": "mock-full-name",
"email": "mock@mock.com",
"groupId": "group-id",
"userType": "REGULAR"
}
Payload structure
type InviteUserPayloadType = {
fullName: string; // User full name
email: string; // User email. An invitation is sent to this address
groupId?: string; // Group of the user. Must be the id of a group of your organization
userType: UserType; // User role in the organization
};
type UserType = "ORGANIZATION_OWNER" | "ORGANIZATION_ADMIN" | "REGULAR";
Field rules
| Field | Required | Rules |
|---|---|---|
fullName | Yes | Not empty |
email | Yes | Valid email format. Must not belong to a user of your organization already |
groupId | No | Id of a group of your organization (see Group list). If it is omitted or does not belong to your organization, the user is created without a group and Users list returns groupId: "NOT-DEFINED" |
userType | Yes | One of the UserType values. An Organization Admin cannot invite users with the ORGANIZATION_OWNER role |
If the email already has an account on the platform (for example, in another organization), no new user is created: the existing user is added to your organization and the response includes their id.
Dictation user
Creates a user in the corporate dictation server of the organization associated with your credentials. You do not send the organization: it is resolved from your access token.
Payload
{
"login": "jperez",
"password": "mock-password",
"fullName": "Juan Perez",
"email": "jperez@hospital.com",
"specialtyCode": "1",
"organization": "Hospital X"
}
Payload structure
type InviteDictationUserPayloadType = {
login: string; // Unique login in the dictation server
password: string; // Initial password
fullName: string; // User full name
email: string; // User email
specialtyCode: string; // Speciality code (see below)
organization?: string; // Free-text organization label
};
Field rules
| Field | Required | Rules |
|---|---|---|
login | Yes | 1 to 254 characters. Must not already exist |
password | Yes | At least 1 character |
fullName | Yes | Up to 254 characters |
email | Yes | Valid email format, up to 254 characters |
specialtyCode | Yes | Must be a code accepted by your dictation server |
organization | No | Free text. Defaults to empty |
The license type of the created user is assigned automatically and cannot be set through this API. Any additional field sent in the payload is ignored.
About specialtyCode
An unknown speciality code is rejected by the dictation server and returns 502.
Responses
Correct response
Successful request — platform user
Describe the characteristics of a satisfactory response
201
Response structure (new user):
{
// empty response
}
{
"message": "User added to organization successfully",
"id": "mock-user-id"
}
type InviteUserSuccessResponseType = {
message?: string; // Only when an existing user was added to your organization
id?: string; // Only when an existing user was added to your organization
};
Successful request — dictation user
Describe the characteristics of a satisfactory response
201
Response structure:
{
"message": "User created successfully",
"login": "jperez"
}
Wrong responses
Unauthorized request
Describe the characteristics of an unauthorized request
401
Response body
{
"message": "Unauthorized"
}
Description: this error occurs when endpoint authorizers fail to validate the token sent in the request header.
Bad request — platform user
Describe the characteristics of a bad request
400
Response body example
{
"errorType": "invalidRequestFormat",
"errorMessage": "Fullname is required",
"message": "Fullname is required",
"details": [
/* validation detail */
]
}
type InviteUserResponseType = {
errorType: INVITE_USER_ERROR_TYPE;
errorMessage: string;
message?: string; // Present on validation errors
details?: object[]; // Present on validation errors
};
enum INVITE_USER_ERROR_TYPE {
INVALID_REQUEST_FORMAT = "invalidRequestFormat",
EMAIL_ALREADY_EXISTS_IN_ORGANIZATION = "emailAlreadyExistsInOrganization",
}
errorType | errorMessage | Meaning |
|---|---|---|
invalidRequestFormat | Fullname is required | fullName missing or empty |
invalidRequestFormat | Email is required | email missing |
invalidRequestFormat | Format email is invalid | email malformed |
invalidRequestFormat | User type is required | userType missing |
invalidRequestFormat | Invalid user type | userType is not a UserType value |
emailAlreadyExistsInOrganization | Email already exists in the organization | the user already belongs to your organization |
Not found — platform user
Describe the characteristics of a not found request
404
Response body
{
"errorType": "emailDoesNotExist",
"errorMessage": "Email does not exist"
}
Forbidden — platform user
Describe the characteristics of a forbidden request
403
Response body
{
"errorType": "notAllowedResource",
"errorMessage": "Unauthorized",
"message": "Unauthorized"
}
ORGANIZATION_OWNER role. Only an Organization Owner can invite Organization Owners. Users without the Owner or Admin role receive the common 403 response.Bad request — dictation user
Describe the characteristics of a bad request
400
Response body
{
"errorType": "invalidRequestFormat",
"errorMessage": "Login is required",
"message": "Login is required",
"details": [
/* validation detail */
]
}
Description: errorMessage identifies the first field that failed. Possible values:
| Message | Meaning |
|---|---|
Login is required | login missing or empty |
Login is too long | login over 254 characters |
Password is required | password missing or empty |
Fullname is required | fullName missing or empty |
The full name cannot have more than 254 characters | fullName too long |
Email is required | email missing |
Format email is invalid | email malformed |
The email cannot have more than 254 characters | email too long |
Specialty code is required | specialtyCode missing or empty |
{ errorType, errorMessage } and the dictation path answers with { message }. Both error formats coexist in this endpoint.Forbidden — dictation user
Describe the characteristics of a forbidden request
403
Response body
{
"message": "Forbidden"
}
{
"message": "Dictation server rejected the operation"
}
Not found — dictation user
Describe the characteristics of a not found request
404
Response body
{
"message": "Tenant not found"
}
Description: there is no dictation server for your organization in this environment.
Conflict — dictation user
Describe the characteristics of a conflicting request
409
Response body
{
"message": "There is already a user with the same login"
}
Description: that login is already in use. Logins are unique and are not reused.
Dictation server unavailable
Describe the characteristics of an unreachable dictation server
502
Response body
{
"message": "Dictation server unavailable"
}
Description: the dictation server could not complete the request. Also returned when the speciality code is not valid.
Dictation server timeout
Describe the characteristics of a dictation server that does not answer in time
504
Response body
{
"message": "Dictation server did not respond in time"
}
Description: the dictation server did not answer within the allowed time. The user may or may not have been created; check before retrying.