API key types
Meilisearch provides several types of API keys:| Key type | Purpose | Usage |
|---|---|---|
| Default admin key | Full API access | Day-to-day admin operations |
| Default search key | Search-only access | Client-side search requests |
| Custom API keys | Scoped permissions | Fine-grained access control |
List all API keys
Retrieve all existing API keys. This endpoint requires the admin API key.uid, key, actions, indexes, expiresAt, and timestamps.
Create an API key
Create a new key with specific permissions. Specify whichactions the key can perform and which indexes it can access.
Available actions
Actions define what operations a key can perform:| Action | Description |
|---|---|
* | All operations (admin-level access) |
search | Search within allowed indexes |
documents.add | Add or replace documents |
documents.get | Retrieve documents |
documents.delete | Delete documents |
indexes.create | Create new indexes |
indexes.get | Retrieve index information |
indexes.update | Update index settings |
indexes.delete | Delete indexes |
indexes.swap | Swap two indexes |
tasks.get | Retrieve task information |
tasks.cancel | Cancel pending tasks |
tasks.delete | Delete finished tasks |
settings.get | Retrieve index settings |
settings.update | Update index settings |
stats.get | Retrieve instance statistics |
dumps.create | Create database dumps |
snapshots.create | Create database snapshots |
version | Retrieve version information |
keys.get | Retrieve API key information |
keys.create | Create new API keys |
keys.update | Update existing API keys |
keys.delete | Delete API keys |
Scope keys to specific indexes
Theindexes field accepts an array of index UIDs. Use ["*"] to grant access to all indexes, or specify individual ones:
expiresAt to null creates a key that never expires.
Update an API key
You can update a key’sname and description. The actions, indexes, and expiresAt fields cannot be modified after creation. If you need different permissions, create a new key instead.
API_KEY_UID with the key’s uid value (not the key itself).
Delete an API key
Permanently revoke a key by deleting it. Any requests using this key will be rejected immediately.Key rotation
Regularly rotating API keys reduces the risk of compromised credentials. To rotate a key:- Create a new key with the same
actionsandindexesas the old one - Update your application to use the new key
- Verify that the application works correctly with the new key
- Delete the old key
expiresAt field to enforce automatic expiration. When a key expires, all requests using it will return a 403 error.
Best practices
- Use the principle of least privilege. Give each key only the permissions it needs. A front-end search client should only have the
searchaction. - Scope keys to specific indexes. Avoid using
["*"]for indexes unless the key genuinely needs access to all of them. - Set expiration dates. Keys without expiration dates remain valid indefinitely, which increases security risk.
- Never expose admin API keys. Only use them server-side to manage API keys. Use search or scoped API keys for all other operations.
- Rotate keys regularly. Create new keys before old ones expire and update your applications accordingly.
Next steps
Security overview
Learn about tenant tokens and multi-tenancy
Keys API reference
Full API reference for the
/keys endpoint