Skip to content
UneeqUneeqUneeq Docs

Add users to the organization

POST
/external/v1/organization/{organizationID}/users/add
curl --request POST \
--url "$UNEEQ_API_URL/external/v1/organization/$UNEEQ_ORG_ID/users/add" \
--header "Authorization: Bearer $UNEEQ_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"emails": [
"jane.doe@example.com",
"john.smith@example.com"
],
"roles": [
"USER"
],
"silent_add": false
}'

Adds one or more people to the organization by email address and gives each of them the same set of roles. Each email is processed independently, in the order sent, so some can succeed while others fail; the response reports the outcome for every email.

Emails are trimmed and lower-cased before use. A malformed or empty email does not reject the request; it is reported as a failed result for that email.

What happens to each person depends on whether they already have an account:

  • New person: an account is created with status invited, and an invitation email is sent (the invitation expires after 30 days). The invitation link is returned as invitation_url.
  • Existing person who is an active member of another organization: added straight away with status active; no invitation email is sent. If they have no usable sign-in account yet (for example, they have never signed in), they are invited instead: status invited, invitation email sent, and this invitation has no expiry, so the person is never reported as expired. With silent_add true they are added with status active and nothing is sent.
  • Existing person with no active membership elsewhere (for example, previously removed): treated like a new person; a previously deleted account is restored.
  • Already a member of this organization: membership is left as it is (no new invitation) and already_member is true; only the roles are updated.

Roles are set, not added: after the call each person holds exactly the roles in roles in this organization, and any other roles they had here are removed. The UNEEQ_ADMIN role passes validation but can never be granted through the API; requesting it fails each email with role_not_permitted.

With silent_add set to true no invitation email is sent and no invitation link is returned. New people are created with status invited and no invitation expiry; they can sign in once their identity provider or a later invitation lets them.

Unknown fields in the body are ignored. There is no limit on the number of emails, but they are processed one at a time, so large batches take proportionally longer.

organizationID
required
string

ID of the organization the API key belongs to, for example org_HYPCX67vaupjhdTn.

Example

org_HYPCX67vaupjhdTn
Media typeapplication/json
object
emails
required

Email addresses to add. Each is trimmed and lower-cased. An invalid address does not reject the request; it is reported as a failed result for that address.

Array<string>
>= 1 items
roles
required

Roles to give every person in this organization. Replaces any roles they already hold here.

Array<string>
>= 1 items
Allowed values: UNEEQ_ADMIN ORG_ADMIN TEAM_ADMIN AUTHOR MANAGER USER
silent_add

When true, no invitation email is sent and no invitation link is returned.

boolean

Example

{
"emails": [
"jane.doe@example.com",
"john.smith@example.com"
],
"roles": [
"USER"
],
"silent_add": false
}

Every email was processed successfully.

Media typeapplication/json
object
results
required

One entry per email sent, in the order sent.

Array<object>
object
email
required

The email this result is for: trimmed and lower-cased, except for an empty or malformed email, which is echoed back trimmed only.

string
id

ID of the user. Present on success.

string format: uuid
success
required

Whether this email was added (or updated) successfully.

boolean
already_member

Present and true when the person was already a member of the organization; only their roles were updated.

boolean
error_code

Present on failure. Stable cause: invalid_email, empty_email, email_taken_by_live_user (a deleted account could not be restored because another active account now uses the email), role_not_permitted, auth0_invite_failed, auth0_add_failed, user_lookup_failed, user_create_failed, user_orgs_lookup_failed, org_membership_check_failed, org_assignment_failed, user_resurrect_failed, invitation_url_store_failed, role_assignment_failed, transaction_start_failed, transaction_commit_failed.

string
error

Present on failure. Human-readable explanation.

string
invitation_url

Present when an invitation was sent. Link the person can use to accept it.

string format: uri
total_count
required

Number of emails in the request.

integer
success_count
required

Number of emails processed successfully.

integer
failed_count
required

Number of emails that failed.

integer

Example generated

{
"results": [
{
"email": "example",
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"success": true,
"already_member": true,
"error_code": "example",
"error": "example",
"invitation_url": "https://example.com"
}
],
"total_count": 1,
"success_count": 1,
"failed_count": 1
}

At least one email failed. Returned even when every email failed. Check success and error_code on each entry of results. Resending the whole request is safe: emails that already succeeded come back with already_member true, their roles are set again, and they are not invited a second time.

Media typeapplication/json
object
results
required

One entry per email sent, in the order sent.

Array<object>
object
email
required

The email this result is for: trimmed and lower-cased, except for an empty or malformed email, which is echoed back trimmed only.

string
id

ID of the user. Present on success.

string format: uuid
success
required

Whether this email was added (or updated) successfully.

boolean
already_member

Present and true when the person was already a member of the organization; only their roles were updated.

boolean
error_code

Present on failure. Stable cause: invalid_email, empty_email, email_taken_by_live_user (a deleted account could not be restored because another active account now uses the email), role_not_permitted, auth0_invite_failed, auth0_add_failed, user_lookup_failed, user_create_failed, user_orgs_lookup_failed, org_membership_check_failed, org_assignment_failed, user_resurrect_failed, invitation_url_store_failed, role_assignment_failed, transaction_start_failed, transaction_commit_failed.

string
error

Present on failure. Human-readable explanation.

string
invitation_url

Present when an invitation was sent. Link the person can use to accept it.

string format: uri
total_count
required

Number of emails in the request.

integer
success_count
required

Number of emails processed successfully.

integer
failed_count
required

Number of emails that failed.

integer

Example generated

{
"results": [
{
"email": "example",
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"success": true,
"already_member": true,
"error_code": "example",
"error": "example",
"invitation_url": "https://example.com"
}
],
"total_count": 1,
"success_count": 1,
"failed_count": 1
}

The request was rejected before any email was processed. error_code is one of: invalid_request_body (body is not valid JSON, is empty, or a field has the wrong type, e.g. “invalid type for field ‘emails’”), emails_required (emails missing or empty), roles_required (roles missing or empty), invalid_role (roles contains an unknown role; the message lists the allowed values), or validation_failed (any other validation failure).

Media typeapplication/json

The body of an error returned by an endpoint.

object
message
required

Human-readable explanation of what went wrong.

string
error_code

Stable machine-readable cause. Present only for errors that have one.

string

Example generated

{
"message": "example",
"error_code": "example"
}

The Authorization header is missing, or the API key is not valid for this organization. A key check that fails on the server is also reported as 401.

Media typeapplication/json

The body of an error returned before the request reaches an endpoint (authentication and rate limiting).

object
error
required

Human-readable explanation of what went wrong.

string

Example generated

{
"error": "example"
}

The API key has sent too many requests. Wait for the number of seconds in Retry-After, then retry.

Media typeapplication/json

The body of an error returned before the request reaches an endpoint (authentication and rate limiting).

object
error
required

Human-readable explanation of what went wrong.

string

Example generated

{
"error": "example"
}
Retry-After
integer
>= 1

Seconds to wait before retrying.