pydo.functions.create_trigger()

Generated on 8 May 2026 from pydo version v0.34.0

Usage

client.functions.create_trigger(
    namespace_id="fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    body={
        "name": "my trigger",
        "function": "hello",
        "type": "SCHEDULED",
        ...,
    },
)
Returns JSONRaises HttpResponseError

Description

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.

Parameters

namespace_id string required

The ID of the namespace to be managed.

name string required

Example: my trigger

The trigger's unique name within the namespace.

function string required

Example: hello

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

type string required

Example: SCHEDULED

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

is_enabled boolean required

Example: True

Indicates weather the trigger is paused or unpaused.

scheduled_details object required

Trigger details for SCHEDULED type, where body is optional.

Show child properties
cron string required

Example: * * * * *

valid cron expression string which is required for SCHEDULED type triggers.

body object or null optional

Optional data to be sent to function while triggering the function.

Show child properties
name string optional

Example: Welcome to DO!

Request Sample

Show Request Sample
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

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

resp = client.functions.create_trigger(namespace_id="aff93af3", body=req)

Response Example

Show Response Example
{
  "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": "* * * * *"
    },
    "scheduled_runs": {
      "last_run_at": "2022-11-11T04:16:45Z",
      "next_run_at": "2022-11-11T04:16:45Z"
    }
  }
}

More Information

See /v2/functions/namespaces/{namespace_id}/triggers in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.