create-api-key

Learn how to create an API key.

This action creates an API key for the configured application and stores the secret in a variable.

Example

The following template creates a development API key and writes it to an environment file:

template.json5
{  "$schema": "https://schema.croct.com/json/v1/template.json",  "title": "API key setup",  "description": "Creates an API key and saves it to .env.",  "actions": [    {      "name": "create-api-key",      "keyName": "Development key",      "environment": "development",      "permissions": ["resource_read_access"],      "result": "apiKey"    },    {      "name": "write-file",      "path": ".env.local",      "content": "CROCT_API_KEY=${this.apiKey}\n"    }  ]}

To apply this template, run:

npx croct@latest use template.json5

Properties

These are the supported properties:

name
string

The action identifier. Always create-api-key for this action.

keyName
string

The display name shown in the dashboard for this API key.

environment
string

The environment to create the key for.

Valid values are development and production.

permissions
Array<string>

The list of permissions to grant to the API key:

PermissionDescription
resource_read_accessAllows reading resources such as content and slots.
token_issueAllows issuing authentication tokens.
data_exportAllows exporting analytics and event data.
result
string

The variable name to store the generated API key secret.