|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Announcing the Keys API: Create and manage API keys with Server SDKs" |
| 4 | +description: API keys can now be created, updated, and deleted programmatically using Appwrite Server SDKs. Automate key provisioning for CI/CD, multi-tenant setups, and team onboarding workflows. |
| 5 | +date: 2026-04-14 |
| 6 | +cover: /images/blog/improve-devex-dev-keys/cover.png |
| 7 | +timeToRead: 4 |
| 8 | +author: matej-baco |
| 9 | +category: announcement |
| 10 | +featured: false |
| 11 | +callToAction: true |
| 12 | +--- |
| 13 | + |
| 14 | +Managing API keys has always required navigating to the Appwrite Console, selecting scopes, and manually creating each key. For a single project, that works. For teams managing multiple environments, onboarding new services, or provisioning keys as part of automated pipelines, it becomes a bottleneck. |
| 15 | + |
| 16 | +Today, we are announcing the **Keys API**, allowing you to create, update, and delete API keys programmatically through the Appwrite Server SDKs. |
| 17 | + |
| 18 | +# Why this matters |
| 19 | + |
| 20 | +API keys are the foundation of server-side authentication in Appwrite. Every Server SDK call, every CLI operation, and every backend integration depends on them. Being able to manage keys from code opens up workflows that were previously manual: |
| 21 | + |
| 22 | +- **CI/CD pipelines** that provision scoped keys for each deployment environment |
| 23 | +- **Multi-tenant platforms** that create isolated keys per customer with only the scopes they need |
| 24 | +- **Team onboarding** where new services get their own keys automatically |
| 25 | +- **Key rotation workflows** that create a new key, update credentials, and retire the old one without downtime |
| 26 | + |
| 27 | +# How it works |
| 28 | + |
| 29 | +The Keys API introduces two new [API key scopes](/docs/advanced/platform/api-keys#scopes): |
| 30 | + |
| 31 | +- **`keys.read`** for listing and retrieving API keys |
| 32 | +- **`keys.write`** for creating, updating, and deleting API keys |
| 33 | + |
| 34 | +The methods live on the `Project` service, alongside existing project-level operations like environment variables. |
| 35 | + |
| 36 | +## Create an API key |
| 37 | + |
| 38 | +```server-nodejs |
| 39 | +import { Client, Project, ID } from 'node-appwrite'; |
| 40 | + |
| 41 | +const client = new Client() |
| 42 | + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') |
| 43 | + .setProject('<PROJECT_ID>') |
| 44 | + .setKey('<YOUR_API_KEY>'); |
| 45 | + |
| 46 | +const project = new Project(client); |
| 47 | + |
| 48 | +const key = await project.createKey({ |
| 49 | + keyId: ID.unique(), |
| 50 | + name: 'Deployment Key', |
| 51 | + scopes: ['databases.read', 'databases.write', 'users.read'], |
| 52 | + expire: '2026-12-31T23:59:59.000+00:00' |
| 53 | +}); |
| 54 | +``` |
| 55 | + |
| 56 | +Each key is created with a specific set of scopes and an optional expiration date. When no expiration is set, the key remains valid indefinitely. |
| 57 | + |
| 58 | +## Update an API key |
| 59 | + |
| 60 | +```server-nodejs |
| 61 | +const updated = await project.updateKey({ |
| 62 | + keyId: '<KEY_ID>', |
| 63 | + name: 'Deployment Key (updated)', |
| 64 | + scopes: ['databases.read', 'users.read'], |
| 65 | + expire: '2027-06-30T23:59:59.000+00:00' |
| 66 | +}); |
| 67 | +``` |
| 68 | + |
| 69 | +Use this to adjust scopes as requirements change, or to extend or shorten a key's expiration window. |
| 70 | + |
| 71 | +## Delete an API key |
| 72 | + |
| 73 | +```server-nodejs |
| 74 | +await project.deleteKey({ |
| 75 | + keyId: '<KEY_ID>' |
| 76 | +}); |
| 77 | +``` |
| 78 | + |
| 79 | +Once deleted, the key immediately stops authenticating API calls. |
| 80 | + |
| 81 | +# Bootstrap requirement |
| 82 | + |
| 83 | +To use the Keys API, you need an existing API key with the `keys.read` and `keys.write` scopes. This initial key must be created through the Appwrite Console. Once you have it, all subsequent key management can be done programmatically. |
| 84 | + |
| 85 | +# Full SDK support |
| 86 | + |
| 87 | +The Keys API is available across all Appwrite Server SDKs. Complete code examples for every supported language are available in the [API keys documentation](/docs/advanced/platform/api-keys#manage-api-keys-with-a-server-sdk). |
| 88 | + |
| 89 | +# Get started |
| 90 | + |
| 91 | +The Keys API is available on **Appwrite Cloud** today. |
| 92 | + |
| 93 | +1. Navigate to **Overview** > **Integration** > **API keys** and create an API key with the `keys.read` and `keys.write` scopes. |
| 94 | +2. Initialize a Server SDK with your API key. |
| 95 | +3. Use the `Project` service to manage keys from code. |
| 96 | + |
| 97 | +Full documentation is available on the [API keys documentation page](/docs/advanced/platform/api-keys). |
| 98 | + |
| 99 | +# Resources |
| 100 | + |
| 101 | +- [API keys documentation](/docs/advanced/platform/api-keys) |
| 102 | +- [API key scopes reference](/docs/advanced/platform/api-keys#scopes) |
| 103 | +- [How to leverage dynamic API keys for better security](/blog/post/how-to-leverage-dynamic-api-keys-for-better-security) |
0 commit comments