API

Users

ulex Users API: tenant-global user records, the SCIM sub-attributes, status transitions including suspend and unsuspend, listing and filtering, memberships across organizations, and bulk JIT provisioning.

A user is tenant-global. One human is one user object, no matter how many customer organizations they belong to. dana@acme.example who is also a contractor at Globex is a single usr_… with two organization_membership records.

Required scopes: read:users, write:users. Reading a user's memberships needs read:organizations as well.

#Object

json
{
  "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "object": "user",
  "email": "dana@acme.example",
  "email_verified": true,
  "first_name": "Dana",
  "last_name": "Okafor",
  "display_name": "Dana Okafor",
  "external_id": "okta-00u1sAM2xY8ZQ4H1",
  "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
  "job_title": "Support Lead",
  "department": "Customer Success",
  "scim": {
    "user_name": "dana@acme.example",
    "display_name": "Dana Okafor",
    "title": "Support Lead",
    "user_type": "Employee",
    "preferred_language": "en-US",
    "locale": "en-US",
    "timezone": "America/New_York",
    "active": true
  },
  "status": "active",
  "last_seen_at": "2026-09-29T14:45:12.000Z",
  "metadata": { "source": "bootstrap" },
  "created_at": "2026-09-29T14:42:07.000Z",
  "updated_at": "2026-09-29T14:42:07.000Z"
}
FieldTypeNotes
emailstringlowercased, trimmed, max 320, unique per tenant
email_verifiedbooleanset by SSO assertion, by SCIM, or by you
first_name / last_namestring ≤ 80, nullable
display_namestring ≤ 160, nullablefalls back to First Last when null
external_idstring ≤ 255, nullablethe id in the upstream IdP. This is the JIT join key — never put your own app's id here
directory_iddir_… | nullnon-null when the user was provisioned over SCIM
statusactive | inactive | suspended | pendingsee below
scimobjecturn:ietf:params:scim:schemas:core:2.0:User sub-attributes, preserved verbatim
last_seen_attimestamp, nullableset on the first completed login and updated after
metadataRecord<string, string|number|boolean|null>flat only, never indexed, never used for authorization

#Status

statusMeaningLogin
activenormalallowed
inactivedeprovisioned upstream but not explicitly blockedrejected with 403 access_denied
suspendedexplicitly blocked by an operator or a policyrejected with 403 access_denied, all sessions revoked
pendingcreated but never verified, e.g. an inviterejected; needs verification

Only active can log in. The other three all produce 403 access_denied with retryable: false — do not retry, do not loop.

#Create

bash
curl -sS -X POST "$BASE/users" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: 3c9d1f77-0b2e-4a58-9d61-5e7a2c40b913" \
  -d '{
    "email": "dana@acme.example",
    "email_verified": true,
    "first_name": "Dana",
    "last_name": "Okafor",
    "job_title": "Support Lead",
    "department": "Customer Success",
    "scim": { "user_type": "Employee", "preferred_language": "en-US", "active": true },
    "metadata": { "source": "bootstrap" }
  }'
json
{
  "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "object": "user",
  "email": "dana@acme.example",
  "email_verified": true,
  "first_name": "Dana",
  "last_name": "Okafor",
  "display_name": "Dana Okafor",
  "external_id": null,
  "directory_id": null,
  "job_title": "Support Lead",
  "department": "Customer Success",
  "scim": { "user_type": "Employee", "preferred_language": "en-US", "active": true },
  "status": "active",
  "last_seen_at": null,
  "metadata": { "source": "bootstrap" },
  "created_at": "2026-09-29T14:42:07.000Z",
  "updated_at": "2026-09-29T14:42:07.000Z"
}

To attach them to a customer, follow with POST /organizations/{id}/members. Creating a user does not create a membership.

Errors: 409 resource_exists on a duplicate email — with hint: "Reuse the existing user id, or add them to the second organization with ulex_add_organization_member."

#List

bash
curl -sS "$BASE/users?limit=100&status=active" -H "Authorization: Bearer $ULEX_API_KEY"
json
{
  "object": "list",
  "data": [
    { "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S", "object": "user", "email": "dana@acme.example", "status": "active" },
    { "id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN", "object": "user", "email": "pat@acme.example", "status": "active" }
  ],
  "first_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "last_id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
  "has_more": false,
  "next_cursor": null
}
FilterTypeNotes
emailexactthe fastest lookup; use it instead of listing and scanning
external_idexactthe JIT join key
organization_idexactusers who hold a membership in that org
group_idexactmembers of that group
directory_idexactusers provisioned from that directory
statusenumone of the four values
searchprefixmatches email, first_name, last_name, display_name
limit, starting_after, ending_before, ordersee Pagination

#Read, update, delete

bash
curl -sS "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S" -H "Authorization: Bearer $ULEX_API_KEY"

curl -sS -X PATCH "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -d '{"job_title":"Head of Support","status":"active"}'

curl -sS -X DELETE "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S" -H "Authorization: Bearer $ULEX_API_KEY"
json
{ "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S", "object": "user", "deleted": true, "deleted_at": "2026-09-29T16:12:00.000Z", "restore_window_days": 30 }

PATCH accepts: email, email_verified, first_name, last_name, display_name, job_title, department, external_id, status, scim, metadata. An empty body is 400 validation_failed.

Changing email does not re-send a verification. Set email_verified explicitly if you have already verified it out of band. Changing email to one that already exists is 409 resource_exists. PATCH never accepts password_hash, email_verification_code_hash, or password_reset_code_hash — digests are written only by their dedicated paths, so a caller cannot plant a code they never received.

#Confirm a signup (admin)

bash
curl -sS -X POST "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S/confirm-signup" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -d '{}'

The operator equivalent of Cognito's AdminConfirmSignUp: marks the email verified and the account active, clears any outstanding verification code, and is idempotent — confirming twice succeeds. Self-service callers use POST /portal/verify-email/confirm with the 6-digit code instead; this route never accepts a code. See Authentication and Capability status for the full lifecycle.

DELETE removes the user from every organization, revokes every session, and soft-deletes. Prefer status: "suspended" for reversible offboarding.

#Suspend and unsuspend

bash
curl -sS -X POST "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S/suspend" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -d '{"reason":"Offboarded 2026-09-29"}'
json
{
  "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "object": "user",
  "status": "suspended",
  "revoked_sessions": 2,
  "revoked_refresh_token_families": 2,
  "webhook_events_emitted": ["user.suspended", "session.revoked"],
  "audit_action": "user.suspended"
}
bash
curl -sS -X POST "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S/unsuspend" \
  -H "Authorization: Bearer $ULEX_API_KEY"
json
{
  "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "object": "user",
  "status": "active",
  "webhook_events_emitted": ["user.unsuspended"]
}

What suspend does, atomically:

  1. sets status: "suspended";
  2. revokes every active session for that user, in every organization;
  3. revokes every refresh-token family, so a stolen refresh token cannot be replayed;
  4. emits user.suspended and one session.revoked per revoked session;
  5. writes user.suspended to the audit log with your request_id.

Suspending is idempotent — suspending an already-suspended user returns the same object and revokes nothing further. Unsuspend is also idempotent.

Warning

Existing access tokens stay cryptographically valid until exp; what changes is that introspection returns active: false and /userinfo returns 401 token_revoked. If your resource server only verifies the signature and never introspects, it will keep honouring the token for up to 3,600 seconds. For immediate revocation, call POST /oauth2/revoke per token, or keep access-token lifetimes short.

#Memberships across organizations

bash
curl -sS "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S/memberships" -H "Authorization: Bearer $ULEX_API_KEY"
json
{
  "object": "list",
  "data": [
    { "id": "mem_01M3PSVDDRC5YN00BRZ8E7CNMT", "object": "organization_membership", "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C", "role": "owner", "organization": { "id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C", "name": "Acme Corp", "slug": "acme" } },
    { "id": "mem_01M3PSWCNRG3H18C3A2AHBRYRZ", "object": "organization_membership", "organization_id": "org_01M3PSVT404FMFWPN6QAMM2R4P", "role": "member", "organization": { "id": "org_01M3PSVT404FMFWPN6QAMM2R4P", "name": "Globex", "slug": "globex" } }
  ],
  "first_id": "mem_01M3PSVDDRC5YN00BRZ8E7CNMT",
  "last_id": "mem_01M3PSWCNRG3H18C3A2AHBRYRZ",
  "has_more": false,
  "next_cursor": null
}

The same endpoint, reversed, is GET /organizations/{id}/members. Both are the canonical way to answer "which customers is this person in" and "who is in this customer".

#Bulk JIT provisioning

Directory syncs and seed scripts need throughput. Use a directory_sync or the SCIM Bulk endpoint, not a for loop over POST /users.

ts
export async function provisionUsers(
  organizationId: string,
  groupId: string,
  rows: Array<{ email: string; first_name: string; last_name: string; job_title?: string }>,
): Promise<{ created: number; existing: number; memberships: number }> {
  let created = 0;
  let existing = 0;
  let memberships = 0;

  // The users list is capped at 200 per page; a 500-row directory is three pages.
  for (const batch of chunk(rows, 100)) {
    for (const row of batch) {
      try {
        const { user } = await tools.ulex_create_user({
          email: row.email,
          email_verified: true,
          first_name: row.first_name,
          last_name: row.last_name,
          job_title: row.job_title ?? null,
          idempotency_key: `jit-${row.email}`,
        });
        created++;
        await tools.ulex_add_organization_member({
          organization_id: organizationId,
          user_id: user.id,
          role: "member",
          group_ids: [groupId],
        });
        memberships++;
      } catch (err) {
        // 409 resource_exists means this human is already in the tenant. That is
        // the normal case on the second run, not a failure.
        if (isUlexError(err) && err.code === "resource_exists") {
          existing++;
          const found = await findUserByEmail(row.email);
          if (found) {
            await tools.ulex_add_organization_member({
              organization_id: organizationId,
              user_id: found.id,
              role: "member",
              group_ids: [groupId],
            });
            memberships++;
          }
        } else {
          throw err;
        }
      }
    }
  }
  return { created, existing, memberships };
}

#Passkeys and MFA factors

json
{
  "id": "psk_01M3PSVR5GYASQ2ETPYPC11Y2A",
  "object": "passkey",
  "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "credential_id": "8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mN",
  "counter": 0,
  "transports": ["internal", "hybrid"],
  "aaguid": "adce0002-35bc-c60a-648b-0b25f1f05503",
  "device_type": "multi_device",
  "backed_up": true,
  "name": "MacBook Pro",
  "created_at": "2026-09-29T14:42:22.000Z",
  "last_used_at": "2026-09-29T14:45:12.000Z"
}
json
{
  "id": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ",
  "object": "mfa_factor",
  "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "type": "totp",
  "target_hint": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
  "verified": true,
  "created_at": "2026-09-29T14:42:23.000Z",
  "last_used_at": "2026-09-29T14:45:12.000Z"
}

type ∈ totp | sms | email | webauthn | backup_code | push. secret_encrypted is never serialised. target_hint is a SHA-256 of the phone number or address, so the raw destination is never stored. Full walkthrough: MFA and passkeys.

#Email matching

email is normalised by lowercasing and trimming on the way in. Dana@Acme.Example and dana@acme.example are the same user, and the second write returns 409 resource_exists. Gmail-style dot-folding and +tag stripping are not applied: dana.t@acme.example and danat@acme.example are different users, because the domain must be verified anyway and folding them would be wrong for corporate domains.

#Errors

codeStatusCause
validation_failed400bad email, over-long name, wrong enum in status — details names the field
unknown_parameter400a field not in the create schema; objects are strict
resource_exists409email already in the tenant
immutable_field409you tried to change id, email_verified history, or object
not_found404no such id in this tenant
insufficient_scope403missing write:users
access_denied403 on loginstatus is not active, or a join-policy violation

#MCP equivalents

ulex_create_user, ulex_list_users, ulex_get_user, ulex_update_user, ulex_delete_user, ulex_suspend_user, ulex_unsuspend_user, ulex_add_organization_member, ulex_remove_organization_member, ulex_list_organization_members.

See Users and groups in the MCP reference and JIT provisioning patterns.