-
Notifications
You must be signed in to change notification settings - Fork 10
docs: Add API key permissions page [AE-485] #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sejla
wants to merge
4
commits into
main
Choose a base branch
from
AE-485/api-key-permissions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
833ce65
docs: Add API key permissions page
sejla e43d625
docs: Enumerate all endpoints in API key permissions table
sejla f4c807c
docs: Update API key permissions page with scopes and screenshots
sejla b5b57df
docs(openapi): Document scope-based 403 on scoped endpoints
sejla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| --- | ||
| title: "API Key Permissions" | ||
| description: "Learn how admins can restrict an API key's access to specific endpoints." | ||
| public: true | ||
| --- | ||
|
|
||
| export const ScopeHeader = ({label, scope}) => ( | ||
| <span style={{display: 'flex', justifyContent: 'space-between', alignItems: 'center', width: '100%', gap: '1rem'}}> | ||
| <span>{label}</span> | ||
| <code style={{fontWeight: 400, fontSize: '0.8125rem', backgroundColor: '#e2e8f0', color: '#475569', padding: '0.125rem 0.5rem', borderRadius: '0.375rem'}}>{scope}</code> | ||
| </span> | ||
| ) | ||
|
|
||
| API key permissions let admins limit what a developer API key can do. Instead of one key with full access to every endpoint, you can issue keys that are scoped to specific operations, for example a key that can only translate text or a key that can only read glossaries. | ||
|
|
||
| Permissions are implemented as scopes. Each scope groups a set of related operations into a single capability you can grant to a key. This page uses "permissions" for the user-facing feature and "scopes" for the technical mechanism. | ||
|
|
||
| Permissions are currently supported only for developer API keys. An account can hold any mix of scoped and unrestricted developer keys. | ||
|
|
||
| ### How scopes work | ||
|
|
||
| Developer keys can be turned into scoped keys by assigning them one or more scopes. Once a key is scoped: | ||
|
|
||
| - It can call only the endpoints fully covered by its scopes. | ||
| - Every other endpoint returns `403 Forbidden` including any endpoint that has no scope requirement of its own. | ||
| - Some endpoints require more than one scope. A key must hold all of them; if any is missing, the request is denied and the response lists the missing scopes. | ||
|
|
||
| <Warning> | ||
| Scopes are enforced only on scoped keys. Unrestricted keys retain full access to every endpoint. Existing keys remain unrestricted by default, but admins can assign them scopes at any time. | ||
| </Warning> | ||
|
|
||
| ### Available scopes | ||
|
|
||
| <style>{` | ||
| .scope-endpoints code { font-size: 1rem; } | ||
| `}</style> | ||
|
|
||
| <AccordionGroup> | ||
| <Accordion title={<ScopeHeader label="Translate text" scope="translate:text" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/translate/request-translation"><code>/v2/translate</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="Translate document" scope="translate:document" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/document/upload-and-translate-a-document"><code>/v2/document</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/document/check-document-status"><code>/v2/document/{document_id}</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/document/download-translated-document"><code>/v2/document/{document_id}/result</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="Rephrase or correct text" scope="write:improve" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/improve-text/request-text-improvement"><code>/v2/write/rephrase</code></a></td></tr> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/improve-text/correct-text"><code>/v2/write/correct</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="View glossaries and their entries" scope="glossaries:read" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/multilingual-glossaries/list-all-glossaries"><code>/v3/glossaries</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/multilingual-glossaries/retrieve-glossary-details"><code>/v3/glossaries/{glossary_id}</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/multilingual-glossaries/retrieve-glossary-entries"><code>/v3/glossaries/{glossary_id}/entries</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/glossaries/list-all-glossaries"><code>/v2/glossaries</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/glossaries/retrieve-glossary-details"><code>/v2/glossaries/{glossary_id}</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/glossaries/retrieve-glossary-entries"><code>/v2/glossaries/{glossary_id}/entries</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/multilingual-glossaries/list-language-pairs-supported-by-glossaries"><code>/v2/glossary-language-pairs</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="Create, modify, and delete glossaries" scope="glossaries:write" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/multilingual-glossaries/create-a-glossary"><code>/v3/glossaries</code></a></td></tr> | ||
| <tr><td><code>PATCH</code></td><td><a href="/api-reference/multilingual-glossaries/edit-glossary-details"><code>/v3/glossaries/{glossary_id}</code></a></td></tr> | ||
| <tr><td><code>PUT</code></td><td><a href="/api-reference/multilingual-glossaries/replaces-or-creates-a-dictionary-in-the-glossary-with-the-specified-entries"><code>/v3/glossaries/{glossary_id}/dictionaries</code></a></td></tr> | ||
| <tr><td><code>DELETE</code></td><td><a href="/api-reference/multilingual-glossaries/delete-a-glossary"><code>/v3/glossaries/{glossary_id}</code></a></td></tr> | ||
| <tr><td><code>DELETE</code></td><td><a href="/api-reference/multilingual-glossaries/deletes-the-dictionary-associated-with-the-given-language-pair-with-the-given-glossary-id"><code>/v3/glossaries/{glossary_id}/dictionaries</code></a></td></tr> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/glossaries/create-a-glossary"><code>/v2/glossaries</code></a></td></tr> | ||
| <tr><td><code>DELETE</code></td><td><a href="/api-reference/glossaries/delete-a-glossary"><code>/v2/glossaries/{glossary_id}</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="View style rules and custom instructions" scope="style_rules:read" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/style-rules/list-all-style-rules"><code>/v3/style_rules</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/style-rules/get-style-rule"><code>/v3/style_rules/{style_id}</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/style-rules/get-custom-instruction"><code>/v3/style_rules/{style_id}/custom_instructions/{instruction_id}</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="Create, modify, and delete style rules and custom instructions" scope="style_rules:write" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/style-rules/create-style-rule"><code>/v3/style_rules</code></a></td></tr> | ||
| <tr><td><code>PATCH</code></td><td><a href="/api-reference/style-rules/update-style-rule"><code>/v3/style_rules/{style_id}</code></a></td></tr> | ||
| <tr><td><code>PUT</code></td><td><a href="/api-reference/style-rules/update-configured-rules"><code>/v3/style_rules/{style_id}/configured_rules</code></a></td></tr> | ||
| <tr><td><code>DELETE</code></td><td><a href="/api-reference/style-rules/delete-style-rule"><code>/v3/style_rules/{style_id}</code></a></td></tr> | ||
| <tr><td><code>POST</code></td><td><a href="/api-reference/style-rules/create-custom-instruction"><code>/v3/style_rules/{style_id}/custom_instructions</code></a></td></tr> | ||
| <tr><td><code>PUT</code></td><td><a href="/api-reference/style-rules/update-custom-instruction"><code>/v3/style_rules/{style_id}/custom_instructions/{instruction_id}</code></a></td></tr> | ||
| <tr><td><code>DELETE</code></td><td><a href="/api-reference/style-rules/delete-custom-instruction"><code>/v3/style_rules/{style_id}/custom_instructions/{instruction_id}</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="Retrieve translation memories" scope="translation_memories:read" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/translation-memory/list-translation-memories"><code>/v3/translation_memories</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="Retrieve languages and resources" scope="languages:read" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/languages/retrieve-languages-by-resource"><code>/v3/languages</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/languages/retrieve-resources"><code>/v3/languages/resources</code></a></td></tr> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/languages/retrieve-supported-languages"><code>/v2/languages</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
|
|
||
| <Accordion title={<ScopeHeader label="View subscription usage and limits" scope="usage:read" />}> | ||
| <table className="scope-endpoints"> | ||
| <tbody> | ||
| <tr><td><code>GET</code></td><td><a href="/api-reference/usage-and-quota/check-usage-and-limits"><code>/v2/usage</code></a></td></tr> | ||
| </tbody> | ||
| </table> | ||
| </Accordion> | ||
| </AccordionGroup> | ||
|
|
||
| ### Create a scoped key | ||
|
|
||
| Open the [Keys](https://www.deepl.com/your-account/keys) page in your account. Click "Create key" and optionally name the key. | ||
|
|
||
| Select **Custom permissions**, then choose one or more scopes from the list. | ||
|
|
||
| Click "Create key" to confirm. The key is created with the chosen scopes and shown once in a popup so you can copy it. | ||
|
|
||
| <Frame caption="Creating a scoped API key"> | ||
| <img src="/_assets/images/api-key-permissions-create.png" style={{width: '100%', maxWidth: '340px'}} /> | ||
| </Frame> | ||
|
|
||
| ### Edit scopes on an existing key | ||
|
|
||
| You can change scopes on any existing developer API key, including keys that were originally unrestricted. | ||
|
|
||
| In the API keys table, open the key's menu and select "Edit permissions". Choose **All access** to make the key unrestricted, or **Custom permissions** to select specific scopes. Click "Save" to apply. | ||
|
|
||
| <Frame caption="Editing scopes for an existing API key"> | ||
| <div style={{display: 'flex', flexDirection: 'column', gap: '2.5rem', alignItems: 'center'}}> | ||
| <img src="/_assets/images/api-key-permissions-edit-menu.png" style={{width: '100%', maxWidth: '200px'}} /> | ||
| <img src="/_assets/images/api-key-permissions-edit-dialog.png" style={{width: '100%', maxWidth: '480px'}} /> | ||
| </div> | ||
| </Frame> | ||
|
|
||
| ### Identify scoped and unrestricted keys | ||
|
|
||
| The API keys table includes a column showing each key's permissions. Hover over the badge to view the assigned scopes. | ||
|
|
||
| <Frame caption="Viewing keys and their scopes"> | ||
| <div style={{display: 'flex', flexDirection: 'column', gap: '2.5rem'}}> | ||
| <img src="/_assets/images/api-key-permissions-badges.png" style={{width: '100%'}} /> | ||
| <img src="/_assets/images/api-key-permissions-badge-hover.png" style={{width: '100%'}} /> | ||
| </div> | ||
| </Frame> | ||
|
|
||
| ### Error responses | ||
|
|
||
| When a scoped key calls an endpoint outside its scopes, the API returns a `403 Forbidden` response. To resolve it, call an endpoint covered by the key's scopes, or add the missing scope to the key. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sejla I think this page belongs in the "Admin" section of the "Documentation" tab rather than "API Reference" tab, since it's not actually an API spec. Does that make sense? It could also be a section or sub-page of "Managing API Keys", if not a standalone page: https://deepl-c950b784-ae-485-api-key-permissions.mintlify.app/docs/getting-started/managing-api-keys