To allow Laravel Scout's scout:import (and usually scout:flush) to work with a Typesense Scoped API key, your key must include permissions that allow:
- Deleting all documents in a collection (for flush)
- Creating and updating documents (for import)
- Searching (Scout may do test queries for validation)
- Retrieving collection schema (Scout may check if the collection exists)
- Creating a collection (only if it doesn't exist)
Based on typical Scout and Typesense interactions, these are the minimal needed actions for a scoped key:
"actions": [
"documents:delete", // for flush
"documents:create", // for import
"documents:update", // for import (if update mode)
"documents:search", // for any queries
"documents:get", // to retrieve a single document
"collections:retrieve", // to check if collection exists
"collections:create" // to create collection if missing (Scout may issue this)
]
If you want to be even more restrictive and you are certain your collection already exists (and will never be created/updated by Scout), you could potentially omit "collections:create". However, to cover all cases and normal Scout workflows, the above list is recommended.
Example for creating such a key via Typesense API:
POST /keys
{
"actions": [
"documents:delete",
"documents:create",
"documents:update",
"documents:search",
"documents:get",
"collections:retrieve",
"collections:create"
],
"collections": ["your_collection_name"]
}
Note:
- Replace
"your_collection_name"with the actual collection name you will index. - If you have multiple collections, add them all to the
"collections"array.
If import still fails after using these permissions, check the error message from Typesense (it usually specifies the missing permission). Sometimes, underlying libraries might need one additional permission, depending on versions.
Summary:
You do not need "*" permissions. The above actions are typically sufficient for importing and flushing with Scout.