Skip to main content

Create Exchange

This endpoint allows you to create a RabbitMQ exchange for message distribution.


Endpoint

POST /api/v1/rabbitmq/exchanges


Request

Headers

KeyValue
Content-Typeapplication/json

Body

{
"name": "example_exchange",
"type": "direct"
}
ParameterTypeDescriptionRequired
namestringThe name of the RabbitMQ exchange.Yes
typestringThe type of exchange (e.g., direct, fanout, topic, or headers).Yes
info

The type of the exchange determines how messages are routed. For example:

  • direct: Routes messages with a specific routing key.
  • fanout: Broadcasts all messages to all queues.
  • topic: Routes messages to queues based on wildcard matching of the routing key.

Response

Success Response

{
"status": 200,
"message": "Exchange created successfully",
"exchangeDetails": {
"name": "example_exchange",
"type": "direct"
}
}
FieldTypeDescription
statusintegerThe HTTP status code of the response.
messagestringA message indicating the operation result.
exchangeDetailsobjectDetails of the created RabbitMQ exchange.
exchangeDetails.namestringThe name of the created exchange.
exchangeDetails.typestringThe type of the created exchange.

Error Response

{
"status": 400,
"error": "Invalid request: Exchange name is required"
}
FieldTypeDescription
statusintegerThe HTTP status code indicating the error.
errorstringA detailed error message explaining the issue.

Example Usage

cURL Command

curl --request POST   --url http://localhost:5672/api/v1/rabbitmq/exchanges   --header 'Content-Type: application/json'   --data '{
"name": "example_exchange",
"type": "direct"
}'
note

Replace http://localhost:5672 with the base URL of your RabbitMQ server.