> For the complete documentation index, see [llms.txt](https://docs.reviactyl.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reviactyl.app/client-api/impersonation.md).

# Client API Impersonation

Client API impersonation lets an authorized application API key make a request as a particular panel user.

### Client API Documentation

The docs for the Reviactyl v26 Client API can be found by going to `/docs/api/client` on your panel.

{% hint style="warning" %}
You must sign in on the login page **before** accessing the docs.
{% endhint %}

```
https://reviactyl.test/docs/api
```

You can also visit the docs on the demo instance [here](https://demo.reviactyl.app/docs/api/client).

### Requirements

The request must use an application API key that:

* belongs to a root administrator;
* has **Read-only** permission for **Impersonation** to make read requests;
* has **Read-write** permission for **Impersonation** to make write requests.

Set this on the application's API key in the admin panel under **API Keys → Create API Key → Permissions → Impersonation**. The selector offers **None**, **Read-only**, and **Read-write**. The stored `r_impersonation` values are `0`, `1`, and `3`, respectively. The middleware checks for read permission on every impersonated request, then checks write permission for non-read-only HTTP methods; therefore, choose **Read-write** for write requests.

### Making a request

Send the target user's numeric database ID or UUID in the `X-Execution-User` header on a client API request. For example, to list that user's servers:

```bash
curl --request GET \
  --url "https://reviactyl.test/api/client" \
  --header "Authorization: Bearer YOUR_APPLICATION_API_KEY" \
  --header "Accept: application/json" \
  --header "X-Execution-User: TARGET_USER_ID_OR_UUID"
```

The response is the client API response for the target user. The application key's owner remains the authenticated caller for authorization and auditing; the target user is used as the request's acting user.

### Errors

* `400 Bad Request`: an application API key called a client API endpoint without `X-Execution-User`.
* `403 Forbidden`: the caller is not a root administrator, the key lacks impersonation permission, or a read-only key attempted a write request.
* `404 Not Found`: the supplied user ID or UUID does not identify a user.

Only send this header with an application API key when impersonation is intended. Keep API keys secret and use the minimum permission level needed.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.reviactyl.app/client-api/impersonation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
