> 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/use-api-as-proxy.md).

# Use API as Proxy

When working with an existing API it can be useful to pass some requests through to it for testing, while serving mock responses for others.

For instance, if an API is not yet fully implemented then testing progress can still be made for the calling application by mocking the parts not yet completed.

Additionally, proxying all but a selection of APIs enables testing of edge and failure cases that would be hard to replicate predictably in the target API.

### How to configure proxy settings

![](/files/-LronXuSq-ARQwByE1WM)

You can configure proxy settings for each of your mock API. All you have to do is click the **Configure proxy server** icon and provide the the proxy url you want to forward your mock API request.

![](/files/-LromOXTd_AX9rgtJxj5)

Once you are done with configuring your proxy settings, you can now enable **Use API as Proxy** settings to start proxing your call to the provided url.

![](/files/-LrooYjwRYK-31znduZM)

Once a mock API is configured and enabled to serve a proxy response, all of the normal request matching rules apply, but instead of returning a saved response, the request is forwarded to the target url.

The endpoint of a request’s URL will be replaced by the proxy url i.e. `if` a request made to `https://api.mocklets.com/mock12675/pets` would result in a proxy request to `https://your.server.com/pets`.

Whenever a request is proxied, Mocklets adds 2 headers to the response with the details about the proxied request.

```
x-mocklets-proxy-url: https://your.server.com/pets
x-mocklets-type: proxy
```


---

# 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/use-api-as-proxy.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.
