Remove a member
DELETE /fapi/v1/organizations/{org_id}/memberships/{membership_id} · called from the environment's sign-in host
Removes a member from the organization. The membership becomes removed, and the user's sessions and tokens for this organization are revoked; their account and their other organizations are not touched.
Requires the authenticated user's __Host-idp_session cookie with an exact Origin, or a first-party app's front API access token (Authorization: DPoP <token> with a DPoP proof; see Front API access token). The user must be an active member of the organization with the idp_members:remove permission. A user who is not a member gets 404 not_found; a member without the permission gets 403 insufficient_permissions.
Removing a member is a sensitive action: the user must have signed in within the last 5 minutes. Otherwise the answer is 401 step_up_required with WWW-Authenticate naming max_age=300; sign the user in again with maxAge: 300 and retry. This check comes before anything about the organization is read.
- You cannot remove your own membership here (
403 insufficient_permissions). - Only a member who holds the admin role can remove a member who holds a privileged role (
403 role_not_assignable). - The last active admin cannot be removed (
409 last_org_admin).
With @keenauth/js: await keenauth.organizations.removeMember(orgId, membershipId).
Request
Headers:
| Header | Required | Description |
|---|---|---|
Idp-Client |
yes | SDK identifier. |
Origin |
yes, with the cookie | https://<sign-in host>. |
If-Match |
no | One version, "<version>", from the member list. A version that does not match, or more than one version, returns 412 precondition_failed. |
org_id: the organization identifier (org_…). membership_id: the membership identifier (mem_…).
No body.
Response
204 No Content.
Errors
| Status | Code | When |
|---|---|---|
| 400 | malformed_request |
If-Match is malformed. |
| 401 | unauthenticated |
No valid session cookie or token. |
| 401 | step_up_required |
The user signed in more than 5 minutes ago. |
| 403 | insufficient_permissions |
The user lacks idp_members:remove, or the membership is the user's own. |
| 403 | role_not_assignable |
The member holds a privileged role and the user does not hold the admin role. |
| 403 | origin_not_allowed |
The Origin does not match. |
| 404 | not_found |
No such organization or membership for this user; an unknown, malformed or foreign identifier answers the same. |
| 409 | last_org_admin |
The member is the organization's last active admin. |
| 409 | organization_disabled |
The organization is disabled or pending deletion (organization_pending_deletion). |
| 412 | precondition_failed |
If-Match does not name the membership's current version. |
| 503 | service_unavailable |
Temporarily unavailable; retry after Retry-After. |
Example
curl -X DELETE "https://example.keenauth.app/fapi/v1/organizations/org_01jbz6x8kq3m2n4p5r6s7t8v9a/memberships/mem_01jbz6x8kq3m2n4p5r6s7t8v9b" \
-H "Idp-Client: my-app/1.0.0 (node/22.0.0)" \
-H "Origin: https://example.keenauth.app" \
-b cookies.txt
Personal data
This endpoint carries personal data: organization memberships and invitations. Personal data in the KeenAuth APIs describes what is stored, how long it is kept and how it is deleted. Do not send special categories of personal data (health, biometric data, religion, political opinions, sexual orientation) in any field.