---
title: Create a new workflow instance
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[Workflows](https://developers.cloudflare.com/api/go/resources/workflows)

[Instances](https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Create a new workflow instance

client.Workflows.Instances.New(ctx, workflowName, params) (\*[InstanceNewResponse](<https://developers.cloudflare.com/api/go/resources/workflows#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)>), error)

POST/accounts/{account\_id}/workflows/{workflow\_name}/instances

Creates a new instance of a workflow, starting its execution.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



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

**Example:**<code>X-Auth-Email: user@example.com</code>

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

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Workers Scripts Write`

##### ParametersExpand Collapse

workflowName string

maxLength64

minLength1

[Link to this property](<#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20workflow_name%20%3E%20(schema)>)

<details>

<summary>

params InstanceNewParams

</summary>

AccountID param.Field\[string]

Path param

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

InstanceID param.Field\[string]Optional

Body param: The system reserves IDs that consist of the <code>cf_</code> prefix and exactly 64 lowercase hexadecimal characters.

maximum100

minimum1

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_id">Link to this property</a>

<details>

<summary>

InstanceRetention param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention%20%3E%20(schema)">InstanceNewParamsInstanceRetention</a>]Optional

Body param

</summary>

<details>

<summary>

ErrorRetention InstanceNewParamsInstanceRetentionErrorRetentionUnionOptional

Specifies the duration in milliseconds or as a string like ‘5 minutes’.

</summary>

One of the following:

UnionInt

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention%20%3E%20(schema)%20%3E%20(property)%20error_retention%20%3E%20(variant)%200">Link to this property</a>

UnionString

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention%20%3E%20(schema)%20%3E%20(property)%20error_retention%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention%20%3E%20(schema)%20%3E%20(property)%20error_retention">Link to this property</a>

<details>

<summary>

SuccessRetention InstanceNewParamsInstanceRetentionSuccessRetentionUnionOptional

Specifies the duration in milliseconds or as a string like ‘5 minutes’.

</summary>

One of the following:

UnionInt

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention%20%3E%20(schema)%20%3E%20(property)%20success_retention%20%3E%20(variant)%200">Link to this property</a>

UnionString

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention%20%3E%20(schema)%20%3E%20(property)%20success_retention%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention%20%3E%20(schema)%20%3E%20(property)%20success_retention">Link to this property</a>

</details>

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20instance_retention">Link to this property</a>

<details>

<summary>

LocationHint param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a>]Optional

Body param

</summary>

const InstanceNewParamsLocationHintWnam <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "wnam"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const InstanceNewParamsLocationHintWeur <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "weur"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const InstanceNewParamsLocationHintEnam <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "enam"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

const InstanceNewParamsLocationHintEeur <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "eeur"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%203">Link to this property</a>

const InstanceNewParamsLocationHintApac <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "apac"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%204">Link to this property</a>

const InstanceNewParamsLocationHintApacNe <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "apac-ne"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%205">Link to this property</a>

const InstanceNewParamsLocationHintApacSe <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "apac-se"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%206">Link to this property</a>

const InstanceNewParamsLocationHintOc <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "oc"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%207">Link to this property</a>

const InstanceNewParamsLocationHintSam <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "sam"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%208">Link to this property</a>

const InstanceNewParamsLocationHintAfr <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "afr"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%209">Link to this property</a>

const InstanceNewParamsLocationHintMe <a href="https://developers.cloudflare.com/api/go/resources/workflows/subresources/instances/methods/create#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)">InstanceNewParamsLocationHint</a> = "me"

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint%20%3E%20(schema)%20%3E%20(member)%2010">Link to this property</a>

</details>

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20location_hint">Link to this property</a>

Params param.Field\[string]Optional

Body param: JSON-encoded event payload passed into the new instance.

<a href="#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20params">Link to this property</a>

</details>

[Link to this property](<#(resource)%20workflows.instances%20%3E%20(method)%20create%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type InstanceNewResponse struct{…}

</summary>

ID string

maxLength100

minLength1

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

<details>

<summary>

Status InstanceNewResponseStatus

</summary>

One of the following:

const InstanceNewResponseStatusQueued InstanceNewResponseStatus = "queued"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%200">Link to this property</a>

const InstanceNewResponseStatusRunning InstanceNewResponseStatus = "running"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%201">Link to this property</a>

const InstanceNewResponseStatusPaused InstanceNewResponseStatus = "paused"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%202">Link to this property</a>

const InstanceNewResponseStatusErrored InstanceNewResponseStatus = "errored"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%203">Link to this property</a>

const InstanceNewResponseStatusTerminated InstanceNewResponseStatus = "terminated"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%204">Link to this property</a>

const InstanceNewResponseStatusComplete InstanceNewResponseStatus = "complete"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%205">Link to this property</a>

const InstanceNewResponseStatusWaitingForPause InstanceNewResponseStatus = "waitingForPause"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%206">Link to this property</a>

const InstanceNewResponseStatusWaiting InstanceNewResponseStatus = "waiting"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%207">Link to this property</a>

const InstanceNewResponseStatusRollingBack InstanceNewResponseStatus = "rollingBack"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%208">Link to this property</a>

</details>

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20status">Link to this property</a>

VersionID string

formatuuid

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20version_id">Link to this property</a>

WorkflowID string

formatuuid

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20workflow_id">Link to this property</a>

<details>

<summary>

TriggerSource InstanceNewResponseTriggerSourceOptional

</summary>

One of the following:

const InstanceNewResponseTriggerSourceUnknown InstanceNewResponseTriggerSource = "unknown"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20trigger_source%20%3E%20(member)%200">Link to this property</a>

const InstanceNewResponseTriggerSourceAPI InstanceNewResponseTriggerSource = "api"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20trigger_source%20%3E%20(member)%201">Link to this property</a>

const InstanceNewResponseTriggerSourceBinding InstanceNewResponseTriggerSource = "binding"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20trigger_source%20%3E%20(member)%202">Link to this property</a>

const InstanceNewResponseTriggerSourceEvent InstanceNewResponseTriggerSource = "event"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20trigger_source%20%3E%20(member)%203">Link to this property</a>

const InstanceNewResponseTriggerSourceCron InstanceNewResponseTriggerSource = "cron"

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20trigger_source%20%3E%20(member)%204">Link to this property</a>

</details>

<a href="#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)%20%3E%20(property)%20trigger_source">Link to this property</a>

</details>

[Link to this property](<#(resource)%20workflows.instances%20%3E%20(model)%20InstanceNewResponse%20%3E%20(schema)>)

### Create a new workflow instance

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/workflows"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  instance, err := client.Workflows.Instances.New(
    context.TODO(),
    "x",
    workflows.InstanceNewParams{
      AccountID: cloudflare.F("account_id"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", instance.ID)
}
```

200 example

```
{
  "errors": [],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "id": "x",
    "status": "queued",
    "version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "trigger_source": "unknown"
  },
  "success": true,
  "result_info": {
    "count": 0,
    "per_page": 0,
    "total_count": 0,
    "cursor": "cursor",
    "page": 0,
    "total_pages": 0
  }
}
```

##### Returns Examples

200 example

```
{
  "errors": [],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "id": "x",
    "status": "queued",
    "version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "trigger_source": "unknown"
  },
  "success": true,
  "result_info": {
    "count": 0,
    "per_page": 0,
    "total_count": 0,
    "cursor": "cursor",
    "page": 0,
    "total_pages": 0
  }
}
```