## Create Event Subscription `client.queues.subscriptions.create(SubscriptionCreateParamsparams, RequestOptionsoptions?): SubscriptionCreateResponse` **post** `/accounts/{account_id}/event_subscriptions/subscriptions` Create a new event subscription for a queue ### Parameters - `params: SubscriptionCreateParams` - `account_id: string` Path param: A Resource identifier. - `destination?: Destination` Body param: Destination configuration for the subscription - `queue_id: string` ID of the target queue - `type: "queues.queue"` Type of destination - `"queues.queue"` - `enabled?: boolean` Body param: Whether the subscription is active - `events?: Array` Body param: List of event types this subscription handles - `name?: string` Body param: Name of the subscription - `source?: MqEventSourceImages | MqEventSourceKV | MqEventSourceR2 | 5 more` Body param: Source configuration for the subscription - `MqEventSourceImages` - `type?: "images"` Type of source - `"images"` - `MqEventSourceKV` - `type?: "kv"` Type of source - `"kv"` - `MqEventSourceR2` - `type?: "r2"` Type of source - `"r2"` - `MqEventSourceSuperSlurper` - `type?: "superSlurper"` Type of source - `"superSlurper"` - `MqEventSourceVectorize` - `type?: "vectorize"` Type of source - `"vectorize"` - `MqEventSourceWorkersAIModel` - `model_name?: string` Name of the Workers AI model - `type?: "workersAi.model"` Type of source - `"workersAi.model"` - `MqEventSourceWorkersBuildsWorker` - `type?: "workersBuilds.worker"` Type of source - `"workersBuilds.worker"` - `worker_name?: string` Name of the worker - `MqEventSourceWorkflowsWorkflow` - `type?: "workflows.workflow"` Type of source - `"workflows.workflow"` - `workflow_name?: string` Name of the workflow ### Returns - `SubscriptionCreateResponse` - `id: string` Unique identifier for the subscription - `created_at: string` When the subscription was created - `destination: Destination` Destination configuration for the subscription - `queue_id: string` ID of the target queue - `type: "queues.queue"` Type of destination - `"queues.queue"` - `enabled: boolean` Whether the subscription is active - `events: Array` List of event types this subscription handles - `modified_at: string` When the subscription was last modified - `name: string` Name of the subscription - `source: MqEventSourceImages | MqEventSourceKV | MqEventSourceR2 | 5 more` Source configuration for the subscription - `MqEventSourceImages` - `type?: "images"` Type of source - `"images"` - `MqEventSourceKV` - `type?: "kv"` Type of source - `"kv"` - `MqEventSourceR2` - `type?: "r2"` Type of source - `"r2"` - `MqEventSourceSuperSlurper` - `type?: "superSlurper"` Type of source - `"superSlurper"` - `MqEventSourceVectorize` - `type?: "vectorize"` Type of source - `"vectorize"` - `MqEventSourceWorkersAIModel` - `model_name?: string` Name of the Workers AI model - `type?: "workersAi.model"` Type of source - `"workersAi.model"` - `MqEventSourceWorkersBuildsWorker` - `type?: "workersBuilds.worker"` Type of source - `"workersBuilds.worker"` - `worker_name?: string` Name of the worker - `MqEventSourceWorkflowsWorkflow` - `type?: "workflows.workflow"` Type of source - `"workflows.workflow"` - `workflow_name?: string` Name of the workflow ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subscription = await client.queues.subscriptions.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 } ```