SCIM issues
Diagnosing ulex SCIM in both directions: why an IdP's test connection fails, 409 uniqueness, 412 mutability, invalidFilter, users provisioned but unable to log in, deprovisioning reaching the wrong scope, and Bulk partial failures.
#Start here
BASE="https://ulexid.com/api/v1"
AUTH="Authorization: Bearer $ULEX_API_KEY"
SCIM="Authorization: Bearer scim_7Bq4Nxf2Vk9Lc3MdT6hR8wS1yP5aG0eJ"
# Inbound: is the directory live, and is anything arriving?
curl -sS "$BASE/directories/$DIR_ID" -H "$AUTH" | jq '{state, inbound_scim_enabled, has_inbound_scim_token, last_sync_status, last_sync_error}'
# Does the SCIM endpoint answer the IdP's probe?
curl -sS -G "$BASE/scim/v2/Users" -H "$SCIM" --data-urlencode 'filter=userName eq "probe@acme.example"' | jq '{totalResults, itemsPerPage}'
# What arrived?
curl -sS -G "$BASE/directories/$DIR_ID/users?limit=5" -H "$AUTH" | jq '.data[] | {email, status, external_id, directory_id}'
# What events fired?
curl -sS -G "$BASE/audit-events" -H "$AUTH" --data-urlencode 'action_prefix=user.' --data-urlencode 'limit=10' \
| jq '.data[] | {action, outcome, error_code}'#The IdP's "Test connection" fails immediately
Okta sends GET /Users?filter=userName eq "probe@<domain>". Three causes, in order of likelihood.
| Cause | Diagnose | Fix |
|---|---|---|
| wrong token | 401 | re-read it: GET /directories/{id}/scim. The token is shown once per rotation |
the directory is not active | 403 | state: pending means it has not been activated. PATCH or recreate with state: "active" |
inbound_scim_enabled is false | 403 or 404 | PATCH /directories/{id} with true |
curl -sS -G "$BASE/scim/v2/Users" -H "$SCIM" --data-urlencode 'filter=userName eq "probe@acme.example"' -i | head -1A 200 with Resources: [] is success. Okta's test expects an empty result for a user that does not exist; anything non-2xx is a failure.
If you lost the SCIM token, do not delete and recreate the directory. That discards the scim_id mappings on every group, and the customer's next group push creates duplicates. PATCH /directories/{id} with a new scim_token instead.
#409 uniqueness
scimType: "uniqueness". Something already exists with that userName or externalId.
| Case | Cause | Fix |
|---|---|---|
| every push collides | the same person was created by another route — an OIDC login, a JIT SAML assertion, or a POST /users | reconcile before pushing: GET /scim/v2/Users?filter=externalId eq "…" |
userName collides but the person is different | two directory entries with the same email | fix the source directory. ulex cannot represent two people with one email |
externalId collides | the IdP is reusing external ids, or externalId is not set at all and is defaulting | always send externalId; it is the join key |
a group displayName collides | two groups in one org whose names slugify the same | rename in the source. 409 is the correct behaviour, not a bug |
# Is it a userName or an externalId collision?
curl -sS -G "$BASE/scim/v2/Users" -H "$SCIM" --data-urlencode 'filter=userName eq "pat@acme.example"' | jq '.Resources[].id'
curl -sS -G "$BASE/scim/v2/Users" -H "$SCIM" --data-urlencode 'filter=externalId eq "okta-00u9xK2mB7yLt4N"' | jq '.Resources[].id'IdPs retry a 409 indefinitely. It is not a transient failure and retrying will not clear it. Fix the data.
#412 mutability on every update
The If-Match value is stale.
# Read the current version
curl -sS "$BASE/scim/v2/Users/$USER_ID" -H "$SCIM" | jq -r '.meta.version'
# → W/"v1.0"
# Patch with it
curl -sS -X PATCH "$BASE/scim/v2/Users/$USER_ID" -H "$SCIM" \
-H "If-Match: W/\"v1.0\"" -H "Content-Type: application/scim+json" \
-d '{"schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"],"Operations":[{"op":"replace","path":"department","value":"Customer Experience"}]}'| Cause | Fix |
|---|---|
| two sync runs overlapped | re-read meta.version and re-apply. This is the lock working |
the IdP caches meta.version | most do not; Entra re-reads. If yours caches, report it — it is a real interoperability bug |
| the version was for a deleted-and-recreated user | re-read; ids are new |
Do not drop the If-Match header to make the error go away. It is the only thing preventing a lost update when two pushes race, and the resulting state is silently wrong.
#400 invalidFilter
| What they sent | Why it fails | What to send |
|---|---|---|
externalId eq "x" and no user has externalId | the attribute path does not exist on any resource | add externalId to your pushes, or stop filtering on it |
department eq "Support" and title ne "Engineer" | over 4 boolean operators | one filter per request |
emails.value eq "x@y.com" | bare sub-attribute paths are not supported | emails[type eq "work"].value eq "x@y.com" |
active eq true where active is a string | the comparison operators are for typed values | active eq true with a boolean, or filter on meta.lastModified |
a URL-encoded filter with a + for a space | + is not a space in a query string | use %20 |
Test any filter before you hand it to a customer:
curl -sS -G "$BASE/scim/v2/Users" -H "$SCIM" --data-urlencode 'filter=department eq "Customer Success" and active eq true' | jq#400 invalidPath
The PATCH path does not exist.
| They sent | Correct form |
|---|---|
nickname | nickName |
name.first | name.givenName |
emails.value | emails[type eq "work"].value |
group | members on /Groups, or nothing on /Users — groups is read-only there |
urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:employeeNumber | correct, but only if you sent the extension |
#Users provisioned but cannot log in
This is the most consequential SCIM problem, because provisioning succeeded and nothing is broken in the directory.
| Cause | Diagnose | Fix |
|---|---|---|
the organization is sso_only and has no active connection | 403 access_denied at login | activate a connection, or set sso_only: false |
the email domain is not a verified org domain and allow_profiles_outside_organization: false | 403 access_denied | verify the domain, or set the flag to true |
email_verified is false and your app gates on it | GET /users/{id} | set it, or stop gating on it. Entra does not assert it |
| the user has no membership in any organization | GET /users/{id}/memberships returns [] | a SCIM user always gets a member membership. An empty list means the directory is not bound to the organization |
the connection's allowed_domains excludes the domain | 403 access_denied | add the domain |
the user status is inactive | GET /users/{id} | upstream active: false, or a failed sync |
curl -sS "$BASE/users/$USER_ID" -H "$AUTH" | jq '{email, email_verified, status, directory_id}'
curl -sS "$BASE/users/$USER_ID/memberships" -H "$AUTH" | jq '.data[] | {organization_id, role}'#Deprovisioning removed access to the wrong organization
This is correct behaviour and it is the most common SCIM surprise.
DELETE /scim/v2/Users/{id} sets status: suspended on the tenant-global user, revokes every session in every organization, and revokes every refresh-token family.
A contractor who is in your tenant through two customers, and whom one customer deprovisions, loses access to both. RFC 7644 models users as global to the service provider, and ulex follows it.
| Want | Call |
|---|---|
| deprovision from a customer's IdP (correct SCIM semantics, tenant-wide) | DELETE /scim/v2/Users/{id} |
| remove one person from one customer | DELETE /organizations/{id}/members/{userId} |
| block a person everywhere, reversibly | POST /users/{id}/suspend |
If a customer's deprovision workflow must not affect other customers, route it through DELETE /organizations/{id}/members/{userId} in a provisioning workflow rather than through SCIM, and document that choice.
#Bulk partially failed
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:BulkResponse"],
"Operations": [
{ "method": "POST", "bulkId": "alex", "status": "201", "location": "/Users/usr_01M3PSWCNRG3H18C3A2AHBRYRZ" },
{ "method": "POST", "bulkId": "robin", "status": "409", "response": { "status": "409", "scimType": "uniqueness", "detail": "A User with userName robin@acme.example already exists." } }
]
}The call's HTTP status is 200 even when operations failed. Read Operations[].
status | Meaning |
|---|---|
201 | created |
200 | replaced or patched |
204 | deleted |
409 | uniqueness or mutability |
400 | the individual operation was malformed |
5xx | our fault for that operation. Retry the whole Bulk with failOnErrors: 0 |
With failOnErrors: 0, a failure does not stop the rest. With >= 1, the batch aborts at the Nth failure. For a seed use 0 — you want to know about every bad row. For a mirror use 1 — a partial directory is worse than an unchanged one.
bulkId referenced from members[].value must appear earlier in the request. A forward reference is 400.
#413 scim_bulk_exceeded
Over 100 operations, or over 10 MiB. Chunk at 100.
for (let i = 0; i < rows.length; i += 100) {
const chunk = rows.slice(i, i + 100);
// POST /scim/v2/Bulk with chunk
}#429 from SCIM
3,000 requests per minute per bearer token. Almost always a script in a tight loop, not the IdP.
{ "error": { "type": "rate_limit_error", "code": "rate_limit_error", "retryable": true, "hint": "Retry after 12s." } }#Nothing is arriving at all
curl -sS -G "$BASE/audit-events" -H "$AUTH" --data-urlencode 'action_prefix=user.' --data-urlencode 'limit=5' | jq 'length'
curl -sS "$BASE/webhooks/$WHK_ID" -H "$AUTH" | jq '{status, failure_count, last_delivery_status}'| Check | Bad value means |
|---|---|
inbound_scim_enabled | false → the endpoint is not exposed |
has_inbound_scim_token | false → no token was ever generated |
webhook status | disabled with failure_count: 8 → events fired and were never delivered |
last_delivery_status | 5xx or null → your receiver is broken, and the events exist but nobody saw them |
A silent SCIM endpoint looks identical to a working one from the IdP's side. Check the audit log, not the customer's dashboard.