# REST API

The REST API service starts after the bot receives the ready event.

## Route file example

```js
/*
Type: GET
*/
module.exports = (req, res) => {
  return res.status(200).json({ status: 'ok' });
};
```

## HTTP method declaration

* Add `Type: GET`, `Type: POST`, or another method in the top comment block
* If no method is declared, the route defaults to `GET`
* Use `Type: ALL` to accept every request method

## Notes

* Dynamic params use file names like `[id].js`
* `index.js` maps to the folder root path
* The API server starts only when `api.enabled` is `true`

{% hint style="warning" %}
Keep the method comment at the top of the file. The loader reads it to register the route correctly.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.discremy.com/documentation/project-structure/rest-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
