## Create Event Subscription `client.Queues.Subscriptions.New(ctx, params) (*SubscriptionNewResponse, error)` **post** `/accounts/{account_id}/event_subscriptions/subscriptions` Create a new event subscription for a queue ### Parameters - `params SubscriptionNewParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `Destination param.Field[SubscriptionNewParamsDestination]` Body param: Destination configuration for the subscription - `QueueID string` ID of the target queue - `Type SubscriptionNewParamsDestinationType` Type of destination - `const SubscriptionNewParamsDestinationTypeQueuesQueue SubscriptionNewParamsDestinationType = "queues.queue"` - `Enabled param.Field[bool]` Body param: Whether the subscription is active - `Events param.Field[[]string]` Body param: List of event types this subscription handles - `Name param.Field[string]` Body param: Name of the subscription - `Source param.Field[SubscriptionNewParamsSource]` Body param: Source configuration for the subscription - `type SubscriptionNewParamsSourceMqEventSourceImages struct{…}` - `Type SubscriptionNewParamsSourceMqEventSourceImagesType` Type of source - `const SubscriptionNewParamsSourceMqEventSourceImagesTypeImages SubscriptionNewParamsSourceMqEventSourceImagesType = "images"` - `type SubscriptionNewParamsSourceMqEventSourceKV struct{…}` - `Type SubscriptionNewParamsSourceMqEventSourceKVType` Type of source - `const SubscriptionNewParamsSourceMqEventSourceKVTypeKV SubscriptionNewParamsSourceMqEventSourceKVType = "kv"` - `type SubscriptionNewParamsSourceMqEventSourceR2 struct{…}` - `Type SubscriptionNewParamsSourceMqEventSourceR2Type` Type of source - `const SubscriptionNewParamsSourceMqEventSourceR2TypeR2 SubscriptionNewParamsSourceMqEventSourceR2Type = "r2"` - `type SubscriptionNewParamsSourceMqEventSourceSuperSlurper struct{…}` - `Type SubscriptionNewParamsSourceMqEventSourceSuperSlurperType` Type of source - `const SubscriptionNewParamsSourceMqEventSourceSuperSlurperTypeSuperSlurper SubscriptionNewParamsSourceMqEventSourceSuperSlurperType = "superSlurper"` - `type SubscriptionNewParamsSourceMqEventSourceVectorize struct{…}` - `Type SubscriptionNewParamsSourceMqEventSourceVectorizeType` Type of source - `const SubscriptionNewParamsSourceMqEventSourceVectorizeTypeVectorize SubscriptionNewParamsSourceMqEventSourceVectorizeType = "vectorize"` - `type SubscriptionNewParamsSourceMqEventSourceWorkersAIModel struct{…}` - `ModelName string` Name of the Workers AI model - `Type SubscriptionNewParamsSourceMqEventSourceWorkersAIModelType` Type of source - `const SubscriptionNewParamsSourceMqEventSourceWorkersAIModelTypeWorkersAIModel SubscriptionNewParamsSourceMqEventSourceWorkersAIModelType = "workersAi.model"` - `type SubscriptionNewParamsSourceMqEventSourceWorkersBuildsWorker struct{…}` - `Type SubscriptionNewParamsSourceMqEventSourceWorkersBuildsWorkerType` Type of source - `const SubscriptionNewParamsSourceMqEventSourceWorkersBuildsWorkerTypeWorkersBuildsWorker SubscriptionNewParamsSourceMqEventSourceWorkersBuildsWorkerType = "workersBuilds.worker"` - `WorkerName string` Name of the worker - `type SubscriptionNewParamsSourceMqEventSourceWorkflowsWorkflow struct{…}` - `Type SubscriptionNewParamsSourceMqEventSourceWorkflowsWorkflowType` Type of source - `const SubscriptionNewParamsSourceMqEventSourceWorkflowsWorkflowTypeWorkflowsWorkflow SubscriptionNewParamsSourceMqEventSourceWorkflowsWorkflowType = "workflows.workflow"` - `WorkflowName string` Name of the workflow ### Returns - `type SubscriptionNewResponse struct{…}` - `ID string` Unique identifier for the subscription - `CreatedAt Time` When the subscription was created - `Destination SubscriptionNewResponseDestination` Destination configuration for the subscription - `QueueID string` ID of the target queue - `Type SubscriptionNewResponseDestinationType` Type of destination - `const SubscriptionNewResponseDestinationTypeQueuesQueue SubscriptionNewResponseDestinationType = "queues.queue"` - `Enabled bool` Whether the subscription is active - `Events []string` List of event types this subscription handles - `ModifiedAt Time` When the subscription was last modified - `Name string` Name of the subscription - `Source SubscriptionNewResponseSource` Source configuration for the subscription - `type SubscriptionNewResponseSourceMqEventSourceImages struct{…}` - `Type SubscriptionNewResponseSourceMqEventSourceImagesType` Type of source - `const SubscriptionNewResponseSourceMqEventSourceImagesTypeImages SubscriptionNewResponseSourceMqEventSourceImagesType = "images"` - `type SubscriptionNewResponseSourceMqEventSourceKV struct{…}` - `Type SubscriptionNewResponseSourceMqEventSourceKVType` Type of source - `const SubscriptionNewResponseSourceMqEventSourceKVTypeKV SubscriptionNewResponseSourceMqEventSourceKVType = "kv"` - `type SubscriptionNewResponseSourceMqEventSourceR2 struct{…}` - `Type SubscriptionNewResponseSourceMqEventSourceR2Type` Type of source - `const SubscriptionNewResponseSourceMqEventSourceR2TypeR2 SubscriptionNewResponseSourceMqEventSourceR2Type = "r2"` - `type SubscriptionNewResponseSourceMqEventSourceSuperSlurper struct{…}` - `Type SubscriptionNewResponseSourceMqEventSourceSuperSlurperType` Type of source - `const SubscriptionNewResponseSourceMqEventSourceSuperSlurperTypeSuperSlurper SubscriptionNewResponseSourceMqEventSourceSuperSlurperType = "superSlurper"` - `type SubscriptionNewResponseSourceMqEventSourceVectorize struct{…}` - `Type SubscriptionNewResponseSourceMqEventSourceVectorizeType` Type of source - `const SubscriptionNewResponseSourceMqEventSourceVectorizeTypeVectorize SubscriptionNewResponseSourceMqEventSourceVectorizeType = "vectorize"` - `type SubscriptionNewResponseSourceMqEventSourceWorkersAIModel struct{…}` - `ModelName string` Name of the Workers AI model - `Type SubscriptionNewResponseSourceMqEventSourceWorkersAIModelType` Type of source - `const SubscriptionNewResponseSourceMqEventSourceWorkersAIModelTypeWorkersAIModel SubscriptionNewResponseSourceMqEventSourceWorkersAIModelType = "workersAi.model"` - `type SubscriptionNewResponseSourceMqEventSourceWorkersBuildsWorker struct{…}` - `Type SubscriptionNewResponseSourceMqEventSourceWorkersBuildsWorkerType` Type of source - `const SubscriptionNewResponseSourceMqEventSourceWorkersBuildsWorkerTypeWorkersBuildsWorker SubscriptionNewResponseSourceMqEventSourceWorkersBuildsWorkerType = "workersBuilds.worker"` - `WorkerName string` Name of the worker - `type SubscriptionNewResponseSourceMqEventSourceWorkflowsWorkflow struct{…}` - `Type SubscriptionNewResponseSourceMqEventSourceWorkflowsWorkflowType` Type of source - `const SubscriptionNewResponseSourceMqEventSourceWorkflowsWorkflowTypeWorkflowsWorkflow SubscriptionNewResponseSourceMqEventSourceWorkflowsWorkflowType = "workflows.workflow"` - `WorkflowName string` Name of the workflow ### Example ```go 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) } ``` #### Response ```json { "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 } ```