Invite user


Request description

Endpoint: /users/invite-to-organization
Method: POST

{
  "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 tokenCreates a user inIdentified by
Platform userYour platform organizationemail
Dictation serviceYour organization's corporate dictation serverlogin

The endpoint, method and headers are identical in both cases. The payload and the possible errors are not.

How to get the dictation service token: the dictation path does not use the token returned by User login. Its access token is generated exactly the same way as the AI Services access tokens: with your APP Id and API Key encoded in base64 (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

FieldRequiredRules
fullNameYesNot empty
emailYesValid email format. Must not belong to a user of your organization already
groupIdNoId 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"
userTypeYesOne 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

FieldRequiredRules
loginYes1 to 254 characters. Must not already exist
passwordYesAt least 1 character
fullNameYesUp to 254 characters
emailYesValid email format, up to 254 characters
specialtyCodeYesMust be a code accepted by your dictation server
organizationNoFree 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

The speciality code is defined in the configuration of your dictation server, so the accepted values depend on your installation. Ask your Invox Medical contact for the list of codes available in your environment. The value is always sent as a string.

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
}
Response structure (the email already had an account on the platform):
{
  "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
};
Description: a new user receives an invitation email to set their password.


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 */
  ]
}
Response body
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",
}
Description:
errorTypeerrorMessageMeaning
invalidRequestFormatFullname is requiredfullName missing or empty
invalidRequestFormatEmail is requiredemail missing
invalidRequestFormatFormat email is invalidemail malformed
invalidRequestFormatUser type is requireduserType missing
invalidRequestFormatInvalid user typeuserType is not a UserType value
emailAlreadyExistsInOrganizationEmail already exists in the organizationthe 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"
}
Description: the invitation could not be created for that email and there is no existing platform user with it. Check the email and try again.


Forbidden — platform user

Describe the characteristics of a forbidden request

403

Response body

{
  "errorType": "notAllowedResource",
  "errorMessage": "Unauthorized",
  "message": "Unauthorized"
}
Description: an Organization Admin tried to invite a user with the 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:

MessageMeaning
Login is requiredlogin missing or empty
Login is too longlogin over 254 characters
Password is requiredpassword missing or empty
Fullname is requiredfullName missing or empty
The full name cannot have more than 254 charactersfullName too long
Email is requiredemail missing
Format email is invalidemail malformed
The email cannot have more than 254 charactersemail too long
Specialty code is requiredspecialtyCode missing or empty
The platform path answers with { 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"
}
Description: your credentials are not allowed to manage dictation users.Response body
{
  "message": "Dictation server rejected the operation"
}
Description: the dictation server refused the request. Usually a licensing limit.


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.