API Keys
Your instance API key can do everything: read, change and delete all your data. Keep it on your server. For everything else, such as a search box in the browser, a separate app or a partner integration, create scoped keys: each one can only use the actions and indexes you choose, and you can delete it at any time without touching anything else.
These are standard Meilisearch API keys, so the official SDKs accept them as they are.
Create a key in the portal
- In app.celersearch.com, open your instance and go to API keys.
- Click New key and choose:
- Access: Search only (the usual choice for a front end), or custom actions such as adding documents or reading settings.
- Indexes: the indexes the key may use, or all indexes.
- Expires (optional): the key stops working at the end of that day (UTC).
- Copy the key that appears. You can reveal it again later from the same page.
Each instance can have up to 50 keys created this way.
Or create keys with the API
Your instance API key can manage keys with the standard Meilisearch
/keys endpoint:
curl -X POST "$CELERSEARCH_URL/keys" \
-H "Authorization: Bearer $CELERSEARCH_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"description": "Storefront search",
"actions": ["search"],
"indexes": ["products"],
"expiresAt": null
}'
The answer contains the new key (key) and its id (uid). A key works through
your endpoint as soon as it's created, and stops working as soon as it's deleted.
Use a key from the browser
A search-only key limited to the right indexes is safe to ship in front-end code:
import { Meilisearch } from 'meilisearch'
const client = new Meilisearch({
host: 'https://your-endpoint-url',
apiKey: 'your-search-only-key',
})
const { hits } = await client.index('products').search('running shoes')
Tenant tokens
To give each signed-in user their own view of an index (for example only their
own documents), sign a tenant token
on your server with a search key and its uid, and hand the token to the
browser. Your endpoint accepts tenant tokens signed with any of your scoped
search keys.
What your endpoint doesn't accept
- Keys with full access (the
*action) or key-management actions (keys.*): use the instance API key for those, from your server. This also applies to the engine's built-in "Default Admin API Key". - Dumps and snapshots stay disabled for every key; your data is protected by encrypted backups.
If the instance API key is replaced
Meilisearch derives every key's value from the instance API key. If we ever replace your instance API key (for example after a leak), all your scoped keys get new values: copy the new ones from API keys and update your apps.