Skip to content
Directory & LifecycleMarkdown

Offboard a leaver

Stop a departing user's sign-in and tokens at once, end the sessions they hold, and delete their account when you no longer need it.

API

Ben leaves today. By the end of this guide he can’t sign in, no app can get a token for him, every session he had open is over, and his groups no longer list him. His record stays, inactive, for as long as you need it, and you can delete it later in one call.

Before you start: you’re a realm administrator holding RealmOwner, with your session in $CVYUH_SESSION (see Call the API). You need the user’s id and their sign-in name (uid), here both ben.

  1. Set him inactive:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "status": "inactive" }'

    From now on his sign-in is refused, no app gets a new token for him, his refresh tokens stop working, and his tokens read as inactive to any app that asks the realm. An access token he already holds still works, at an app that checks it itself, until it expires (five minutes by default).

  2. End the sessions he still holds, found by his sign-in name:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/sessions/v1/end \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "qbe": { "filter": { "field": "user", "op": "=", "value": "ben" } } }'

    The realm answers { "ended": <n> }. Each session ends as a sign-out does, and the apps it signed in to are told.

  3. Remove him from every group at once, by setting his groups to an empty list:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "memberOf": [] }'

    Each of his groups stops listing him in the same write. To remove him from one group only, use DELETE on /objects/v1/group/{group}/relationships/member/ben with If-Match: *.

  4. Hand over his agents. Agents acting for him already get nothing for him, but agents he owns go on, and would be left with no owner if you deleted him. List them:

    Terminal window
    curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben?expand=ownedAgents/*" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

    For each one, remove Ben as its owner and name the new one, here Maya:

    Terminal window
    curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent/relationships/businessOwner/ben \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "If-Match: *"
    curl https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent/relationships/businessOwner \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -H "If-Match: *" \
    -d '{ "targetId": "maya" }'

    Or stop an agent no one needs: see Stop an agent.

  • His live sessions are gone:

    Terminal window
    curl -G https://foobar.cvyuh.com/api/v0/am/sessions/v1 \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    --data-urlencode 'filter={"filter":{"field":"user","op":"=","value":"ben"}}'
  • A read of /objects/v1/user/ben?expand=memberOf/* shows status inactive and no groups, and one with ?expand=ownedAgents/* shows no agents.

  • A sign-in as ben is refused.

When you no longer need his record, delete it:

Terminal window
curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "If-Match: *"

This also removes every link to him and his personal vault, with every secret in it. It can’t be undone. Any agent still naming him as owner is left with none, which is why step 4 comes first.

Before you delete the account, everything is reversible. Set { "status": "active" } and add him back to his groups, and he can sign in again with what he had. Note his groups before step 3 if he may come back.