Scopes
Scopes limit what an access token can do in Tny. Choose them when you create a team or personal access token. Both token types use the same scopes. Start with the narrowest scope that covers your integration. The shared scopes guide explains how parent scopes and write access work.
Available scopes
Broad scopes
| Scope | Access |
|---|---|
tny | Every Tny API operation |
tny:read | Read all Tny resources |
tny:write | Read and change all Tny resources |
Link scopes
| Scope | Access |
|---|---|
tny:links:read | List and view shortened URLs |
tny:links:write | Create, update, and delete shortened URLs, including custom social cards |
Domain scopes
| Scope | Access |
|---|---|
tny:domains:read | List and view link domains and domain redirects |
Utility scopes
| Scope | Access |
|---|---|
tny:utilities:read | Unshorten URLs and look up URL metadata |
Scopes are hierarchical. tny:write includes every Tny write scope and its matching read scope. tny grants all Tny scopes.
Handle a missing scope
The API does not reject a GraphQL request as a whole when the token lacks a scope. It returns null for each field the token cannot access and adds an error for it. The error's extensions list the required and granted scopes:
Code
A null for a non-null field makes its parent null too, which is why team is null in this example. Remove the field from the query or create a token with the required scope. Retrying with the same token returns the same error.
The REST endpoints respond with 403 instead.
Example token configurations
Read links and domains
Use separate read scopes when an integration only needs links and domains.
Code
Manage links
Code
Write access includes read access at the same level, so this token can also list and view links. For a server that shortens links, use a team access token so it keeps working when people join or leave the team.
Read everything
Use the broad read scope for reporting or monitoring across Tny.
Code
Use URL utilities
Code