Skip to content
Start here

Send event to instance

client.workflows.instances.events.create(stringeventType, EventCreateParams { account_id, workflow_name, instance_id, body } params, RequestOptionsoptions?): EventCreateResponse { instanceId, timestamp }
POST/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}

Sends an event to a running workflow instance to trigger state transitions.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Workers Scripts Write
ParametersExpand Collapse
eventType: string
maxLength100
minLength1
params: EventCreateParams { account_id, workflow_name, instance_id, body }
account_id: string

Path param

workflow_name: string

Path param

maxLength64
minLength1
instance_id: string

Path param: Instance identifier. User-created instances match ^[a-zA-Z0-9_][a-zA-Z0-9-_]*$ (max 100 characters); cron-triggered instances can use a longer, system-generated id derived from the cron expression.

maxLength271
minLength1
body: unknown

Body param

ReturnsExpand Collapse
EventCreateResponse { instanceId, timestamp }
instanceId: string
timestamp: string

Accepts ISO 8601 with no timezone offsets and in UTC.

formatdate-time

Send event to instance

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const event = await client.workflows.instances.events.create('x', {
  account_id: 'account_id',
  workflow_name: 'x',
  instance_id: 'x',
  body: {},
});

console.log(event.instanceId);
{
  "errors": [],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "instanceId": "instanceId",
    "timestamp": "2019-12-27T18:11:19.117Z"
  },
  "success": true,
  "result_info": {
    "count": 0,
    "per_page": 0,
    "total_count": 0,
    "cursor": "cursor",
    "page": 0,
    "total_pages": 0
  }
}
Returns Examples
{
  "errors": [],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "instanceId": "instanceId",
    "timestamp": "2019-12-27T18:11:19.117Z"
  },
  "success": true,
  "result_info": {
    "count": 0,
    "per_page": 0,
    "total_count": 0,
    "cursor": "cursor",
    "page": 0,
    "total_pages": 0
  }
}