---
title: "Create"
method: POST
path: "/v2/storage/triggers/"
tags: ["Triggers"]
---

# Create

`POST /v2/storage/triggers/`

## Request

- Base URL: `https://connection.keboola.com`
- URL: `https://connection.keboola.com/v2/storage/triggers/`
- Auth: one of:
  - API key in header `X-StorageApi-Token`
  - API key in header `X-KBC-ManageApiToken`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/keboola/apis/keboola-storage-api/docs/v2/storage/triggers/post~2.ts> (a function with typed inputs; its response is checked against the schema)

Creates a trigger listening on a set of tables.

Token has to be [*master*](https://help.keboola.com/storage/tokens/) (then `runWithTokenId` can be also master). If it isn't master, it has to have `canManageBuckets` permission or `componentAccess` permission for the component which you want to trigger. This also applies when updating and deleting triggers.
When updating the component of trigger you need permissions for both the current component and the component you're updating the trigger to.

Without `runWithTokenId`, the trigger creates the token it runs with, in the same request, and owns it:
- The token never expires and is named `[_internal] Token for triggering <configurationId>`.
- In a project with a protected default branch it can only create jobs; elsewhere it can manage buckets and read all file uploads.
- Your token has to be able to create that token.
- If the trigger cannot be created, no token is left behind.
- Deleting the trigger, or giving it another token, revokes the token.

## Request body

- CreateTriggerRequest
  - `runWithTokenId` integer, nullable: ID of the token that runs the configured component. When omitted or `null`, the trigger creates a non-expiring token `[_internal] Token for triggering <configurationId>` and owns it: deleting the trigger, or giving it another token, revokes that token.
  - `component` string, required: Component ID of the triggered configuration (typically `orchestration`).
  - `configurationId` string, required: ID of component configuration.
  - `coolDownPeriodMinutes` integer, required: Minimal cool down period before firing action again in minutes (min is 1 minute).
  - `tableIds` string[], required: IDs of tables to watch (like `in.c-test.watched`).

## Response `201`

Trigger created.

- TriggerResponse
  - `id` string, required: Trigger ID.
  - `runWithTokenId` integer, required: ID of token used for running configured component.
  - `component` string, required: Component ID of the triggered configuration.
  - `configurationId` string, required: ID of component configuration.
  - `lastRun` string, nullable, required: Time of the last trigger run, ISO 8601 with a `+hhmm` offset; `null` if never fired.
  - `creatorToken` object, required: Token that created the trigger.
    - `id` integer, required: Token ID.
    - `description` string, required: Token description.
  - `actor` ActorResponse, required: Who performed the action and through which credential.
    - `type` 'token' | 'session' | 'pat' | 'system', required: Credential the action came through: a Storage token, a programmatic session, a personal access token, or system work.
    - `id` string, required: Token id as a string, session or personal access token UUID, or the system subject.
    - `name` string, required: Token description, the admin email for a session or personal access token, or the system label, as it was when the action happened.
    - `adminId` integer, nullable, required: Admin behind the credential; null for a token without an admin, for system work, and when the admin was not recorded (an object whose creator is known only from its token columns, including rows backfilled from them).
  - `coolDownPeriodMinutes` integer, required: Minimal cool down period before firing action again in minutes.
  - `tables` object[], required: Watched tables.
    - `tableId` string, required: Table ID.

## Other responses

- `400`: Invalid request parameters (`storage.triggers.missingParam`), or invalid `runWithTokenId` (`storage.triggers.invalidTokenPair`, `storage.triggers.invalidRunByToken`).
- `422`: Cool down period shorter than 1 minute (`storage.triggers.missingParam`), table from an external bucket (`storage.triggers.triggerOnTableFromExternalBucket`), insufficient privilege for the component (`storage.triggers.insufficientPrivilege`), or no `runWithTokenId` and your token may not create the token the trigger runs with (`storage.triggers.runWithTokenNotCreatable`).

---

[API](https://skmtc.dev/keboola/apis/keboola-storage-api.md) - [All operations](https://skmtc.dev/keboola/apis/keboola-storage-api/llms.txt) - [OpenAPI document](https://skmtc.dev/keboola/apis/keboola-storage-api/revisions/34b5ceac0317?raw)
