# HTTP API for RabbitMQ and LavinMQ

RabbitMQ is a message broker that allows clients to connect over different open and standardized protocols such as [AMQP,](/docs/amqp/)[HTTP,](/docs/http/)[STOMP,](/docs/stomp/)[MQTT,](/docs/mqtt/)[MQTT over WebSockets](/docs/mqtt-over-websockets/) and [STOMP over WebSockets](/docs/stomp-over-websockets/).

HTTP stands for Hypertext Transfer Protocol, and it is an application-level protocol for distributed, collaborative, hypermedia information systems. HTTP is not a messaging protocol. However, RabbitMQ can transmit messages over HTTP.

The [rabbitmq-management plugin](https://www.rabbitmq.com/management.html) provides an HTTP-based API for the management and monitoring of your RabbitMQ server. It enables by default on all CloudAMQP instances and assigned port 443.

The full HTTP API reference can be found in the official [RabbitMQ Management HTTP API](https://rawcdn.githack.com/rabbitmq/rabbitmq-server/v3.13.7/deps/rabbitmq_management/priv/www/api/index.html) documentation, or in the [LavinMQ management HTTP API documentation](https://docs.lavinmq.com/docs/).

The HTTP API uses [basic authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) (the `Authorization` header). In the examples on this page, this is handled by the [curl](https://curl.se/)`--user`[flag](https://curl.se/docs/manpage.html#-u).

## Publish with HTTP

Example of how to publish a message to the default exchange with the routing key `my_key`:

```bash
curl --user username:password \
     --json '{"properties":{},"routing_key":"my_key","payload":"my body","payload_encoding":"string"}' \
     https://hostname/api/exchanges/your_vhost/amq.default/publish
```

The response will be in JSON, telling you if the message was routed or not.

## Get message with HTTP

Example of how to get one message from the Queue `your_queue`. (This is not an HTTP GET as it will alter the Queue’s state.)

```bash
curl --user username:password \
     --json '{"count":1,"requeue":true,"encoding":"auto"}' \
     https://hostname/api/queues/your_vhost/your_queue/get
```

The response will be in JSON, with the message payload and various properties.

### Get queue information

```bash
curl --user username:password https://hostname/api/queues/your_vhost/your_queue
```

The response will be in JSON, with various information about the queue.

### Autoscale by polling queue length

When arrive faster to the queue than they are processed - and when the queue starts growing in length, it is good to spin up more workers. The idea is to poll the HTTP API queue length and spin up or take down workers depending on the length.
