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.
Prerequisite
The project must be initialized with an application linked to the target environment.
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:
npm
npx croct@latest use template.json5Properties
These are the supported properties:
- namestring
The action identifier. Always create-api-key for this action.
- keyNamestring
The display name shown in the dashboard for this API key.
- environmentstring
The environment to create the key for.
Valid values are development and production.
- permissionsArray<string>
The list of permissions to grant to the API key:
Permission Description resource_read_access Allows reading resources such as content and slots. token_issue Allows issuing authentication tokens. data_export Allows exporting analytics and event data. - resultstring
The variable name to store the generated API key secret.