API key types
Meilisearch provides several types of API keys: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: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