> For the complete documentation index, see [llms.txt](https://docs.mocklets.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mocklets.com/managing-mock-apis/randomized-responses.md).

# Randomised Responses

The behavior of production APIs in real-world scenarios is all but reliable. Due to various constraints (like network congestion, bad request from client side or even sometimes server failures), your back-end APIs might behave in different ways, producing different responses.

In the **Dynamic Responses** section, we learned that you can add the possible outcome of an API to the Mocklets dashboard. But what if you want your API to return one of the responses randomly instead of the currently active response?

Generating random responses from the API on every request gives a true sense of working with a real-world API.

### How to make an API to return random responses

![](/files/-Lroq57BM-wKMdOaAl5n)

It's very simple to set your API to return random responses on every request. Just enable **Randomised Responses** settings of your API, and your API will starting one the response set in your api on a random basis. If enabled, this setting will override the active response.

{% hint style="info" %}
**Please note** If you have enabled the **Use Api as Proxy**, this feature will be overridden and you will receive the response sent by your proxy server.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.mocklets.com/managing-mock-apis/randomized-responses.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
