HTTP API Reference
Introduction
This is a reference page for the RabbitMQ HTTP API.
Client Libraries for the HTTP API
There are several mature HTTP API client libraries available, see Developer Tools.
HTTP API-based CLI Tool
In addition to client libraries, there is an HTTP API-specific CLI tool for both interactive and script use.
See rabbitmqadmin v2, a Command Line Tool for the HTTP API to learn more.
Overview
All HTTP API API endpoints will serve only resources
of type application/json
, and will require HTTP basic
authentication (using the standard RabbitMQ user database). The
default user is guest/guest.
Many URIs require the name of a virtual host as part of the
path, since names only uniquely identify objects within a virtual
host. As the default virtual host is called "/
", this
will need to be encoded as "%2F
".
PUTing a resource creates it. The JSON object you upload must have certain mandatory keys (documented below) and may have optional keys. Other keys are ignored. Missing mandatory keys constitute an error.
Since bindings do not have names or IDs in AMQP we synthesise one based on all its properties. Since predicting this name is hard in the general case, you can also create bindings by POSTing to a factory URI. See the example below.
Many URIs return lists. Such URIs can have the query string
parameters sort
and sort_reverse
added. sort
allows you to select a primary field to
sort by, and sort_reverse
will reverse the sort order
if set to true
. The sort
parameter can
contain subfields separated by dots. This allows you to sort by a
nested component of the listed items; it does not allow you to
sort by more than one field. See the example below.
You can also restrict what information is returned per item
with the columns
parameter. This is a comma-separated
list of subfields separated by dots. See the example below.
It is possible to disable the statistics in the GET requests and obtain just the basic information of every object. This reduces considerably the amount of data returned and the memory and resource consumption of each query in the system. For some monitoring and operation purposes, these queries are more appropriate.
To opt out of the additional metrics, set the disable_stats
query parameter
to true
Endpoint Reference
The examples below use rabbitmqadmin
v2 or curl
.
However, the API can be used with any HTTP client. Team RabbitMQ strongly recommends a number of dedicated HTTP API client libraries.
The examples that produce JSON output also format the output with jq
.
The use of jq
is entirely optional.
GET /api/overview
Various random bits of information that describe the whole system.
Examples
- rabbitmqadmin v2
- curl
rabbitmqadmin show overview
# jq is used for pretty-printing the result. It is entirely optional.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/overview | jq
GET /api/cluster-name
Returns the name identifying this RabbitMQ cluster.
Examples
- curl
# jq is used for pretty-printing the result. It is entirely optional.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/cluster-name | jq
PUT /api/cluster-name
Updates the name identifying this RabbitMQ cluster.
GET /api/nodes
Lists all nodes in the cluster together with their metrics.
Examples
- rabbitmqadmin v2
- curl
rabbitmqadmin list nodes
# jq is used for pretty-printing the result. It is entirely optional.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/nodes | jq
GET /api/nodes/{name}
Returns metrics of an individual cluster node.
Examples
- rabbitmqadmin v2
- curl
rabbitmqadmin list nodes
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/nodes/rabbit@hostname | jq
GET /api/nodes/{name}/memory
Returns a memory usage breakdown of a specific cluster node.
Examples
- rabbitmqadmin v2
- curl
# in percent
rabbitmqadmin show memory_breakdown_in_percent --node rabbit@hostname
# in bytes
rabbitmqadmin show memory_breakdown_in_bytes --node rabbit@hostname
# jq is used for pretty-printing the result. It is entirely optional.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/nodes/rabbit@hostname/memory | jq
GET /api/definitions
Exports cluster-wide definitions: all exchanges, queues, bindings, users, virtual hosts, permissions, topic permissions, and parameters. That is, everything apart from messages.
Examples
- rabbitmqadmin v2
- curl
# Prints the result to the standard output stream.
# jq is used for pretty-printing the result. It is entirely optional.
rabbitmqadmin definitions export --stdout | jq
# stores the result to a file
rabbitmqadmin definitions export --file /path/to/exported.cluster.definitions.json
# jq is used for pretty-printing the result. It is entirely optional.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/definitions | jq
Relevant documentation guide: Definition Export and Import.
POST /api/definitions
The server definitions: exchanges, queues, bindings, users, virtual hosts, permissions, topic permissions, and parameters. Everything apart from messages. POST to upload an existing set of definitions. Note that:
Cluster-wide definitions use a different format from the virtual host-specific ones. Virtual host-specific definitions cannot be imported using this endpoint. Use the
POST /api/definitions/{vhost}
endpoint instead.The definitions are merged. Anything already existing on the server but not in the uploaded definitions is untouched.
Conflicting definitions on immutable objects (exchanges, queues and bindings) will be ignored. The existing definition will be preserved.
Conflicting definitions on mutable objects will cause the object in the server to be overwritten with the object from the definitions.
In the event of an error you will be left with a partially-applied set of definitions.
This endpoint supports multipart/form-data
as
well as the standard application/json
content types for uploads.
In the former case, the definitions file should be uploaded as a form field named "file".
Relevant documentation guide: Definition Export and Import.
GET /api/definitions/{vhost}
Exports definitions of a single virtual host.
Virtual host-specific definitions do not contain any details on the virtual host name, and can be imported into any virtual host. That is, the original name of the virtual host does not have to match the name of the target virtual host when the definitions are imported.
Relevant documentation guide: Definition Export and Import.
Examples
- rabbitmqadmin v2
- curl
# Prints the result to the standard output stream.
# jq is used for pretty-printing the result. It is entirely optional.
rabbitmqadmin --vhost "/" definitions export_from_vhost --stdout | jq
# stores the result to a file
rabbitmqadmin --vhost "/" definitions export_from_vhost --file /path/to/exported.single-vhost.definitions.json
# jq is used for pretty-printing the result. It is entirely optional.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/definitions/%2F | jq
POST /api/definitions/{vhost}
Imports (uploads) definitions from a single virtual host: exchanges, queues, bindings, users, permissions in that virtual host, topic permissions, and parameters.
Note that:
Cluster-wide definitions cannot be imported using this endpoint. Use the
POST /api/definitions/
endpoint instead.Virtual host-specific definitions do not contain any details on the virtual host name, and can be imported into any virtual host. That is, the original name of the virtual host does not have to match the name of the target virtual host when the definitions are imported.
The definitions are merged. Anything already existing on the server but not in the uploaded definitions is untouched.
Conflicting definitions on immutable objects (exchanges, queues and bindings) will be ignored. The existing definition will be preserved.
Conflicting definitions on mutable objects will cause the object in the server to be overwritten with the object from the definitions.
In the event of an error you will be left with a partially-applied set of definitions.
This endpoint supports multipart/form-data
as
well as the standard application/json
content types for uploads.
In the former case, the definitions file should be uploaded as a form field named "file".
Relevant documentation guide: Definition Export and Import.
GET /api/feature-flags
Lists all feature flags and their state.
Relevant documentation guide: Feature Flags.
Examples
- rabbitmqadmin v2
- curl
rabbitmqadmin feature_flags list
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/feature-flags | jq
GET /api/deprecated-features
Lists all deprecated features and their state.
Relevant documentation guide: Deprecated Features
Examples
- rabbitmqadmin v2
- curl
rabbitmqadmin deprecated_features list
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/feature-flags | jq
GET /api/deprecated-features/used
Lists the deprecated features that are used in this cluster.
Relevant documentation guide: Deprecated Features
Examples
- rabbitmqadmin v2
- curl
rabbitmqadmin deprecated_features list_used
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/deprecated_features/used | jq
GET /api/connections
A list of all open connections.
Use pagination parameters to list connections, otherwise this endpoint can produce very large JSON responses and waste a lot of bandwidth and CPU resources. Default page size is 100, maximum supported page size is 500.
- rabbitmqadmin v2
- curl
rabbitmqadmin list connections
# This request can result in a very large JSON document
# and unnecessarily wasted CPU resources.
#
# Never use it to fetch information about a single connection.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/connections | jq
GET /api/vhosts/{vhost}/connections
A list of all open connections in a specific virtual host.
Use pagination parameters to list connections, otherwise this endpoint can produce very large JSON responses and waste a lot of bandwidth and CPU resources. Default page size is 100, maximum supported page size is 500.
GET /api/connections/{name}
Returns metrics of an individual connection.
- rabbitmqadmin v2
- curl
rabbitmqadmin deprecated_features list_used
# the connection name must be percent-encoded
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/connections/127.0.0.1%3A54594%20-%3E%20127.0.0.1%3A5672 | jq
DELETE /api/connections/{name}
Closes the connection. Optionally set the "X-Reason" header to provide a reason.
- rabbitmqadmin v2
- curl
rabbitmqadmin close connection --name "127.0.0.1:51740 -> 127.0.0.1:5672"
# the connection name must be percent-encoded
curl -sL -u guest:guest -X DELETE -H "Accept: application/json" http://127.0.0.1:15672/api/connections/127.0.0.1%3A62965%20-%3E%20127.0.0.1%3A5672
GET /api/connections/username/{username}
A list of all open connections that authenticated using a specific username.
- rabbitmqadmin v2
- curl
rabbitmqadmin list user_connections --username "guest"
# the connection name must be percent-encoded
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/connections/username/guest
DELETE /api/connections/username/{username}
Close all the connections of a user.
Optionally set the "X-Reason" header to provide a reason.
- rabbitmqadmin v2
- curl
rabbitmqadmin close user_connections --username "guest"
# the connection name must be percent-encoded
curl -sL -u guest:guest -X DELETE -H "Accept: application/json" http://127.0.0.1:15672/api/connections/127.0.0.1%3A62965%20-%3E%20127.0.0.1%3A5672
GET /api/connections/{name}/channels
List of all channels for a given connection.
Use pagination parameters to list channels, otherwise this endpoint can produce very large JSON responses and waste a lot of bandwidth and CPU resources. Default page size is 100, maximum supported page size is 500.
- curl
# the connection name must be percent-encoded
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/connections/127.0.0.1%3A52066%20-%3E%20127.0.0.1%3A5672/channels | jq
GET /api/channels
A list of all open channels.
Use pagination parameters to list channels, otherwise this endpoint can produce very large JSON responses and waste a lot of bandwidth and CPU resources. Default page size is 100, maximum supported page size is 500.
- rabbitmqadmin v2
- curl
rabbitmqadmin list channels
# This request can result in a very large JSON document
# and unnecessarily wasted CPU resources.
#
# Never use it to fetch information about a single channel.
curl -sL -u guest:guest -H "Accept: application/json" http://127.0.0.1:15672/api/channels