Add users to the organization
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}'const url = `${process.env.UNEEQ_API_URL}/external/v1/organization/${process.env.UNEEQ_ORG_ID}/users/add`;const response = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${process.env.UNEEQ_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "emails": [ "jane.doe@example.com", "john.smith@example.com" ], "roles": [ "USER" ], "silent_add": false }),});console.log(response.status, await response.text());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 asinvitation_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: statusinvited, invitation email sent, and this invitation has no expiry, so the person is never reported asexpired. Withsilent_addtrue they are added with statusactiveand 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_memberis 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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”ID of the organization the API key belongs to, for example org_HYPCX67vaupjhdTn.
Example
org_HYPCX67vaupjhdTnRequest Bodyrequired
Section titled “Request Bodyrequired”object
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.
Roles to give every person in this organization. Replaces any roles they already hold here.
When true, no invitation email is sent and no invitation link is returned.
Example
{ "emails": [ "jane.doe@example.com", "john.smith@example.com" ], "roles": [ "USER" ], "silent_add": false}Responses
Section titled “Responses”Every email was processed successfully.
object
One entry per email sent, in the order sent.
object
The email this result is for: trimmed and lower-cased, except for an empty or malformed email, which is echoed back trimmed only.
ID of the user. Present on success.
Whether this email was added (or updated) successfully.
Present and true when the person was already a member of the organization; only their roles were updated.
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.
Present on failure. Human-readable explanation.
Present when an invitation was sent. Link the person can use to accept it.
Number of emails in the request.
Number of emails processed successfully.
Number of emails that failed.
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.
object
One entry per email sent, in the order sent.
object
The email this result is for: trimmed and lower-cased, except for an empty or malformed email, which is echoed back trimmed only.
ID of the user. Present on success.
Whether this email was added (or updated) successfully.
Present and true when the person was already a member of the organization; only their roles were updated.
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.
Present on failure. Human-readable explanation.
Present when an invitation was sent. Link the person can use to accept it.
Number of emails in the request.
Number of emails processed successfully.
Number of emails that failed.
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).
The body of an error returned by an endpoint.
object
Human-readable explanation of what went wrong.
Stable machine-readable cause. Present only for errors that have one.
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.
The body of an error returned before the request reaches an endpoint (authentication and rate limiting).
object
Human-readable explanation of what went wrong.
Example generated
{ "error": "example"}The API key has sent too many requests. Wait for the number of seconds in Retry-After, then retry.
The body of an error returned before the request reaches an endpoint (authentication and rate limiting).
object
Human-readable explanation of what went wrong.
Example generated
{ "error": "example"}Headers
Section titled “Headers”Seconds to wait before retrying.

