---
title: "Create trigger"
method: POST
path: "/api/v1/functions/{function_id}/triggers"
tags: ["Functions"]
---

# Create trigger

`POST /api/v1/functions/{function_id}/triggers`

Schedule or subscribe the function. `cron` uses a 5-field expression
with an optional IANA `timezone`; `once` fires a single time at
`run_at`; `s3` fires on Object Storage bucket events (optionally
filtered by key prefix/suffix). Deliveries are signed CloudEvents
(HMAC `X-Raff-Signature`) with 3 retry attempts. Triggers are free.

## Path parameters

- `function_id` string, required

## Request body

- CreateFunctionTriggerRequest
  - `trigger_type` 'cron' | 'once' | 's3', required
  - `cron_expression` string — 5-field cron (required for `cron`)
  - `timezone` string — IANA name, default UTC
  - `run_at` string, date-time — Required for `once`
  - `payload_json` string — JSON merged into the CloudEvent data (cron/once)
  - `bucket_id` string, uuid — Required for `s3` — an Object Storage bucket you own
  - `s3_events` string[] — Default s3:ObjectCreated:*; also s3:ObjectRemoved:*
  - `key_prefix` string — Only objects whose key starts with this fire the trigger
  - `key_suffix` string — Only objects whose key ends with this fire the trigger

## Response `201`

Trigger created

- object
  - `success` boolean
  - `data` object
    - `trigger` FunctionTrigger
      - `id` string, uuid
      - `trigger_type` 'cron' | 'once' | 's3'
      - `enabled` boolean
      - `cron_expression` string
      - `timezone` string
      - `run_at` string, date-time
      - `next_run_at` string, date-time
      - `payload_json` string
      - `bucket_id` string, uuid — Source bucket (`s3` type)
      - `s3_events` string[] — Subscribed events, e.g. s3:ObjectCreated:*, s3:ObjectRemoved:*
      - `key_prefix` string
      - `key_suffix` string
      - `last_run_at` string, date-time
      - `last_status` 'ok' | 'failed' | ''
      - `created_at` string, date-time

## Other responses

- `400` — Invalid request parameters
- `401` — Authentication required

---

[API](https://skmtc.dev/rafftechnologies/apis/raff-api.md) · [All operations](https://skmtc.dev/rafftechnologies/apis/raff-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/rafftechnologies/raff-api/revisions/2f4df56be77c/schema)
