Anchor a user to one organization in logiccloud orchestrate and Keycloak
const url = 'http://localhost:3000/api/v1/tenant-consistency/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/anchor';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"organizationId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","roleId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:3000/api/v1/tenant-consistency/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/anchor \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "organizationId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "roleId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'Makes the organization the user’s primary membership and sets the Keycloak organization_id attribute to exactly the user’s membership set, atomically with a rollback of Keycloak on failure. Creates the membership (default role viewer) when the user is not a member yet. A user without a live Keycloak account gets the database anchor only, and a link to a deleted Keycloak account is cleared. Requires Super Admin privileges.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”UUID of the organization (tenant) the request acts in. It selects the tenant and grants nothing: the server checks membership or an open tenant switch. Not needed for global operations. A malformed value returns 400. API keys are fixed to their own organization; another organization returns 403. The x-organization-source header grants nothing.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Organization to make the user primary in, in both logiccloud orchestrate and Keycloak.
Role for a NEW membership; defaults to the system viewer role when the user is not yet a member. Rejected (400) when the user already is a member, because the existing role is kept.
Examplegenerated
{ "organizationId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "roleId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}Responses
Section titled “Responses”object
True when the user was not a member and a membership was created.
Organization_id attribute before the anchor, as Keycloak reported it.
Organization_id attribute now: exactly the membership set, de-duplicated. Order is not meaningful.
False when the user has no live Keycloak account (never linked, or the linked account no longer exists): only the database primary was set (FM-1441).
True when the linked Keycloak account no longer exists and the stale link was removed; the user is linked again on the next sign-in (FM-1441).
True when a logiccloud orchestrate user row was created for a Keycloak-only account (FM-1441).
Examplegenerated
{ "userId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "email": "example", "organizationId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "membershipCreated": true, "previousPrimaryOrganizationId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "previousKeycloakOrganizationIds": [ "example" ], "keycloakOrganizationIds": [ "example" ], "keycloakUpdated": true, "keycloakLinkCleared": true, "userCreated": true}Invalid input data
Forbidden - Super Admin required
User, organization or role not found
Organization not active
Rollback of Keycloak failed; the user must be checked manually
Keycloak rejected the update or could not be read; nothing changed