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
{
"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.
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.strategy | Config namespace | What it is |
|---|---|---|
mock_sso | config.mock | The built-in simulated enterprise IdP. The agent-friendly default. |
password | config.password | local, LDAP, Active Directory, or RADIUS |
magic_link | — | one-time link to an email address |
otp_email | — | one-time code to an email address |
oidc | config.oidc | generic upstream OIDC |
google_oidc | config.oidc | Google, with Google's claim quirks |
microsoft_oidc | config.oidc | Microsoft, multi-tenant issuer |
entra_oidc | config.oidc | Microsoft Entra ID, single-tenant issuer |
okta_oidc | config.oidc | Okta, org authorization server |
github_oidc | config.oidc | GitHub |
apple_oidc | config.oidc | Sign in with Apple |
generic_oauth2 | config.oidc | OAuth 2.0 without OIDC |
saml | config.saml | SAML 2.0 IdP |
scim | config.scim | inbound SCIM provisioning from a directory |
directory_sync | config.scim | outbound SCIM polling of a directory |
jwt_bearer | config.jwt | a federated assertion you POST |
x509_client_cert | — | mTLS client certificate |
impersonation_only | — | agent/test only: log in as any user, no credential |
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
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
{
"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}"
}
}| Field | Default | Notes |
|---|---|---|
issuer | — | must equal the iss in the id_token, byte for byte, including trailing slash |
client_id | — | |
client_secret_encrypted | null | send "env:VAR" to have ulex read it from its own environment |
discovery_url | null | defaults to {issuer}/.well-known/openid-configuration |
scopes | ["openid","profile","email"] | min 1, each ≤ 64 chars |
attribute_mapping | see above | maps 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_provisioning | false | legacy 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_role | member | admin | 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
{
"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:
| Field | Why it matters |
|---|---|
sso_url | where ulex sends the AuthnRequest. This is the value POST /connections/{id}/verify probes |
x509_certificate | the 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_id | the IdP's entityID. If the IdP signs the assertion, it must equal the Issuer |
audience_uri | what ulex expects the assertion Audience to be. Defaults to ulex's own entity id |
signature_validation | strict (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_seconds | 0–600, default 120. Raise only if the IdP's clock is genuinely wrong |
acs_allowed_urls | up to 20 ACS endpoints the IdP may POST to. An empty list means "only the connection's own ACS URL" |
allow_create | true |
allow_update | true |
allow_link | true |
name_id_transformations | none, 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, withldap.{url, bind_dn, bind_password_encrypted, base_dn, user_filter, tls_required, start_tls}andradius.{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.
{ "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
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
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"andx509_certificate_expires_atis in the past;- the strategy's required config is missing or invalid;
- the organization has
sso_only: trueand 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
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:
{
"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:
{
"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
| Endpoint | Method | Purpose | Credential |
|---|---|---|---|
/connections/{id}/saml/metadata | GET | ulex's IdP metadata XML | none |
/connections/{id}/saml/login | GET | SP-initiated; 302 to the upstream IdP | none |
/connections/{id}/saml/acs | POST | Assertion Consumer Service | saml:consume |
/connections/{id}/saml/slo | GET/POST | Single Logout | saml:consume |
/connections/{id}/saml/sso | POST | IdP-initiated; used by the built-in fixture IdP | none |
curl -sS -L "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/saml/login?RelayState=st_9Kq2WmB7yLt4NxZ"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=300The 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:
curl -sS -X POST "$BASE/connections/con_01M3PSVY108K5TEHHQ82WN30YK/saml/sso" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "SAMLResponse=$(cat assertion.b64)"{
"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:
- exact match against a
domainsentry on anactiveconnection withdomains_state: "verified"; - longest suffix match, so
eu.acme.exampleprefers a connection oneu.acme.exampleover one onacme.example; - the organization's
connection_id; - the organization's
default_connection_id; - any
mock_ssoconnection on the tenant, in creation order; - 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
curl -sS -X DELETE "$BASE/connections/con_01M3PSVAG0QFJG99R0M5DXSR5A" -H "Authorization: Bearer $ULEX_API_KEY"{ "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A", "object": "connection", "deleted": true, "revoked_sessions": 2 }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:
{
"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
code | Status | Cause |
|---|---|---|
validation_failed | 400 | invalid strategy, missing required config for the strategy, param names it |
unknown_parameter | 400 | a config key that does not belong to the chosen strategy |
invalid_state_transition | 409 | activate with an unverified domain, or an expired certificate |
resource_exists | 409 | a connection with the same name in the same organization |
not_found | 404 | no such id in this tenant |
domain_not_verified | 412 | login routed to a connection whose domains are unverified |
saml_signature_invalid | 400 | certificate mismatch; re-upload and re-verify |
saml_replay_detected | 400 | this assertion was already consumed |
saml_clock_skew | 400 | NotOnOrAfter outside the tolerance |
connection_not_active | 403 | login on a draft connection — activate it |
access_denied | 403 | allowed_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.