# Authorization

LianaAutomation uses the same OAuth 2.0 client credentials flow as every Liana API.
[Authentication](/authentication) explains how to create credentials in LianaAccount, request a
token and handle its errors. This page lists what is specific to LianaAutomation.

## Scope

Credentials can be created in LianaAccount for installations on automation.lianacloud.com. For
other installations, ask your account manager.

The scope is optional in the token request. Without it, or with `automation-api`, the token can
make every call. To limit a token, request only the sub-scopes it needs, for example
`scope=automation-api:read` for a read-only token:

| Sub-scope               | Operations                                                                                                                                          |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `automation-api:read`   | `pingpong`, `info`, `segment/list`, `form/list`, `channel/list`, `export/*`, `report/*`, `database/search/*`, `database/delete/ready` and `/result` |
| `automation-api:write`  | `import`, `channel/create`, `channel/edit`                                                                                                          |
| `automation-api:delete` | `database/delete/request`, `channel/delete`                                                                                                         |

A call without the sub-scope it needs returns `403` with the message
`Insufficient OAuth scope. 'automation-api:write' required.` (naming the missing sub-scope).
`pingpong`, the first call in the [introduction](./introduction), needs `:read`, so a token with
only `:write` fails it.

## Regions

Bearer tokens work on rest.automation.lianacloud.com, the API URL in
[Regions](./introduction#regions). The Asia (`t.asia.lianacem.com`) and UAE (`t6.lianacem.com`)
installations accept only the legacy HMAC signature: they return 404 to a request with a Bearer
token, and LianaAccount can't create credentials for them.

## Errors

A missing or invalid `Authorization` header, or an expired token, returns 401.
[Requests and responses](./introduction#requests-and-responses) describes the error responses.
