/keys route allows you to create, manage, and delete API keys. To use these endpoints, you must first set the master key. Once a master key is set, you can access these endpoints by supplying it in the header of the request, or using API keys that have access to the keys.get, keys.create, keys.update, or keys.delete actions.
Key object
name
Type: StringDefault value:
nullDescription: A human-readable name for the key
description
Type: StringDefault value:
nullDescription: A description for the key. You can add any important information about the key here
uid
Type: StringDefault value: N/A
Description: A uuid v4 to identify the API key. If not specified, it is automatically generated by Meilisearch
key
Type: StringDefault value: N/A
Description: An alphanumeric key value generated by Meilisearch by hashing the
uid and the master key on API key creation. Used for authorization when making calls to a protected Meilisearch instance
This value is also used as the {key} path variable to update, delete, or get a specific key.
If the master key changes, all key values are automatically changed.
Custom API keys are deterministic:
key is a SHA256 hash of the uid and master key. To reuse custom API keys, launch the new instance with the same master key and recreate your API keys with the same uid.You cannot reuse default API keys between instances. Meilisearch automatically generates their uids the first time you launch an instance.actions
Type: ArrayDefault value: N/A
Description: An array of API actions permitted for the key, represented as strings. API actions are only possible on authorized
indexes. ["*"] for all actions.
You can use * as a wildcard to access all endpoints for the documents, indexes, tasks, settings, stats, webhooks, and dumps actions. For example, documents.* gives access to all document actions.
indexes
Type: ArrayDefault value: N/A
Description: An array of indexes the key is authorized to act on. Use
["*"] for all indexes. Only the key’s permitted actions can be used on these indexes.
You can also use the * character as a wildcard by adding it at the end of a string. This allows an API key access to all index names starting with that string. For example, using "indexes": ["movie*"] will give the API key access to the movies and movie_ratings indexes.
expiresAt
Type: StringDefault value: N/A
Description: Date and time when the key will expire, represented in RFC 3339 format.
null if the key never expires
Once a key is past its
expiresAt date, using it for API authorization will return an error.createdAt
Type: StringDefault value:
nullDescription: Date and time when the key was created, represented in RFC 3339 format
updatedAt
Type: StringDefault value:
nullDescription: Date and time when the key was last updated, represented in RFC 3339 format
Get all keys
Returns the 20 most recently created keys in aresults array. Expired keys are included in the response, but deleted keys are not.
Query parameters
Results can be paginated using theoffset and limit query parameters.
Response
Example
Response: 200 Ok
API keys are displayed in descending order based on their
createdAt date. This means that the most recently created keys appear first.Get one key
Get information on the specified key. Attempting to use this endpoint with a non-existent or deleted key will result in an error.Path parameters
A valid APIkey or uid is required.
Example
Response: 200 Ok
Create a key
Create an API key with the provided description, permissions, and expiration date.Body
Example
Response: 201 Created
Update a key
Update thename and description of an API key.
Updates to keys are partial. This means you should provide only the fields you intend to update, as any fields not present in the payload will remain unchanged.
Path parameters
A valid APIkey or uid is required.
Body
Example
Response: 200 Ok
Delete a key
Delete the specified API key.Path parameters
A valid APIkey or uid is required.