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_id values you're allowed to switch into.
Request body
account_id int64 Req
The account to switch to. Must be one you're a member of.
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_id int64
The ID of the account the new token is scoped to — the same value you passed in.
Errors
400 Bad Request
Body could not be parsed, contained unknown fields, or
account_id was missing or not positive.401 Unauthorized
Missing or invalid auth.
403 Forbidden
You are not a member of the target account.
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_id": 87}'
Python
from ngris import Ngris
client = Ngris(api_key="<your_api_key>")
result = client.users.switch_account(account_id=87)
# subsequent calls made with result["token"] are scoped to account 87
print(result["active_account_id"])
Response — 200 OK
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"active_account_id": 87
}