---
title: "Create Trigger"
method: POST
path: "/v2/functions/namespaces/{namespace_id}/triggers"
tags: ["DigitalOcean-public.v2-new_Functions"]
---

# Create Trigger

`POST /v2/functions/namespaces/{namespace_id}/triggers`

Creates a new trigger for a given function in a namespace. To create a trigger, send a POST request to `/v2/functions/namespaces/$NAMESPACE_ID/triggers` with the `name`, `function`, `type`, `is_enabled` and `scheduled_details` properties.

## Path parameters

- `namespace_id` string, required

## Request body

- CreateTrigger
  - `name` string, required — The trigger's unique name within the namespace.
  - `function` string, required — Name of function(action) that exists in the given namespace.
  - `type` string, required — One of different type of triggers. Currently only SCHEDULED is supported.
  - `is_enabled` boolean, required — Indicates weather the trigger is paused or unpaused.
  - `scheduled_details` ScheduledDetails, required — Trigger details for SCHEDULED type, where body is optional.
    - `cron` string, required — valid cron expression string which is required for SCHEDULED type triggers.
    - `body` object, nullable — Optional data to be sent to function while triggering the function.
      - `name` string

## Response `200`

A JSON response object with a key called `trigger`. The object contains the properties associated
with the trigger.

- object
  - `trigger` TriggerInfo
    - `namespace` string — A unique string format of UUID with a prefix fn-.
    - `name` string — The trigger's unique name within the namespace.
    - `function` string — Name of function(action) that exists in the given namespace.
    - `type` string — String which indicates the type of trigger source like SCHEDULED.
    - `is_enabled` boolean — Indicates weather the trigger is paused or unpaused.
    - `created_at` string — UTC time string.
    - `updated_at` string — UTC time string.
    - `scheduled_details` ScheduledDetails — Trigger details for SCHEDULED type, where body is optional.
      - `cron` string, required — valid cron expression string which is required for SCHEDULED type triggers.
      - `body` object, nullable — Optional data to be sent to function while triggering the function.
        - `name` string
    - `scheduled_runs` object
      - `last_run_at` string, nullable — Indicates last run time. null value indicates trigger not run yet.
      - `next_run_at` string, nullable — Indicates next run time. null value indicates trigger will not run.

## Other responses

- `400` — Bad Request.
- `401` — Authentication failed due to invalid credentials.
- `404` — Bad Request.
- `422` — Limit Reached
- `429` — The API rate limit has been exceeded.
- `500` — There was a server error.
- `default` — There was an unexpected error.

---

[API](https://skmtc.net/digitalocean/apis/digitalocean-api.md) · [All operations](https://skmtc.net/digitalocean/apis/digitalocean-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/digitalocean/digitalocean-api/versions/cb3bf9b21459/schema)
