# Queues ## List Queues `client.Queues.List(ctx, query) (*SinglePage[Queue], error)` **get** `/accounts/{account_id}/queues` Returns the queues owned by an account. ### Parameters - `query QueueListParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type Queue struct{…}` - `Consumers []Consumer` - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` - `ConsumersTotalCount float64` - `CreatedOn string` - `ModifiedOn string` - `Producers []QueueProducer` - `type QueueProducersMqWorkerProducer struct{…}` - `Script string` - `Type QueueProducersMqWorkerProducerType` - `const QueueProducersMqWorkerProducerTypeWorker QueueProducersMqWorkerProducerType = "worker"` - `type QueueProducersMqR2Producer struct{…}` - `BucketName string` - `Type QueueProducersMqR2ProducerType` - `const QueueProducersMqR2ProducerTypeR2Bucket QueueProducersMqR2ProducerType = "r2_bucket"` - `ProducersTotalCount float64` - `QueueID string` - `QueueName string` - `Settings QueueSettings` - `DeliveryDelay float64` Number of seconds to delay delivery of all messages to consumers. - `DeliveryPaused bool` Indicates if message delivery to consumers is currently paused. - `MessageRetentionPeriod float64` Number of seconds after which an unconsumed message will be delayed. ### 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"), ) page, err := client.Queues.List(context.TODO(), queues.QueueListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": [ { "consumers": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "consumers_total_count": 0, "created_on": "created_on", "modified_on": "modified_on", "producers": [ { "script": "script", "type": "worker" } ], "producers_total_count": 0, "queue_id": "queue_id", "queue_name": "example-queue", "settings": { "delivery_delay": 5, "delivery_paused": true, "message_retention_period": 345600 } } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 }, "success": true } ``` ## Get Queue `client.Queues.Get(ctx, queueID, query) (*Queue, error)` **get** `/accounts/{account_id}/queues/{queue_id}` Get details about a specific queue. ### Parameters - `queueID string` A Resource identifier. - `query QueueGetParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type Queue struct{…}` - `Consumers []Consumer` - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` - `ConsumersTotalCount float64` - `CreatedOn string` - `ModifiedOn string` - `Producers []QueueProducer` - `type QueueProducersMqWorkerProducer struct{…}` - `Script string` - `Type QueueProducersMqWorkerProducerType` - `const QueueProducersMqWorkerProducerTypeWorker QueueProducersMqWorkerProducerType = "worker"` - `type QueueProducersMqR2Producer struct{…}` - `BucketName string` - `Type QueueProducersMqR2ProducerType` - `const QueueProducersMqR2ProducerTypeR2Bucket QueueProducersMqR2ProducerType = "r2_bucket"` - `ProducersTotalCount float64` - `QueueID string` - `QueueName string` - `Settings QueueSettings` - `DeliveryDelay float64` Number of seconds to delay delivery of all messages to consumers. - `DeliveryPaused bool` Indicates if message delivery to consumers is currently paused. - `MessageRetentionPeriod float64` Number of seconds after which an unconsumed message will be delayed. ### 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"), ) queue, err := client.Queues.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.QueueGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", queue.QueueID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumers": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "consumers_total_count": 0, "created_on": "created_on", "modified_on": "modified_on", "producers": [ { "script": "script", "type": "worker" } ], "producers_total_count": 0, "queue_id": "queue_id", "queue_name": "example-queue", "settings": { "delivery_delay": 5, "delivery_paused": true, "message_retention_period": 345600 } }, "success": true } ``` ## Create Queue `client.Queues.New(ctx, params) (*Queue, error)` **post** `/accounts/{account_id}/queues` Create a new queue ### Parameters - `params QueueNewParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `QueueName param.Field[string]` Body param ### Returns - `type Queue struct{…}` - `Consumers []Consumer` - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` - `ConsumersTotalCount float64` - `CreatedOn string` - `ModifiedOn string` - `Producers []QueueProducer` - `type QueueProducersMqWorkerProducer struct{…}` - `Script string` - `Type QueueProducersMqWorkerProducerType` - `const QueueProducersMqWorkerProducerTypeWorker QueueProducersMqWorkerProducerType = "worker"` - `type QueueProducersMqR2Producer struct{…}` - `BucketName string` - `Type QueueProducersMqR2ProducerType` - `const QueueProducersMqR2ProducerTypeR2Bucket QueueProducersMqR2ProducerType = "r2_bucket"` - `ProducersTotalCount float64` - `QueueID string` - `QueueName string` - `Settings QueueSettings` - `DeliveryDelay float64` Number of seconds to delay delivery of all messages to consumers. - `DeliveryPaused bool` Indicates if message delivery to consumers is currently paused. - `MessageRetentionPeriod float64` Number of seconds after which an unconsumed message will be delayed. ### 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"), ) queue, err := client.Queues.New(context.TODO(), queues.QueueNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), QueueName: cloudflare.F("example-queue"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", queue.QueueID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumers": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "consumers_total_count": 0, "created_on": "created_on", "modified_on": "modified_on", "producers": [ { "script": "script", "type": "worker" } ], "producers_total_count": 0, "queue_id": "queue_id", "queue_name": "example-queue", "settings": { "delivery_delay": 5, "delivery_paused": true, "message_retention_period": 345600 } }, "success": true } ``` ## Update Queue `client.Queues.Update(ctx, queueID, params) (*Queue, error)` **put** `/accounts/{account_id}/queues/{queue_id}` Updates a Queue. Note that this endpoint does not support partial updates. If successful, the Queue's configuration is overwritten with the supplied configuration. ### Parameters - `queueID string` A Resource identifier. - `params QueueUpdateParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `Queue param.Field[Queue]` Body param ### Returns - `type Queue struct{…}` - `Consumers []Consumer` - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` - `ConsumersTotalCount float64` - `CreatedOn string` - `ModifiedOn string` - `Producers []QueueProducer` - `type QueueProducersMqWorkerProducer struct{…}` - `Script string` - `Type QueueProducersMqWorkerProducerType` - `const QueueProducersMqWorkerProducerTypeWorker QueueProducersMqWorkerProducerType = "worker"` - `type QueueProducersMqR2Producer struct{…}` - `BucketName string` - `Type QueueProducersMqR2ProducerType` - `const QueueProducersMqR2ProducerTypeR2Bucket QueueProducersMqR2ProducerType = "r2_bucket"` - `ProducersTotalCount float64` - `QueueID string` - `QueueName string` - `Settings QueueSettings` - `DeliveryDelay float64` Number of seconds to delay delivery of all messages to consumers. - `DeliveryPaused bool` Indicates if message delivery to consumers is currently paused. - `MessageRetentionPeriod float64` Number of seconds after which an unconsumed message will be delayed. ### 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"), ) queue, err := client.Queues.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.QueueUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", queue.QueueID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumers": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "consumers_total_count": 0, "created_on": "created_on", "modified_on": "modified_on", "producers": [ { "script": "script", "type": "worker" } ], "producers_total_count": 0, "queue_id": "queue_id", "queue_name": "example-queue", "settings": { "delivery_delay": 5, "delivery_paused": true, "message_retention_period": 345600 } }, "success": true } ``` ## Update Queue `client.Queues.Edit(ctx, queueID, params) (*Queue, error)` **patch** `/accounts/{account_id}/queues/{queue_id}` Updates a Queue. ### Parameters - `queueID string` A Resource identifier. - `params QueueEditParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `Queue param.Field[Queue]` Body param ### Returns - `type Queue struct{…}` - `Consumers []Consumer` - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` - `ConsumersTotalCount float64` - `CreatedOn string` - `ModifiedOn string` - `Producers []QueueProducer` - `type QueueProducersMqWorkerProducer struct{…}` - `Script string` - `Type QueueProducersMqWorkerProducerType` - `const QueueProducersMqWorkerProducerTypeWorker QueueProducersMqWorkerProducerType = "worker"` - `type QueueProducersMqR2Producer struct{…}` - `BucketName string` - `Type QueueProducersMqR2ProducerType` - `const QueueProducersMqR2ProducerTypeR2Bucket QueueProducersMqR2ProducerType = "r2_bucket"` - `ProducersTotalCount float64` - `QueueID string` - `QueueName string` - `Settings QueueSettings` - `DeliveryDelay float64` Number of seconds to delay delivery of all messages to consumers. - `DeliveryPaused bool` Indicates if message delivery to consumers is currently paused. - `MessageRetentionPeriod float64` Number of seconds after which an unconsumed message will be delayed. ### 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"), ) queue, err := client.Queues.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.QueueEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", queue.QueueID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumers": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "consumers_total_count": 0, "created_on": "created_on", "modified_on": "modified_on", "producers": [ { "script": "script", "type": "worker" } ], "producers_total_count": 0, "queue_id": "queue_id", "queue_name": "example-queue", "settings": { "delivery_delay": 5, "delivery_paused": true, "message_retention_period": 345600 } }, "success": true } ``` ## Delete Queue `client.Queues.Delete(ctx, queueID, body) (*QueueDeleteResponse, error)` **delete** `/accounts/{account_id}/queues/{queue_id}` Deletes a queue ### Parameters - `queueID string` A Resource identifier. - `body QueueDeleteParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type QueueDeleteResponse struct{…}` - `Errors []ResponseInfo` - `Code int64` - `Message string` - `DocumentationURL string` - `Source ResponseInfoSource` - `Pointer string` - `Messages []string` - `Success QueueDeleteResponseSuccess` Indicates if the API call was successful or not. - `const QueueDeleteResponseSuccessTrue QueueDeleteResponseSuccess = true` ### 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"), ) queue, err := client.Queues.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.QueueDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", queue.Errors) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true } ``` ## Domain Types ### Queue - `type Queue struct{…}` - `Consumers []Consumer` - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` - `ConsumersTotalCount float64` - `CreatedOn string` - `ModifiedOn string` - `Producers []QueueProducer` - `type QueueProducersMqWorkerProducer struct{…}` - `Script string` - `Type QueueProducersMqWorkerProducerType` - `const QueueProducersMqWorkerProducerTypeWorker QueueProducersMqWorkerProducerType = "worker"` - `type QueueProducersMqR2Producer struct{…}` - `BucketName string` - `Type QueueProducersMqR2ProducerType` - `const QueueProducersMqR2ProducerTypeR2Bucket QueueProducersMqR2ProducerType = "r2_bucket"` - `ProducersTotalCount float64` - `QueueID string` - `QueueName string` - `Settings QueueSettings` - `DeliveryDelay float64` Number of seconds to delay delivery of all messages to consumers. - `DeliveryPaused bool` Indicates if message delivery to consumers is currently paused. - `MessageRetentionPeriod float64` Number of seconds after which an unconsumed message will be delayed. # Messages ## Push Message `client.Queues.Messages.Push(ctx, queueID, params) (*MessagePushResponse, error)` **post** `/accounts/{account_id}/queues/{queue_id}/messages` Push a message to a Queue ### Parameters - `queueID string` A Resource identifier. - `params MessagePushParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `Body param.Field[string]` Body param - `ContentType param.Field[MessagePushParamsMqQueueMessageTextContentType]` Body param - `const MessagePushParamsMqQueueMessageTextContentTypeText MessagePushParamsMqQueueMessageTextContentType = "text"` - `DelaySeconds param.Field[float64]` Body param: The number of seconds to wait for attempting to deliver this message to consumers ### Returns - `type MessagePushResponse struct{…}` - `Errors []ResponseInfo` - `Code int64` - `Message string` - `DocumentationURL string` - `Source ResponseInfoSource` - `Pointer string` - `Messages []string` - `Success MessagePushResponseSuccess` Indicates if the API call was successful or not. - `const MessagePushResponseSuccessTrue MessagePushResponseSuccess = true` ### 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"), ) response, err := client.Queues.Messages.Push( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.MessagePushParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Errors) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true } ``` ## Acknowledge + Retry Queue Messages `client.Queues.Messages.Ack(ctx, queueID, params) (*MessageAckResponse, error)` **post** `/accounts/{account_id}/queues/{queue_id}/messages/ack` Acknowledge + Retry messages from a Queue ### Parameters - `queueID string` A Resource identifier. - `params MessageAckParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `Acks param.Field[[]MessageAckParamsAck]` Body param - `LeaseID string` An ID that represents an "in-flight" message that has been pulled from a Queue. You must hold on to this ID and use it to acknowledge this message. - `Retries param.Field[[]MessageAckParamsRetry]` Body param - `DelaySeconds float64` The number of seconds to delay before making the message available for another attempt. - `LeaseID string` An ID that represents an "in-flight" message that has been pulled from a Queue. You must hold on to this ID and use it to acknowledge this message. ### Returns - `type MessageAckResponse struct{…}` - `AckCount float64` The number of messages that were succesfully acknowledged. - `RetryCount float64` The number of messages that were succesfully retried. - `Warnings []string` ### 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"), ) response, err := client.Queues.Messages.Ack( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.MessageAckParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.AckCount) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "ackCount": 5, "retryCount": 5, "warnings": [ "string" ] }, "success": true } ``` ## Pull Queue Messages `client.Queues.Messages.Pull(ctx, queueID, params) (*MessagePullResponse, error)` **post** `/accounts/{account_id}/queues/{queue_id}/messages/pull` Pull a batch of messages from a Queue ### Parameters - `queueID string` A Resource identifier. - `params MessagePullParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `BatchSize param.Field[float64]` Body param: The maximum number of messages to include in a batch. - `VisibilityTimeoutMs param.Field[float64]` Body param: The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. ### Returns - `type MessagePullResponse struct{…}` - `MessageBacklogCount float64` The number of unacknowledged messages in the queue - `Messages []MessagePullResponseMessage` - `ID string` - `Attempts float64` - `Body string` - `LeaseID string` An ID that represents an "in-flight" message that has been pulled from a Queue. You must hold on to this ID and use it to acknowledge this message. - `Metadata unknown` - `TimestampMs float64` ### 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"), ) response, err := client.Queues.Messages.Pull( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.MessagePullParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.MessageBacklogCount) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "message_backlog_count": 5, "messages": [ { "id": "b01b5594f784d0165c2985833f5660dd", "attempts": 1, "body": "hello world", "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0", "metadata": { "CF-Content-Type": "text", "CF-sourceMessageSource": "dash" }, "timestamp_ms": 1710950954154 } ] }, "success": true } ``` ## Push Message Batch `client.Queues.Messages.BulkPush(ctx, queueID, params) (*MessageBulkPushResponse, error)` **post** `/accounts/{account_id}/queues/{queue_id}/messages/batch` Push a batch of message to a Queue ### Parameters - `queueID string` A Resource identifier. - `params MessageBulkPushParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `DelaySeconds param.Field[float64]` Body param: The number of seconds to wait for attempting to deliver this batch to consumers - `Messages param.Field[[]MessageBulkPushParamsMessage]` Body param - `type MessageBulkPushParamsMessagesMqQueueMessageText struct{…}` - `Body string` - `ContentType MessageBulkPushParamsMessagesMqQueueMessageTextContentType` - `const MessageBulkPushParamsMessagesMqQueueMessageTextContentTypeText MessageBulkPushParamsMessagesMqQueueMessageTextContentType = "text"` - `DelaySeconds float64` The number of seconds to wait for attempting to deliver this message to consumers - `type MessageBulkPushParamsMessagesMqQueueMessageJson struct{…}` - `Body unknown` - `ContentType MessageBulkPushParamsMessagesMqQueueMessageJsonContentType` - `const MessageBulkPushParamsMessagesMqQueueMessageJsonContentTypeJson MessageBulkPushParamsMessagesMqQueueMessageJsonContentType = "json"` - `DelaySeconds float64` The number of seconds to wait for attempting to deliver this message to consumers ### Returns - `type MessageBulkPushResponse struct{…}` - `Errors []ResponseInfo` - `Code int64` - `Message string` - `DocumentationURL string` - `Source ResponseInfoSource` - `Pointer string` - `Messages []string` - `Success MessageBulkPushResponseSuccess` Indicates if the API call was successful or not. - `const MessageBulkPushResponseSuccessTrue MessageBulkPushResponseSuccess = true` ### 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"), ) response, err := client.Queues.Messages.BulkPush( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.MessageBulkPushParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Errors) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true } ``` # Purge ## Get Queue Purge Status `client.Queues.Purge.Status(ctx, queueID, query) (*PurgeStatusResponse, error)` **get** `/accounts/{account_id}/queues/{queue_id}/purge` Get details about a Queue's purge status. ### Parameters - `queueID string` A Resource identifier. - `query PurgeStatusParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type PurgeStatusResponse struct{…}` - `Completed string` Indicates if the last purge operation completed successfully. - `StartedAt string` Timestamp when the last purge operation started. ### 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"), ) response, err := client.Queues.Purge.Status( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.PurgeStatusParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Completed) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "completed": "completed", "started_at": "started_at" }, "success": true } ``` ## Purge Queue `client.Queues.Purge.Start(ctx, queueID, params) (*Queue, error)` **post** `/accounts/{account_id}/queues/{queue_id}/purge` Deletes all messages from the Queue. ### Parameters - `queueID string` A Resource identifier. - `params PurgeStartParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `DeleteMessagesPermanently param.Field[bool]` Body param: Confimation that all messages will be deleted permanently. ### Returns - `type Queue struct{…}` - `Consumers []Consumer` - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` - `ConsumersTotalCount float64` - `CreatedOn string` - `ModifiedOn string` - `Producers []QueueProducer` - `type QueueProducersMqWorkerProducer struct{…}` - `Script string` - `Type QueueProducersMqWorkerProducerType` - `const QueueProducersMqWorkerProducerTypeWorker QueueProducersMqWorkerProducerType = "worker"` - `type QueueProducersMqR2Producer struct{…}` - `BucketName string` - `Type QueueProducersMqR2ProducerType` - `const QueueProducersMqR2ProducerTypeR2Bucket QueueProducersMqR2ProducerType = "r2_bucket"` - `ProducersTotalCount float64` - `QueueID string` - `QueueName string` - `Settings QueueSettings` - `DeliveryDelay float64` Number of seconds to delay delivery of all messages to consumers. - `DeliveryPaused bool` Indicates if message delivery to consumers is currently paused. - `MessageRetentionPeriod float64` Number of seconds after which an unconsumed message will be delayed. ### 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"), ) queue, err := client.Queues.Purge.Start( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.PurgeStartParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", queue.QueueID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumers": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "consumers_total_count": 0, "created_on": "created_on", "modified_on": "modified_on", "producers": [ { "script": "script", "type": "worker" } ], "producers_total_count": 0, "queue_id": "queue_id", "queue_name": "example-queue", "settings": { "delivery_delay": 5, "delivery_paused": true, "message_retention_period": 345600 } }, "success": true } ``` # Consumers ## List Queue Consumers `client.Queues.Consumers.List(ctx, queueID, query) (*SinglePage[Consumer], error)` **get** `/accounts/{account_id}/queues/{queue_id}/consumers` Returns the consumers for a Queue ### Parameters - `queueID string` A Resource identifier. - `query ConsumerListParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type Consumer interface{…}` Response body representing a consumer - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` ### 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"), ) page, err := client.Queues.Consumers.List( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "success": true } ``` ## Get Queue Consumer `client.Queues.Consumers.Get(ctx, queueID, consumerID, query) (*Consumer, error)` **get** `/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}` Fetches the consumer for a queue by consumer id ### Parameters - `queueID string` A Resource identifier. - `consumerID string` A Resource identifier. - `query ConsumerGetParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type Consumer interface{…}` Response body representing a consumer - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` ### 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"), ) consumer, err := client.Queues.Consumers.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", consumer) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" }, "success": true } ``` ## Create a Queue Consumer `client.Queues.Consumers.New(ctx, queueID, params) (*Consumer, error)` **post** `/accounts/{account_id}/queues/{queue_id}/consumers` Creates a new consumer for a Queue ### Parameters - `queueID string` A Resource identifier. - `params ConsumerNewParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `ScriptName param.Field[string]` Body param: Name of a Worker - `Type param.Field[ConsumerNewParamsMqWorkerConsumerRequestType]` Body param - `const ConsumerNewParamsMqWorkerConsumerRequestTypeWorker ConsumerNewParamsMqWorkerConsumerRequestType = "worker"` - `DeadLetterQueue param.Field[string]` Body param - `Settings param.Field[ConsumerNewParamsMqWorkerConsumerRequestSettings]` Body param - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. ### Returns - `type Consumer interface{…}` Response body representing a consumer - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` ### 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"), ) consumer, err := client.Queues.Consumers.New( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: queues.ConsumerNewParamsBodyMqWorkerConsumerRequest{ ScriptName: cloudflare.F("my-consumer-worker"), Type: cloudflare.F(queues.ConsumerNewParamsBodyMqWorkerConsumerRequestTypeWorker), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", consumer) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" }, "success": true } ``` ## Update Queue Consumer `client.Queues.Consumers.Update(ctx, queueID, consumerID, params) (*Consumer, error)` **put** `/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}` Updates the consumer for a queue, or creates one if it does not exist. ### Parameters - `queueID string` A Resource identifier. - `consumerID string` A Resource identifier. - `params ConsumerUpdateParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `ScriptName param.Field[string]` Body param: Name of a Worker - `Type param.Field[ConsumerUpdateParamsMqWorkerConsumerRequestType]` Body param - `const ConsumerUpdateParamsMqWorkerConsumerRequestTypeWorker ConsumerUpdateParamsMqWorkerConsumerRequestType = "worker"` - `DeadLetterQueue param.Field[string]` Body param - `Settings param.Field[ConsumerUpdateParamsMqWorkerConsumerRequestSettings]` Body param - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. ### Returns - `type Consumer interface{…}` Response body representing a consumer - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` ### 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"), ) consumer, err := client.Queues.Consumers.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: queues.ConsumerUpdateParamsBodyMqWorkerConsumerRequest{ ScriptName: cloudflare.F("my-consumer-worker"), Type: cloudflare.F(queues.ConsumerUpdateParamsBodyMqWorkerConsumerRequestTypeWorker), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", consumer) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" }, "success": true } ``` ## Delete Queue Consumer `client.Queues.Consumers.Delete(ctx, queueID, consumerID, body) (*ConsumerDeleteResponse, error)` **delete** `/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}` Deletes the consumer for a queue. ### Parameters - `queueID string` A Resource identifier. - `consumerID string` A Resource identifier. - `body ConsumerDeleteParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type ConsumerDeleteResponse struct{…}` - `Errors []ResponseInfo` - `Code int64` - `Message string` - `DocumentationURL string` - `Source ResponseInfoSource` - `Pointer string` - `Messages []string` - `Success ConsumerDeleteResponseSuccess` Indicates if the API call was successful or not. - `const ConsumerDeleteResponseSuccessTrue ConsumerDeleteResponseSuccess = true` ### 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"), ) consumer, err := client.Queues.Consumers.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", consumer.Errors) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true } ``` ## Domain Types ### Consumer - `type Consumer interface{…}` Response body representing a consumer - `type ConsumerMqWorkerConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `ScriptName string` Name of a Worker - `Settings ConsumerMqWorkerConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxConcurrency float64` Maximum number of concurrent consumers that may consume from this Queue. Set to `null` to automatically opt in to the platform's maximum (recommended). - `MaxRetries float64` The maximum number of retries - `MaxWaitTimeMs float64` The number of milliseconds to wait for a batch to fill up before attempting to deliver it - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `Type ConsumerMqWorkerConsumerResponseType` - `const ConsumerMqWorkerConsumerResponseTypeWorker ConsumerMqWorkerConsumerResponseType = "worker"` - `type ConsumerMqHTTPConsumerResponse struct{…}` - `ConsumerID string` A Resource identifier. - `CreatedOn Time` - `DeadLetterQueue string` Name of the dead letter queue, or empty string if not configured - `QueueName string` - `Settings ConsumerMqHTTPConsumerResponseSettings` - `BatchSize float64` The maximum number of messages to include in a batch. - `MaxRetries float64` The maximum number of retries - `RetryDelay float64` The number of seconds to delay before making the message available for another attempt. - `VisibilityTimeoutMs float64` The number of milliseconds that a message is exclusively leased. After the timeout, the message becomes available for another attempt. - `Type ConsumerMqHTTPConsumerResponseType` - `const ConsumerMqHTTPConsumerResponseTypeHTTPPull ConsumerMqHTTPConsumerResponseType = "http_pull"` # Subscriptions ## List Event Subscriptions `client.Queues.Subscriptions.List(ctx, params) (*V4PagePaginationArray[SubscriptionListResponse], error)` **get** `/accounts/{account_id}/event_subscriptions/subscriptions` Get a paginated list of event subscriptions with optional sorting and filtering ### Parameters - `params SubscriptionListParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `Direction param.Field[SubscriptionListParamsDirection]` Query param: Sort direction - `const SubscriptionListParamsDirectionAsc SubscriptionListParamsDirection = "asc"` - `const SubscriptionListParamsDirectionDesc SubscriptionListParamsDirection = "desc"` - `Order param.Field[SubscriptionListParamsOrder]` Query param: Field to sort by - `const SubscriptionListParamsOrderCreatedAt SubscriptionListParamsOrder = "created_at"` - `const SubscriptionListParamsOrderName SubscriptionListParamsOrder = "name"` - `const SubscriptionListParamsOrderEnabled SubscriptionListParamsOrder = "enabled"` - `const SubscriptionListParamsOrderSource SubscriptionListParamsOrder = "source"` - `Page param.Field[int64]` Query param: Page number for pagination - `PerPage param.Field[int64]` Query param: Number of items per page ### Returns - `type SubscriptionListResponse struct{…}` - `ID string` Unique identifier for the subscription - `CreatedAt Time` When the subscription was created - `Destination SubscriptionListResponseDestination` Destination configuration for the subscription - `QueueID string` ID of the target queue - `Type SubscriptionListResponseDestinationType` Type of destination - `const SubscriptionListResponseDestinationTypeQueuesQueue SubscriptionListResponseDestinationType = "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 SubscriptionListResponseSource` Source configuration for the subscription - `type SubscriptionListResponseSourceMqEventSourceImages struct{…}` - `Type SubscriptionListResponseSourceMqEventSourceImagesType` Type of source - `const SubscriptionListResponseSourceMqEventSourceImagesTypeImages SubscriptionListResponseSourceMqEventSourceImagesType = "images"` - `type SubscriptionListResponseSourceMqEventSourceKV struct{…}` - `Type SubscriptionListResponseSourceMqEventSourceKVType` Type of source - `const SubscriptionListResponseSourceMqEventSourceKVTypeKV SubscriptionListResponseSourceMqEventSourceKVType = "kv"` - `type SubscriptionListResponseSourceMqEventSourceR2 struct{…}` - `Type SubscriptionListResponseSourceMqEventSourceR2Type` Type of source - `const SubscriptionListResponseSourceMqEventSourceR2TypeR2 SubscriptionListResponseSourceMqEventSourceR2Type = "r2"` - `type SubscriptionListResponseSourceMqEventSourceSuperSlurper struct{…}` - `Type SubscriptionListResponseSourceMqEventSourceSuperSlurperType` Type of source - `const SubscriptionListResponseSourceMqEventSourceSuperSlurperTypeSuperSlurper SubscriptionListResponseSourceMqEventSourceSuperSlurperType = "superSlurper"` - `type SubscriptionListResponseSourceMqEventSourceVectorize struct{…}` - `Type SubscriptionListResponseSourceMqEventSourceVectorizeType` Type of source - `const SubscriptionListResponseSourceMqEventSourceVectorizeTypeVectorize SubscriptionListResponseSourceMqEventSourceVectorizeType = "vectorize"` - `type SubscriptionListResponseSourceMqEventSourceWorkersAIModel struct{…}` - `ModelName string` Name of the Workers AI model - `Type SubscriptionListResponseSourceMqEventSourceWorkersAIModelType` Type of source - `const SubscriptionListResponseSourceMqEventSourceWorkersAIModelTypeWorkersAIModel SubscriptionListResponseSourceMqEventSourceWorkersAIModelType = "workersAi.model"` - `type SubscriptionListResponseSourceMqEventSourceWorkersBuildsWorker struct{…}` - `Type SubscriptionListResponseSourceMqEventSourceWorkersBuildsWorkerType` Type of source - `const SubscriptionListResponseSourceMqEventSourceWorkersBuildsWorkerTypeWorkersBuildsWorker SubscriptionListResponseSourceMqEventSourceWorkersBuildsWorkerType = "workersBuilds.worker"` - `WorkerName string` Name of the worker - `type SubscriptionListResponseSourceMqEventSourceWorkflowsWorkflow struct{…}` - `Type SubscriptionListResponseSourceMqEventSourceWorkflowsWorkflowType` Type of source - `const SubscriptionListResponseSourceMqEventSourceWorkflowsWorkflowTypeWorkflowsWorkflow SubscriptionListResponseSourceMqEventSourceWorkflowsWorkflowType = "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"), ) page, err := client.Queues.Subscriptions.List(context.TODO(), queues.SubscriptionListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0, "total_pages": 0 }, "success": true } ``` ## Get Event Subscription `client.Queues.Subscriptions.Get(ctx, subscriptionID, query) (*SubscriptionGetResponse, error)` **get** `/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}` Get details about an existing event subscription ### Parameters - `subscriptionID string` A Resource identifier. - `query SubscriptionGetParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type SubscriptionGetResponse struct{…}` - `ID string` Unique identifier for the subscription - `CreatedAt Time` When the subscription was created - `Destination SubscriptionGetResponseDestination` Destination configuration for the subscription - `QueueID string` ID of the target queue - `Type SubscriptionGetResponseDestinationType` Type of destination - `const SubscriptionGetResponseDestinationTypeQueuesQueue SubscriptionGetResponseDestinationType = "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 SubscriptionGetResponseSource` Source configuration for the subscription - `type SubscriptionGetResponseSourceMqEventSourceImages struct{…}` - `Type SubscriptionGetResponseSourceMqEventSourceImagesType` Type of source - `const SubscriptionGetResponseSourceMqEventSourceImagesTypeImages SubscriptionGetResponseSourceMqEventSourceImagesType = "images"` - `type SubscriptionGetResponseSourceMqEventSourceKV struct{…}` - `Type SubscriptionGetResponseSourceMqEventSourceKVType` Type of source - `const SubscriptionGetResponseSourceMqEventSourceKVTypeKV SubscriptionGetResponseSourceMqEventSourceKVType = "kv"` - `type SubscriptionGetResponseSourceMqEventSourceR2 struct{…}` - `Type SubscriptionGetResponseSourceMqEventSourceR2Type` Type of source - `const SubscriptionGetResponseSourceMqEventSourceR2TypeR2 SubscriptionGetResponseSourceMqEventSourceR2Type = "r2"` - `type SubscriptionGetResponseSourceMqEventSourceSuperSlurper struct{…}` - `Type SubscriptionGetResponseSourceMqEventSourceSuperSlurperType` Type of source - `const SubscriptionGetResponseSourceMqEventSourceSuperSlurperTypeSuperSlurper SubscriptionGetResponseSourceMqEventSourceSuperSlurperType = "superSlurper"` - `type SubscriptionGetResponseSourceMqEventSourceVectorize struct{…}` - `Type SubscriptionGetResponseSourceMqEventSourceVectorizeType` Type of source - `const SubscriptionGetResponseSourceMqEventSourceVectorizeTypeVectorize SubscriptionGetResponseSourceMqEventSourceVectorizeType = "vectorize"` - `type SubscriptionGetResponseSourceMqEventSourceWorkersAIModel struct{…}` - `ModelName string` Name of the Workers AI model - `Type SubscriptionGetResponseSourceMqEventSourceWorkersAIModelType` Type of source - `const SubscriptionGetResponseSourceMqEventSourceWorkersAIModelTypeWorkersAIModel SubscriptionGetResponseSourceMqEventSourceWorkersAIModelType = "workersAi.model"` - `type SubscriptionGetResponseSourceMqEventSourceWorkersBuildsWorker struct{…}` - `Type SubscriptionGetResponseSourceMqEventSourceWorkersBuildsWorkerType` Type of source - `const SubscriptionGetResponseSourceMqEventSourceWorkersBuildsWorkerTypeWorkersBuildsWorker SubscriptionGetResponseSourceMqEventSourceWorkersBuildsWorkerType = "workersBuilds.worker"` - `WorkerName string` Name of the worker - `type SubscriptionGetResponseSourceMqEventSourceWorkflowsWorkflow struct{…}` - `Type SubscriptionGetResponseSourceMqEventSourceWorkflowsWorkflowType` Type of source - `const SubscriptionGetResponseSourceMqEventSourceWorkflowsWorkflowTypeWorkflowsWorkflow SubscriptionGetResponseSourceMqEventSourceWorkflowsWorkflowType = "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.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.SubscriptionGetParams{ 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 } ``` ## 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 } ``` ## Update Event Subscription `client.Queues.Subscriptions.Update(ctx, subscriptionID, params) (*SubscriptionUpdateResponse, error)` **patch** `/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}` Update an existing event subscription ### Parameters - `subscriptionID string` A Resource identifier. - `params SubscriptionUpdateParams` - `AccountID param.Field[string]` Path param: A Resource identifier. - `Destination param.Field[SubscriptionUpdateParamsDestination]` Body param: Destination configuration for the subscription - `QueueID string` ID of the target queue - `Type SubscriptionUpdateParamsDestinationType` Type of destination - `const SubscriptionUpdateParamsDestinationTypeQueuesQueue SubscriptionUpdateParamsDestinationType = "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 ### Returns - `type SubscriptionUpdateResponse struct{…}` - `ID string` Unique identifier for the subscription - `CreatedAt Time` When the subscription was created - `Destination SubscriptionUpdateResponseDestination` Destination configuration for the subscription - `QueueID string` ID of the target queue - `Type SubscriptionUpdateResponseDestinationType` Type of destination - `const SubscriptionUpdateResponseDestinationTypeQueuesQueue SubscriptionUpdateResponseDestinationType = "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 SubscriptionUpdateResponseSource` Source configuration for the subscription - `type SubscriptionUpdateResponseSourceMqEventSourceImages struct{…}` - `Type SubscriptionUpdateResponseSourceMqEventSourceImagesType` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceImagesTypeImages SubscriptionUpdateResponseSourceMqEventSourceImagesType = "images"` - `type SubscriptionUpdateResponseSourceMqEventSourceKV struct{…}` - `Type SubscriptionUpdateResponseSourceMqEventSourceKVType` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceKVTypeKV SubscriptionUpdateResponseSourceMqEventSourceKVType = "kv"` - `type SubscriptionUpdateResponseSourceMqEventSourceR2 struct{…}` - `Type SubscriptionUpdateResponseSourceMqEventSourceR2Type` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceR2TypeR2 SubscriptionUpdateResponseSourceMqEventSourceR2Type = "r2"` - `type SubscriptionUpdateResponseSourceMqEventSourceSuperSlurper struct{…}` - `Type SubscriptionUpdateResponseSourceMqEventSourceSuperSlurperType` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceSuperSlurperTypeSuperSlurper SubscriptionUpdateResponseSourceMqEventSourceSuperSlurperType = "superSlurper"` - `type SubscriptionUpdateResponseSourceMqEventSourceVectorize struct{…}` - `Type SubscriptionUpdateResponseSourceMqEventSourceVectorizeType` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceVectorizeTypeVectorize SubscriptionUpdateResponseSourceMqEventSourceVectorizeType = "vectorize"` - `type SubscriptionUpdateResponseSourceMqEventSourceWorkersAIModel struct{…}` - `ModelName string` Name of the Workers AI model - `Type SubscriptionUpdateResponseSourceMqEventSourceWorkersAIModelType` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceWorkersAIModelTypeWorkersAIModel SubscriptionUpdateResponseSourceMqEventSourceWorkersAIModelType = "workersAi.model"` - `type SubscriptionUpdateResponseSourceMqEventSourceWorkersBuildsWorker struct{…}` - `Type SubscriptionUpdateResponseSourceMqEventSourceWorkersBuildsWorkerType` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceWorkersBuildsWorkerTypeWorkersBuildsWorker SubscriptionUpdateResponseSourceMqEventSourceWorkersBuildsWorkerType = "workersBuilds.worker"` - `WorkerName string` Name of the worker - `type SubscriptionUpdateResponseSourceMqEventSourceWorkflowsWorkflow struct{…}` - `Type SubscriptionUpdateResponseSourceMqEventSourceWorkflowsWorkflowType` Type of source - `const SubscriptionUpdateResponseSourceMqEventSourceWorkflowsWorkflowTypeWorkflowsWorkflow SubscriptionUpdateResponseSourceMqEventSourceWorkflowsWorkflowType = "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.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.SubscriptionUpdateParams{ 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 } ``` ## Delete Event Subscription `client.Queues.Subscriptions.Delete(ctx, subscriptionID, body) (*SubscriptionDeleteResponse, error)` **delete** `/accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}` Delete an existing event subscription ### Parameters - `subscriptionID string` A Resource identifier. - `body SubscriptionDeleteParams` - `AccountID param.Field[string]` A Resource identifier. ### Returns - `type SubscriptionDeleteResponse struct{…}` - `ID string` Unique identifier for the subscription - `CreatedAt Time` When the subscription was created - `Destination SubscriptionDeleteResponseDestination` Destination configuration for the subscription - `QueueID string` ID of the target queue - `Type SubscriptionDeleteResponseDestinationType` Type of destination - `const SubscriptionDeleteResponseDestinationTypeQueuesQueue SubscriptionDeleteResponseDestinationType = "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 SubscriptionDeleteResponseSource` Source configuration for the subscription - `type SubscriptionDeleteResponseSourceMqEventSourceImages struct{…}` - `Type SubscriptionDeleteResponseSourceMqEventSourceImagesType` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceImagesTypeImages SubscriptionDeleteResponseSourceMqEventSourceImagesType = "images"` - `type SubscriptionDeleteResponseSourceMqEventSourceKV struct{…}` - `Type SubscriptionDeleteResponseSourceMqEventSourceKVType` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceKVTypeKV SubscriptionDeleteResponseSourceMqEventSourceKVType = "kv"` - `type SubscriptionDeleteResponseSourceMqEventSourceR2 struct{…}` - `Type SubscriptionDeleteResponseSourceMqEventSourceR2Type` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceR2TypeR2 SubscriptionDeleteResponseSourceMqEventSourceR2Type = "r2"` - `type SubscriptionDeleteResponseSourceMqEventSourceSuperSlurper struct{…}` - `Type SubscriptionDeleteResponseSourceMqEventSourceSuperSlurperType` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceSuperSlurperTypeSuperSlurper SubscriptionDeleteResponseSourceMqEventSourceSuperSlurperType = "superSlurper"` - `type SubscriptionDeleteResponseSourceMqEventSourceVectorize struct{…}` - `Type SubscriptionDeleteResponseSourceMqEventSourceVectorizeType` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceVectorizeTypeVectorize SubscriptionDeleteResponseSourceMqEventSourceVectorizeType = "vectorize"` - `type SubscriptionDeleteResponseSourceMqEventSourceWorkersAIModel struct{…}` - `ModelName string` Name of the Workers AI model - `Type SubscriptionDeleteResponseSourceMqEventSourceWorkersAIModelType` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceWorkersAIModelTypeWorkersAIModel SubscriptionDeleteResponseSourceMqEventSourceWorkersAIModelType = "workersAi.model"` - `type SubscriptionDeleteResponseSourceMqEventSourceWorkersBuildsWorker struct{…}` - `Type SubscriptionDeleteResponseSourceMqEventSourceWorkersBuildsWorkerType` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceWorkersBuildsWorkerTypeWorkersBuildsWorker SubscriptionDeleteResponseSourceMqEventSourceWorkersBuildsWorkerType = "workersBuilds.worker"` - `WorkerName string` Name of the worker - `type SubscriptionDeleteResponseSourceMqEventSourceWorkflowsWorkflow struct{…}` - `Type SubscriptionDeleteResponseSourceMqEventSourceWorkflowsWorkflowType` Type of source - `const SubscriptionDeleteResponseSourceMqEventSourceWorkflowsWorkflowTypeWorkflowsWorkflow SubscriptionDeleteResponseSourceMqEventSourceWorkflowsWorkflowType = "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.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", queues.SubscriptionDeleteParams{ 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 } ```