Issue a session token scoped to a business
Mint a new token scoped to `business_id`. A new token rather than an amended one: a JWT is signed, so it cannot be re-scoped in place, and issuing a fresh one is what stops the previous scope applying to subsequent calls. Membership is checked here as well as on every later request. Refusing at the point of switching gives the user a clear answer instead of a token that fails on first use.
Mint a new token scoped to business_id.
A new token rather than an amended one: a JWT is signed, so it cannot be re-scoped in place, and issuing a fresh one is what stops the previous scope applying to subsequent calls.
Membership is checked here as well as on every later request. Refusing at the point of switching gives the user a clear answer instead of a token that fails on first use.
Authorization
OAuth2PasswordBearer In: header
Cookie Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
curl -X POST "https://example.com/api/b/v1/context/switch" \ -H "Content-Type: application/json" \ -d '{ "business_id": "f59fcbb7-848d-4242-af07-a8bb7e3ab37c" }'{ "access_token": "string", "token_type": "bearer", "business_id": "f59fcbb7-848d-4242-af07-a8bb7e3ab37c", "role": "owner", "expires_in_minutes": 0}Businesses the caller belongs to GET
Every business this user holds a role in. Requires only a consumer token, because this is how somebody discovers what they can switch into.
What the current token is scoped to GET
The business this session acts for, with the role the server read now. Useful to a dashboard on load, and the smallest endpoint that demonstrates scoping: it names a business without the caller having named one.