Outline: [Article Title]

Keyword: [Enter Targeted Keyword]

Keyword MSV: [Enter Targeted Keyword’s Monthly Search Volume]

Author: [Enter Author Name]

Due Date: [Enter Due Date]

Publish Date: [Enter Desired Publish Date]

User Persona: [Enter Targeted Reader and/or User Persona]


Typesense lets you create API Keys with fine-grained access controls. You can limit access to a collection, an action, a record, or a field, or a combination of these.It is strongly advised that you do not use the bootstrap API key in production applications. Instead, you should create a key that is appropriately scoped for the application in question.

Creating an API key

Admin Key First start by creating an API key that allows to perform all operations which essentially is an admin key that’s the same as the one you used to sign up for Typesense using --api-key

For Javascript

key = client.keys().create({
  description: "Admin key.",
  actions: ["*"],
  collections: ["*"],
});

For php

$key = $client->keys->create([
'description' => 'Admin key.',
'actions' => ['*'],
'collections' => ['*']
]);

For python

key = client.keys.create({
"description": "Admin key.",
"actions": ["*"],
"collections": ["*"]
})

For ruby

key = client.keys.create({
'description' => 'Admin key.',
'actions' => ['*'],
'collections' => ['*']
})

For Dart

final key = await client.keys.create({
'description': 'Admin key.',
'actions': ['*'],
'collections': ['*']
});

For Java

ApiKeySchema apiKeySchema = new ApiKeySchema();
List<String> actionValues = new ArrayList<>();
List<String> collectionValues = new ArrayList<>();

actionValues.add("_");
collectionValues.add("_");

apiKeySchema.description("Admin Key").actions(actionValues).collections(collectionValues);
ApiKey apiKey = client.keys().create(apiKeySchema);

For Swift

let adminKey = ApiKeySchema(
\_description: "Admin Key",
actions: ["*"],
collections: ["*"]
)

let (apiKey, response) = try await client.keys().create(adminKey)

For Shell

curl 'http://localhost:8108/keys' \
 -X POST \
 -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
 -H 'Content-Type: application/json' \
 -d '{"description":"Admin key.","actions": ["*"], "collections": ["*"]}'

It is possible to create an admin key with universal access by setting both actions and collections to a wildcard [‘*’] scope. However, one should avoid making keys with such broad scopes. Also, the generated key is only returned during the creation process. This key should be carefully stored in a secure location.