> For the complete documentation index, see [llms.txt](https://docs.crimsonq.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.crimsonq.io/server-interfaces/rest-interface.md).

# REST Interface

CrimsonQ has its own REST API

You can control CrimsonQ from REST APIs, whether you need to manage the consumers, or push messages or even consume them. The only downside with REST APIs is the lack of constant connectivity to the server to know when a message is enqueued in the queue. This can be done with the Websocket connection though.&#x20;

We recommend to use the RESP interface with your applications to communicate with the CrimsonQ.&#x20;

CrimsonQ by default opens port 8080 and exposes the commmands to `HTTP://DOMAIN:8080/api` path.&#x20;

{% hint style="warning" %}
If you use the REST interface you will need to poll the route `/api/msg/counts/:consumerId` with a timer, this keeps the consumer alive and not expire, this will also allow you to know if new messages have arrived to the pending state.&#x20;
{% endhint %}

### Authentication&#x20;

To authenticate and be able to use the REST API you will need to generate a JWT token by authenticating through `POST /login` and **pass Form data** `Username` & `Password`. This will return a JWT token in a JSON Object, you will then need to use the JWT token to authenticate with every API request by `sending the token as Authorization as Bearer.`

### REST Commands&#x20;

You can find the list of commands you can use below;&#x20;

<table><thead><tr><th width="150">Method</th><th width="292">HTTP Route</th><th width="150">Arguments</th><th>Returns</th></tr></thead><tbody><tr><td>GET</td><td>/api/command</td><td></td><td>{JSON} List of comands</td></tr><tr><td>GET</td><td>/api/consumer/concurrency/ok/:consumerId</td><td>consumerId</td><td>{JSON} Returns true or false depending on if the consumer has bandwidth to process messages</td></tr><tr><td>GET </td><td>/api/consumer/info/:consumerId</td><td>consumerId</td><td>{JSON} Returns consumer information.</td></tr><tr><td>GET</td><td>/api/consumer/exists/:consumerId</td><td>consumerId</td><td>JSON</td></tr><tr><td>GET</td><td>/api/consumer/list</td><td></td><td>{JSON} List of all consumers</td></tr><tr><td>GET</td><td>/api/consumer/topics/get/:consumerId</td><td>consumerId</td><td>{JSON} Returns the topics the consumer is listening on</td></tr><tr><td>GET</td><td>/api/info</td><td></td><td>{JSON} CrimsonQ Server Information</td></tr><tr><td>GET</td><td>/api/msg/counts/:consumerId</td><td>consumerId</td><td>{JSON} List Count of messages grouped by status</td></tr><tr><td>GET</td><td>/api/msg/keys/:consumerId</td><td>consumerId</td><td>{JSON} List of all keys prefixed with status</td></tr><tr><td>GET</td><td>/api/msg/list/json/:consumerId/:status</td><td>consumerId - status</td><td>{JSON} Gets all of the messages' body for a spesific consumerId and Status</td></tr><tr><td>GET</td><td>/api/msg/pull/:consumerId</td><td>consumerId</td><td>{JSON} Pulls and returns a message with its body</td></tr><tr><td>GET</td><td>/api/ping/:messageString</td><td>messageString</td><td>{JSON} Returns Pong! + [messageString]</td></tr><tr><td>POST</td><td>/login</td><td>Username - Password</td><td>{JSON} JWT Token</td></tr><tr><td>POST</td><td>/api/consumer/concurrency/set</td><td>consumerId - concurrency</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/consumer/create</td><td>consumerId - topics - concurrency</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/consumer/destroy</td><td>consumerId</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/consumer/flush/complete</td><td>consumerId</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/consumer/flush/failed</td><td>consumerId</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/consumer/topics/set</td><td>consumerId - topics</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/msg/complete</td><td>consumerId - messageId</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/msg/del</td><td>consumerId - status - messageId</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/msg/fail</td><td>consumerId - messageId - errMsg</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/msg/push/consumer</td><td>consumerId - messageString</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/msg/push/topic</td><td>topicString - messageString</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/msg/retryall</td><td>consumerId</td><td>{JSON} ok or Error</td></tr><tr><td>POST</td><td>/api/msg/retry</td><td>consumerId - messageId</td><td>{JSON} ok or Error</td></tr></tbody></table>
