v8

latestOpenAPI 3.0.0Apache 2.0raw.githubusercontent.com2025-10-165266542.4 MB
DigitalOcean-public.v2-new_Functions

Create Trigger

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.

post/v2/functions/namespaces/{namespace_id}/triggers

Path parameters

namespace_idstring required

The ID of the namespace to be managed.

Request body

namestring required

The trigger's unique name within the namespace.

functionstring required

Name of function(action) that exists in the given namespace.

typestring required

One of different type of triggers. Currently only SCHEDULED is supported.

is_enabledboolean required

Indicates weather the trigger is paused or unpaused.

Example request

{
  "name": "my trigger",
  "function": "hello",
  "type": "SCHEDULED",
  "is_enabled": true,
  "scheduled_details": {
    "cron": "* * * * *",
    "body": {
      "name": "Welcome to DO!"
    }
  }
}

Response

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

Example response

{
  "trigger": {
    "namespace": "fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "name": "my trigger",
    "function": "hello",
    "type": "SCHEDULED",
    "is_enabled": true,
    "created_at": "2022-11-11T04:16:45Z",
    "updated_at": "2022-11-11T04:16:45Z",
    "scheduled_details": {
      "cron": "* * * * *",
      "body": {
        "name": "Welcome to DO!"
      }
    },
    "scheduled_runs": {
      "last_run_at": "2022-11-11T04:16:45Z",
      "next_run_at": "2022-11-11T04:16:45Z"
    }
  }
}