---
title: Create Event Subscription
---

[Skip to content](#_top)

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

[Queues](https://developers.cloudflare.com/api/go/resources/queues)

[Subscriptions](https://developers.cloudflare.com/api/go/resources/queues/subresources/subscriptions)

Copy Markdown

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

---

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

# Create Event Subscription

client.Queues.Subscriptions.New(ctx, params) (\*[SubscriptionNewResponse](<https://developers.cloudflare.com/api/go/resources/queues#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)>), error)

POST/accounts/{account\_id}/event\_subscriptions/subscriptions

Creates an event subscription for a Queue.

##### 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)

`Queues Write``Workers Scripts Write`

##### ParametersExpand Collapse

<details>

<summary>

params SubscriptionNewParams

</summary>

AccountID param.Field\[string]

Path param: A Resource identifier.

maxLength32

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

<details>

<summary>

Destination param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/queues/subresources/subscriptions/methods/create#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20destination%20%3E%20(schema)">SubscriptionNewParamsDestination</a>]Optional

Body param: Destination configuration for the subscription

</summary>

QueueID string

ID of the target queue

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20destination%20%3E%20(schema)%20%3E%20(property)%20queue_id">Link to this property</a>

Type SubscriptionNewParamsDestinationType

Type of destination

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20destination%20%3E%20(schema)%20%3E%20(property)%20type">Link to this property</a>

</details>

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

Enabled param.Field\[bool]Optional

Body param: Whether the subscription is active

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

Events param.Field\[\[]string]Optional

Body param: List of event types this subscription handles

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

Name param.Field\[string]Optional

Body param: Name of the subscription

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

<details>

<summary>

Source param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/queues/subresources/subscriptions/methods/create#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)">SubscriptionNewParamsSource</a>]Optional

Body param: Source configuration for the subscription

</summary>

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceImages struct{…}

</summary>

Type SubscriptionNewParamsSourceMqEventSourceImagesTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20type">Link to this property</a>

</details>

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

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceKV struct{…}

</summary>

Type SubscriptionNewParamsSourceMqEventSourceKVTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20type">Link to this property</a>

</details>

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

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceR2 struct{…}

</summary>

Type SubscriptionNewParamsSourceMqEventSourceR2TypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%202%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%202">Link to this property</a>

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceSuperSlurper struct{…}

</summary>

Type SubscriptionNewParamsSourceMqEventSourceSuperSlurperTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%203%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%203">Link to this property</a>

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceVectorize struct{…}

</summary>

Type SubscriptionNewParamsSourceMqEventSourceVectorizeTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%204%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%204">Link to this property</a>

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceWorkersAIModel struct{…}

</summary>

ModelName stringOptional

Name of the Workers AI model

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20model_name">Link to this property</a>

Type SubscriptionNewParamsSourceMqEventSourceWorkersAIModelTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%205">Link to this property</a>

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceWorkersBuildsWorker struct{…}

</summary>

Type SubscriptionNewParamsSourceMqEventSourceWorkersBuildsWorkerTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%206%20%3E%20(property)%20type">Link to this property</a>

WorkerName stringOptional

Name of the worker

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%206%20%3E%20(property)%20worker_name">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%206">Link to this property</a>

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceWorkersScript struct{…}

</summary>

ScriptTag stringOptional

Tag of the Worker script

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20script_tag">Link to this property</a>

Type SubscriptionNewParamsSourceMqEventSourceWorkersScriptTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%207">Link to this property</a>

<details>

<summary>

type SubscriptionNewParamsSourceMqEventSourceWorkflowsWorkflow struct{…}

</summary>

Type SubscriptionNewParamsSourceMqEventSourceWorkflowsWorkflowTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20type">Link to this property</a>

WorkflowName stringOptional

Name of the workflow

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20workflow_name">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20source%20%3E%20(schema)%20%3E%20(variant)%208">Link to this property</a>

</details>

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

</details>

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

##### ReturnsExpand Collapse

<details>

<summary>

type SubscriptionNewResponse struct{…}

</summary>

ID string

Unique identifier for the subscription

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

CreatedAt Time

When the subscription was created

formatdate-time

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

<details>

<summary>

Destination SubscriptionNewResponseDestination

Destination configuration for the subscription

</summary>

QueueID string

ID of the target queue

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20destination%20%3E%20(property)%20queue_id">Link to this property</a>

Type SubscriptionNewResponseDestinationType

Type of destination

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20destination%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20destination">Link to this property</a>

Enabled bool

Whether the subscription is active

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

Events \[]string

List of event types this subscription handles

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20events">Link to this property</a>

ModifiedAt Time

When the subscription was last modified

formatdate-time

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

Name string

Name of the subscription

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

Source SubscriptionNewResponseSource

Source configuration for the subscription

</summary>

One of the following:

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceImages struct{…}

</summary>

Type SubscriptionNewResponseSourceMqEventSourceImagesTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%200%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceKV struct{…}

</summary>

Type SubscriptionNewResponseSourceMqEventSourceKVTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%201%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%201">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceR2 struct{…}

</summary>

Type SubscriptionNewResponseSourceMqEventSourceR2TypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%202%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%202">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceSuperSlurper struct{…}

</summary>

Type SubscriptionNewResponseSourceMqEventSourceSuperSlurperTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%203%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%203">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceVectorize struct{…}

</summary>

Type SubscriptionNewResponseSourceMqEventSourceVectorizeTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%204%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%204">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceWorkersAIModel struct{…}

</summary>

ModelName stringOptional

Name of the Workers AI model

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%205%20%3E%20(property)%20model_name">Link to this property</a>

Type SubscriptionNewResponseSourceMqEventSourceWorkersAIModelTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%205%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%205">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceWorkersBuildsWorker struct{…}

</summary>

Type SubscriptionNewResponseSourceMqEventSourceWorkersBuildsWorkerTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%206%20%3E%20(property)%20type">Link to this property</a>

WorkerName stringOptional

Name of the worker

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%206%20%3E%20(property)%20worker_name">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%206">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceWorkersScript struct{…}

</summary>

ScriptTag stringOptional

Tag of the Worker script

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%207%20%3E%20(property)%20script_tag">Link to this property</a>

Type SubscriptionNewResponseSourceMqEventSourceWorkersScriptTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%207%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%207">Link to this property</a>

<details>

<summary>

type SubscriptionNewResponseSourceMqEventSourceWorkflowsWorkflow struct{…}

</summary>

Type SubscriptionNewResponseSourceMqEventSourceWorkflowsWorkflowTypeOptional

Type of source

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%208%20%3E%20(property)%20type">Link to this property</a>

WorkflowName stringOptional

Name of the workflow

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%208%20%3E%20(property)%20workflow_name">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(variant)%208">Link to this property</a>

</details>

<a href="#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)%20%3E%20(property)%20source">Link to this property</a>

</details>

[Link to this property](<#(resource)%20queues.subscriptions%20%3E%20(model)%20SubscriptionNewResponse%20%3E%20(schema)>)

### Create Event Subscription

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  subscription, err := client.Queues.Subscriptions.New(context.TODO(), queues.SubscriptionNewParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", subscription.ID)
}
```

200 example

```
{
  "errors": [
    {
      "code": 7003,
      "message": "No route for the URI",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "id": "id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "destination": {
      "queue_id": "queue_id",
      "type": "queues.queue"
    },
    "enabled": true,
    "events": [
      "string"
    ],
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "source": {
      "type": "images"
    }
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 7003,
      "message": "No route for the URI",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "id": "id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "destination": {
      "queue_id": "queue_id",
      "type": "queues.queue"
    },
    "enabled": true,
    "events": [
      "string"
    ],
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "source": {
      "type": "images"
    }
  },
  "success": true
}
```