# Identity and access ## Two keys, two surfaces | | Tenant-level user’s key | Account-level user’s key | | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | Issued by | a user who holds `tenant:api_key:manage`, on the [Tenant API](https://docs.aiva.apifonica.com/api/tenant/) | a user who holds `account:api_key:manage`, on the [Account API](https://docs.aiva.apifonica.com/api/account/) | | Opens | [Tenant API](https://docs.aiva.apifonica.com/api/tenant/), and the [Account API](https://docs.aiva.apifonica.com/api/account/) for any account of the tenant. `X-Account-Sid` names the account | [Account API](https://docs.aiva.apifonica.com/api/account/), for its own account | | Can create accounts | yes, with the permission `account:manage` | no | Never ship a tenant-level user's key to an account-level consumer A tenant-level user’s key reaches every account of the tenant. With the role `tenant_admin` it can create accounts, their users and their keys. It belongs in your provisioning service, not in anything a business unit operates. Voicebot issues an account-level user’s key through [POST/v1/a/user/{sid}/api-key](https://docs.aiva.apifonica.com/api/account/operations/issueuserapikey/) and a tenant-level user’s key through [POST/v1/t/user/{sid}/api-key](https://docs.aiva.apifonica.com/api/tenant/operations/issuetenantuserapikey/). The first key of the first `tenant_admin` comes from us, at provisioning ([phase 1, step 4](https://docs.aiva.apifonica.com/integration/phase-1-onboarding/#step-4--set-up-the-tenant)). The principal that issues a key also lists and revokes it, and a signed-in person lists and revokes their own keys from their profile ([GET/v1/a/profile/api-key](https://docs.aiva.apifonica.com/api/account/operations/listprofileapikeys/), [DELETE/v1/a/profile/api-key/{key\_sid}](https://docs.aiva.apifonica.com/api/account/operations/revokeprofileapikey/)). ## Permission gates the action, scope gates the target These are two independent checks and both must pass. - **Permission.** May this caller perform this kind of action at all? Deleting a scenario, issuing a key, dispatching a call. The roles the caller holds decide it. Some roles are fixed, and your tenant builds the others. [Roles and permissions](https://docs.aiva.apifonica.com/concepts/roles-and-permissions/) lists every permission and what it lets a person do. - **Scope.** May this principal touch *this particular object*? Resolved from the principal, never from a header the caller controls. A key acts with the roles of the user who owns it. [GET/v1/a/profile](https://docs.aiva.apifonica.com/api/account/operations/getprofile/) lists the permissions the caller holds. A read of an object outside your scope answers `404`, not `403`. Returning `403` would confirm the object exists, which is itself a leak. ## Signing your users in Voicebot supports two sign-in shapes. Neither asks your people to maintain a second password. **Magic link.** Your system asks Voicebot for a one-time sign-in link for a user it already authenticated, then redirects the browser to it. [POST/v1/a/user/{sid}/magic-link/request](https://docs.aiva.apifonica.com/api/account/operations/issueusermagiclink/) **Provisioned credentials.** Your system creates the user and drives a password reset, and the person signs in directly. [POST/v1/a/user/{sid}/password-reset/request](https://docs.aiva.apifonica.com/api/account/operations/issueuserpasswordreset/) Both requests need the permission `account:sign_in:manage`. The permission to edit users does not include it. Note You choose between them during [phase 2](https://docs.aiva.apifonica.com/integration/phase-2-api-integration/), depending on whether your identity provider can front the redirect. ## Session tokens Both API surfaces authenticate with a bearer token, and there are three ways to hold one. - An API key, sent as the bearer directly. - A session token from a password login through [POST/v1/a/auth/regular](https://docs.aiva.apifonica.com/api/account/operations/authregularlogin/). This works for account-level users only: a tenant-level user holds no password. - A session token from a magic link consumed through [POST/v1/a/auth/magic-link/consume](https://docs.aiva.apifonica.com/api/account/operations/authmagicconsume/). This works for any user. A tenant-level user has no other way to sign in. A session expires after 24 hours by default. There is no refresh: the client signs in again. ## Feature flags Voicebot resolves what a tenant may use server-side and exposes it on the caller’s profile. Read the flags rather than hard-coding what a tenant may use into your integration. We set the rules. Neither published surface changes them. [GET/v1/a/profile](https://docs.aiva.apifonica.com/api/account/operations/getprofile/)