Switch Active Account
Changes which account is active by issuing a new token scoped to the account you name. Your active account determines what every other endpoint reads and writes, so switching is simply a matter of swapping in the new token: all subsequent requests carrying it are scoped to the target account.
You must be a member of the target account. Use /user/accounts to find the account uuid values you're allowed to switch into.
Request body
account_uuid string (uuid) Req
The
uuid of the account to switch to. Must be one you're a member of.Deprecated: account_id (integer) is still accepted until the sunset. Send account_uuid; sending both for different objects is a 400 id_uuid_mismatch.
Response (200 OK)
token string
A new token whose active account is the target. Use it as the bearer for all subsequent requests to operate inside that account; discard the previous token.
active_account_uuid string (uuid)
The
uuid of the account the new token is scoped to — the same value you passed in.Deprecated: until the sunset this response also carries the legacy integer active_account_id. Don't use it; read active_account_uuid.
Errors
400 Bad Request
Body could not be parsed, contained unknown fields,
account_uuid was missing or is not a uuid, or account_id and account_uuid name different accounts (id_uuid_mismatch).401 Unauthorized
Missing or invalid auth.
403 Forbidden
Your membership in the target account is not active.
404 Not Found
account_uuid is not an account you belong to (an unknown uuid and another account's uuid read the same).Request
curl -X POST "https://api.ngris.com/v1/user/switch-account" \
-H "X-API-KEY: <your_api_key>" \
-H "Content-Type: application/json" \
-d '{"account_uuid": "019a6e8e-a31d-751c-96b0-440186b7f3a8"}'
Python
from ngris import Ngris
client = Ngris(api_key="<your_api_key>")
result = client._post_raw(
"/user/switch-account",
{"account_uuid": "019a6e8e-a31d-751c-96b0-440186b7f3a8"},
)
# subsequent calls made with result["token"] are scoped to that account
print(result["active_account_uuid"])
Response — 200 OK
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"active_account_uuid": "019a6e8e-a31d-751c-96b0-440186b7f3a8"
}
Was this helpful?