API

Connections

ulex Connections API: all eighteen config.strategy values, per-strategy configuration, connection states, activation, domain routing, OIDC discovery verification, SAML metadata, SP-initiated and IdP-initiated login, ACS, and SLO.

A connection is one identity source for one organization: how the humans of a customer prove who they are. One connection = one IdP.

Required scopes: read:connections, write:connections. SAML ACS consumption additionally needs saml:consume. impersonation_only needs sso:impersonate.

#Object

json
{
  "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
  "object": "connection",
  "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
  "name": "Acme SSO",
  "state": "active",
  "config": {
    "strategy": "mock_sso",
    "mock": {
      "seed_users": [
        {
          "email": "dana@acme.example",
          "first_name": "Dana",
          "last_name": "Okafor",
          "job_title": "Support Lead",
          "department": "Customer Success",
          "groups": ["engineering"],
          "mfa_enrolled": false,
          "status": "active"
        }
      ],
      "force_failure": false,
      "latency_ms": 0
    }
  },
  "domains": ["acme.example"],
  "domains_state": "verified",
  "organization_ids": ["org_01M3PSV8HGTKQFCAYF9GDWGN3C"],
  "directory_ids": [],
  "discovery": {
    "authorization_endpoint": null,
    "token_endpoint": null,
    "userinfo_endpoint": null,
    "jwks_uri": null,
    "issuer": null,
    "fetched_at": null,
    "error": null
  },
  "last_auth_at": "2026-09-29T14:45:12.000Z",
  "last_auth_result": "success",
  "last_auth_error": null,
  "created_at": "2026-09-29T14:42:08.000Z",
  "updated_at": "2026-09-29T14:42:08.000Z"
}

state ∈ draft | active | inactive | expired | error. domains_state ∈ pending | verified | failed | expired.

Warning

A connection is created in state: "draft". Every login on a draft connection fails with 403 connection_not_active. Call POST /connections/{id}/activate before you test anything. This is the single most common cause of "my mock SSO returns 401".

Secrets never leave the server. config.oidc.client_secret_encrypted, config.saml.x509_certificate (public, so it is returned), config.scim.token_encrypted, and config.password.*.bind_password_encrypted are stored encrypted with the tenant KEK. The API returns null or a has_* boolean for the secret-shaped fields and never the ciphertext.

#Strategies

config.strategy is a closed enum of eighteen values.

config.strategyConfig namespaceWhat it is
mock_ssoconfig.mockThe built-in simulated enterprise IdP. The agent-friendly default.
passwordconfig.passwordlocal, LDAP, Active Directory, or RADIUS
magic_link—one-time link to an email address
otp_email—one-time code to an email address
oidcconfig.oidcgeneric upstream OIDC
google_oidcconfig.oidcGoogle, with Google's claim quirks
microsoft_oidcconfig.oidcMicrosoft, multi-tenant issuer
entra_oidcconfig.oidcMicrosoft Entra ID, single-tenant issuer
okta_oidcconfig.oidcOkta, org authorization server
github_oidcconfig.oidcGitHub
apple_oidcconfig.oidcSign in with Apple
generic_oauth2config.oidcOAuth 2.0 without OIDC
samlconfig.samlSAML 2.0 IdP
scimconfig.sciminbound SCIM provisioning from a directory
directory_syncconfig.scimoutbound SCIM polling of a directory
jwt_bearerconfig.jwta federated assertion you POST
x509_client_cert—mTLS client certificate
impersonation_only—agent/test only: log in as any user, no credential
Note

magic_link and otp_email do not send email when allow_mocks: true is enabled (or in local mode): the simulator returns the code or link in the API response and writes it to the auth_attempt record. Use ulex_simulate_login with connection_id set to one of these and read the code from the result.

#Create

bash
curl -sS -X POST "$BASE/connections" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: 1f4c9e2a-3b7d-4a1e-9c58-0f2a6b3d81cc" \
  -d '{
    "name": "Acme SSO",
    "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
    "domains": ["acme.example"],
    "config": {
      "strategy": "mock_sso",
      "mock": {
        "seed_users": [
          { "email": "dana@acme.example", "first_name": "Dana", "last_name": "Okafor", "groups": ["engineering"] }
        ]
      }
    }
  }'

config is a discriminated union on strategy: the only valid keys for mock_sso are strategy and mock. Sending config.oidc alongside config.strategy: "mock_sso" is 400 unknown_parameter with param: "config.oidc".

#OIDC configuration

json
{
  "strategy": "okta_oidc",
  "oidc": {
    "issuer": "https://acme.okta.com/oauth2/default",
    "client_id": "0oa3kq9x2mB7cVd1Rf6sT4pW8L",
    "client_secret_encrypted": null,
    "discovery_url": null,
    "scopes": ["openid", "profile", "email", "groups"],
    "attribute_mapping": {
      "email": "email",
      "email_verified": "email_verified",
      "first_name": "given_name",
      "last_name": "family_name",
      "display_name": "name",
      "job_title": "job_title",
      "department": "department",
      "external_id": "sub",
      "groups": "groups"
    },
    "allowed_domains": ["acme.example"],
    "require_jit_provisioning": false,
    "jit_default_role": "member",
    "username_template": "{email}"
  }
}
FieldDefaultNotes
issuer—must equal the iss in the id_token, byte for byte, including trailing slash
client_id—
client_secret_encryptednullsend "env:VAR" to have ulex read it from its own environment
discovery_urlnulldefaults to {issuer}/.well-known/openid-configuration
scopes["openid","profile","email"]min 1, each ≤ 64 chars
attribute_mappingsee abovemaps an upstream claim name to a ulex field. null disables the field
allowed_domains[]max 500. When non-empty, a login with any other email domain is 403 access_denied
require_jit_provisioningfalselegacy name: when true, JIT creation is disabled for unknown users. Existing users can still sign in. It does not assert that an identity came from a linked directory.
jit_default_rolememberadmin | member | guest — owner is never granted automatically
username_template"{email}"supports {email} and {external_id}

attribute_mapping is the field that makes real IdPs work. Entra's preferred_username is not email; Okta groups are object ids, not names; Apple's sub is stable but its email is only present on the first authorization. Map explicitly. See OIDC claim reference.

#SAML configuration

json
{
  "strategy": "saml",
  "saml": {
    "entity_id": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7",
    "sign_in_url": null,
    "sign_out_url": null,
    "x509_certificate": "MIIE1DCCA3CgAwIBAgIULSJ…",
    "x509_certificate_expires_at": "2027-04-18T00:00:00.000Z",
    "sso_url": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/sso/saml",
    "acs_url": null,
    "audience_uri": null,
    "idp_initiated_url": null,
    "binding": "saml_redirect",
    "name_id_format": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
    "want_response_signed": true,
    "want_assertion_signed": true,
    "want_authn_request_signed": false,
    "signature_algorithm": "rsa-sha256",
    "digest_algorithm": "sha256",
    "name_id_transformations": "email",
    "allow_create": true,
    "allow_update": true,
    "allow_link": true,
    "group_attribute": "groups",
    "groups_attribute": "groups",
    "group_name_template": "{name}",
    "active_attribute": "active",
    "active_value": "true",
    "signature_validation": "strict",
    "allowed_clock_skew_seconds": 120,
    "acs_allowed_urls": [],
    "attribute_mapping": {
      "email": "email",
      "first_name": "firstName",
      "last_name": "lastName",
      "display_name": "displayName",
      "job_title": "title",
      "department": "department",
      "external_id": "userId",
      "groups": "groups"
    }
  }
}

Critical fields:

FieldWhy it matters
sso_urlwhere ulex sends the AuthnRequest. This is the value POST /connections/{id}/verify probes
x509_certificatethe signing certificate or SPKI: PEM armour, bare base64, and a bare public key are all accepted. ulex verifies the assertion signature against this, and verify checks that it yields a usable key — "non-empty" is not "usable", and a certificate the verifier cannot read fails every sign-in with nothing in ulex's logs
entity_idthe IdP's entityID. If the IdP signs the assertion, it must equal the Issuer
audience_uriwhat ulex expects the assertion Audience to be. Defaults to ulex's own entity id
signature_validationstrict (default) requires a signed Assertion. lenient also accepts an unsigned Assertion inside a Response signed by the pinned certificate. Both modes enforce InResponseTo, Destination, Audience, and time conditions; neither accepts an unsigned response and assertion.
allowed_clock_skew_seconds0–600, default 120. Raise only if the IdP's clock is genuinely wrong
acs_allowed_urlsup to 20 ACS endpoints the IdP may POST to. An empty list means "only the connection's own ACS URL"
allow_createtrue
allow_updatetrue
allow_linktrue
name_id_transformationsnone, lowercase, email, email_verified, or saml_subject_hash. email is the default and is what links an assertion to a user

binding ∈ saml_redirect (HTTP-Redirect, default) or saml_post.

Other strategies' config, in brief:

  • config.password — mode ∈ local | ldap | active_directory | radius, with ldap.{url, bind_dn, bind_password_encrypted, base_dn, user_filter, tls_required, start_tls} and radius.{host, port, shared_secret_encrypted}.
  • config.scim — provider, base_url, token_encrypted, poll_interval_seconds (60–86400, default 900), user_filter, group_filter, deprovision_upstream_removals, attribute_mapping.
  • config.jwt — issuer, audience, jwks_url, jwks_encrypted, algorithms (default ["RS256"]), claim_mapping.
  • config.mock — seed_users[] (max 500), force_failure, latency_ms (0–10000).

#The env: value form

Any secret-shaped string accepts env:VAR_NAME. ulex reads the value from its own process environment at request time and stores only the ciphertext.

json
{ "client_secret": "env:ULEX_TEST_OKTA_SECRET" }

This is how you keep real IdP secrets out of the API surface, out of the audit log, and out of your agent's transcript. Applies to config.oidc.client_secret, config.scim.token, config.jwt.jwks, config.password.ldap.bind_password, config.password.radius.shared_secret. See Secret handling.

#List, read, update

bash
curl -sS "$BASE/connections?organization_id=org_01M3PSV8HGTKQFCAYF9GDWGN3C&limit=50" -H "Authorization: Bearer $ULEX_API_KEY"
curl -sS "$BASE/connections/con_01M3PSVAG0QFJG99R0M5DXSR5A" -H "Authorization: Bearer $ULEX_API_KEY"
curl -sS -X PATCH "$BASE/connections/con_01M3PSVAG0QFJG99R0M5DXSR5A" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -d '{"config":{"strategy":"mock_sso","mock":{"force_failure":true}}}'

List filters: organization_id, strategy, state, domain, search, plus the standard pagination parameters.

PATCH replaces the whole config object; it does not deep-merge. Read the current config, modify it, send it back. A patch that changes the strategy is treated as a new connection configuration and forces re-verification — state drops to draft and you must activate again.

#Activate

bash
curl -sS -X POST "$BASE/connections/con_01M3PSVAG0QFJG99R0M5DXSR5A/activate" -H "Authorization: Bearer $ULEX_API_KEY"

Activation is rejected with 409 invalid_state_transition when:

  • any domain on the connection is not verified;
  • strategy: "saml" and x509_certificate_expires_at is in the past;
  • the strategy's required config is missing or invalid;
  • the organization has sso_only: true and the connection has no domains.

Activating an already-active connection is a no-op returning the same object — safe to call repeatedly.

Deactivate is PATCH /connections/{id} with {"state": "inactive"}. Deactivating revokes sessions created through that connection and emits connection.deactivated.

#Verify

bash
curl -sS -X POST "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/verify" -H "Authorization: Bearer $ULEX_API_KEY"

Verify reaches the upstream. It is the documented gate on going live — activate refuses an unverified connection — so "verified" and "the IdP answers" are the same claim. It used to be a config inspection asking whether issuer was non-empty, while this page claimed it fetched discovery.

For OIDC, ulex fetches {issuer}/.well-known/openid-configuration, validates it, and on success caches the endpoints on the connection:

json
{
  "connection_id": "con_01M3PSVY108K5TEHHQ82WN30YK",
  "valid": true,
  "checks": [
    { "check": "client_id present", "status": "passed", "detail": "0oa1b2c3d4e5f6g7h8i9" },
    { "check": "issuer present", "status": "passed", "detail": "https://acme.okta.com/oauth2/default" },
    { "check": "discovery document", "status": "passed", "detail": "issuer matches https://acme.okta.com/oauth2/default" },
    { "check": "authorization code flow", "status": "passed", "detail": "https://acme.okta.com/oauth2/default/v1/authorize" },
    { "check": "token endpoint", "status": "passed", "detail": "https://acme.okta.com/oauth2/default/v1/token" },
    { "check": "jwks", "status": "passed", "detail": "https://acme.okta.com/oauth2/default/v1/keys" },
    { "check": "client_id configured", "status": "passed", "detail": "0oa1b2c3d4e5f6g7h8i9 — ulex cannot confirm the IdP recognises it until someone signs in" }
  ]
}

Validation is strict, and each refusal is one a real IdP causes: the document's issuer must equal the issuer you configured (the mix-up defence), code_challenge_methods_supported must include S256, response_types_supported must include code, and id_token_signing_alg_values_supported must offer an asymmetric algorithm — HS256 is refused because there the client secret is the signing key. The detail on the failed check says which one.

Read the detail on client_id configured carefully: ulex cannot confirm your IdP recognises that client_id. That is the single most common cause of a connection that verifies here and fails at the browser.

For SAML, ulex checks that the pinned certificate yields a usable public key, reports the signature algorithm and clock-skew budget, and probes sso_url:

json
{
  "connection_id": "con_01M3PSVY108K5TEHHQ82WN30YK",
  "valid": false,
  "checks": [
    { "check": "entity_id present", "status": "passed", "detail": "https://acme.okta.com/app/exkxxxx/sso/saml/metadata" },
    { "check": "sso_url present", "status": "passed", "detail": "https://acme.okta.com/app/exkxxxx/sso/saml" },
    {
      "check": "certificate parses",
      "status": "failed",
      "detail": "Unparseable certificate: error:03000072:digital envelope routines::decode error"
    }
  ]
}

A PEM or a bare base64 x509_certificate (or SPKI) is accepted — some IdPs publish only the key. clock skew budget fails below 30 seconds, because most enterprise IdPs need ~60s and a negative NotOnOrAfter otherwise rejects legitimate assertions.

A check reports status: "skipped" when it does not apply to the strategy — SCIM has an upstream, but not one this call reaches. skipped is not passed.

A failing check returns valid: false and no 4xx is raised — verify is diagnostic and always returns 200 with a body, because a caller scripting this has to be able to distinguish "the IdP is misconfigured" from "the check itself broke". Read valid and checks[].

Nothing is cached unless every check passed. A rejected document leaving cached endpoints behind is how a later sign-in ends up trusting the answer this call rejected.

#SAML endpoints

EndpointMethodPurposeCredential
/connections/{id}/saml/metadataGETulex's IdP metadata XMLnone
/connections/{id}/saml/loginGETSP-initiated; 302 to the upstream IdPnone
/connections/{id}/saml/acsPOSTAssertion Consumer Servicesaml:consume
/connections/{id}/saml/sloGET/POSTSingle Logoutsaml:consume
/connections/{id}/saml/ssoPOSTIdP-initiated; used by the built-in fixture IdPnone
bash
curl -sS -L "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/saml/login?RelayState=st_9Kq2WmB7yLt4NxZ"
http
HTTP/2 302 Found
location: https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/sso/saml?SAMLRequest=PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxw…
set-cookie: ulex_saml_request=8JmQ1vZ0Xh4n7cW2; Path=/; HttpOnly; Secure; SameSite=None; Max-Age=300

The AuthnRequest is signed only when want_authn_request_signed is true. RelayState round-trips to your redirect_uri after the ACS, so an agent can complete the whole SP-initiated loop headlessly: GET /saml/login → follow to the fixture IdP → POST /saml/sso with the signed assertion → observe the session.

IdP-initiated, as the built-in fixture IdP posts it:

bash
curl -sS -X POST "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/saml/sso" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "SAMLResponse=$(cat assertion.b64)"
json
{
  "session_id": "ses_01M3PSW6T8FT4M24DH9P8YAY32",
  "user_id": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
  "organization_id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
  "outcome": "success",
  "amr": ["saml"],
  "acs_redirect": "https://app.example.com/auth/callback?code=ac_4Kq9WmB2yLt7NxZ1pRc6HdE0sJg3AuV8&state=st_9Kq2WmB7yLt4NxZ"
}

#Domain routing

When a login arrives with no connection_id, ulex routes on the email domain:

  1. exact match against a domains entry on an active connection with domains_state: "verified";
  2. longest suffix match, so eu.acme.example prefers a connection on eu.acme.example over one on acme.example;
  3. the organization's connection_id;
  4. the organization's default_connection_id;
  5. any mock_sso connection on the tenant, in creation order;
  6. otherwise 400 no_matching_connection.

Put a mock_sso connection on the tenant when you want step 5 to always succeed. That is what ulex_bootstrap_app does.

#Delete

bash
curl -sS -X DELETE "$BASE/connections/con_01M3PSVAG0QFJG99R0M5DXSR5A" -H "Authorization: Bearer $ULEX_API_KEY"
json
{ "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A", "object": "connection", "deleted": true, "revoked_sessions": 2 }
Warning

Deleting a connection does not delete the sessions or grants it produced. Those live until their own expires_at or idle_expires_at. If you need them dead now, revoke them explicitly or call ulex_reset_simulation. This is the most common surprise during a migration.

#Auth attempts

Every login writes an auth_attempt (job_…), readable through GET /status aggregates and the audit log:

json
{
  "id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
  "object": "auth_attempt",
  "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
  "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
  "strategy": "mock_sso",
  "outcome": "success",
  "stage": "complete",
  "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "error_code": null,
  "error_message": null,
  "duration_ms": 214,
  "ip_hash": "sha256:9c2e4a6b8d0f2a4c6e8b0d2f4a6c8e0b2d4f6a8c0e2b4d6f8a0c2e4b6d8f0a2c",
  "correlation_id": "onboard-acme-2026-09-29",
  "started_at": "2026-09-29T14:45:12.000Z",
  "finished_at": "2026-09-29T14:45:12.000Z"
}

stage ∈ initiated | redirected | callback | validated | provisioned | mfa | complete. outcome ∈ success | failure | challenge | error | cancelled.

#Errors

codeStatusCause
validation_failed400invalid strategy, missing required config for the strategy, param names it
unknown_parameter400a config key that does not belong to the chosen strategy
invalid_state_transition409activate with an unverified domain, or an expired certificate
resource_exists409a connection with the same name in the same organization
not_found404no such id in this tenant
domain_not_verified412login routed to a connection whose domains are unverified
saml_signature_invalid400certificate mismatch; re-upload and re-verify
saml_replay_detected400this assertion was already consumed
saml_clock_skew400NotOnOrAfter outside the tolerance
connection_not_active403login on a draft connection — activate it
access_denied403allowed_domains mismatch, sso_only violation, or a suspended user

#MCP equivalents

ulex_create_connection, ulex_list_connections, ulex_get_connection, ulex_activate_connection, ulex_delete_connection, ulex_verify_connection, ulex_get_saml_idp_metadata, ulex_get_saml_login_url.

Deeper: SAML SP integration, SAML metadata reference, SAML troubleshooting.