> ## Documentation Index
> Fetch the complete documentation index at: https://docs.promptguard.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Attribute requests to your end users

> Track per-customer usage, cost, threats, and risk by passing a single header on every request

PromptGuard ties each request back to the human (or service) that triggered it via the `X-End-User` header. Once present, every downstream feature, usage analytics, geographic rollups, access lists, abuse investigation, is automatically scoped to that identifier.

## How to set it

Pass `X-End-User` on **every** outbound LLM call. The value is opaque to PromptGuard; it can be a UUID, a hashed email, an internal user id, anything stable per-customer.

```python Python theme={"system"}
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["OPENAI_API_KEY"],  # forwarded to OpenAI
    base_url="https://api.promptguard.co/api/v1",
    default_headers={
        "X-API-Key": os.environ["PROMPTGUARD_API_KEY"],
        "X-End-User": current_user.id,
    },
)
```

```javascript Node.js theme={"system"}
const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY, // forwarded to OpenAI
  baseURL: "https://api.promptguard.co/api/v1",
  defaultHeaders: {
    "X-API-Key": process.env.PROMPTGUARD_API_KEY,
    "X-End-User": currentUser.id,
  },
});
```

```bash cURL theme={"system"}
curl https://api.promptguard.co/api/v1/chat/completions \
  -H "X-API-Key: $PROMPTGUARD_API_KEY" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "X-End-User: customer-42" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "What is the capital of France?"}]}'
```

The [Guard API](https://docs.promptguard.co/api-reference/guard.md) reads the same header, so a request you scan without the proxy is attributed the same way.

Don't put PII in this header. Hash it. The value is logged into every `security_events` row and exposed in the dashboard, exactly the place you don't want raw email addresses.

## What it unlocks

> [card] End-Users page
>
> `Dashboard → End Users` rolls up every value of `X-End-User` you've ever sent: total events, flagged events, flag rate, last seen, computed risk band (`low` / `medium` / `high`).

> [card] Per-end-user blocking
>
> A single rule on the [Allow & Block lists](https://docs.promptguard.co/gateway/access-lists.md) page rejects every future request from one customer, without having to redeploy your app.

> [card] Risk scoring
>
> The risk band is computed over the chosen window (30 days by default). **High**: a flag rate of 25% or more, or 50 or more flagged events. **Medium**: 5% or more, or 10 or more flagged events. Otherwise **low**. Queryable via the API for upstream alerting.

## API: list end-users

```bash theme={"system"}
curl -H "Authorization: Bearer $TOKEN" \
  "https://api.promptguard.co/dashboard/end-users?days=30"
```

Returns the same data the End Users page renders. Pair this with your CRM to flag accounts that are stress-testing your guardrails, and with your billing to surface overage candidates.

## What about anonymous traffic?

If the request doesn't carry `X-End-User`, the row's `end_user_id` is `NULL`, with one exception: a request authenticated by an enrolled Shadow AI device is attributed to that device's own label, which the device cannot edit. Everywhere else the End Users page silently skips a NULL and the per-end-user rules can't fire on it. Set the header on every request, even for anonymous users, at minimum, send a per-session UUID. The dashboard becomes useless without it.

> [!WARNING]
>
> `end_user_id` is an **attribution label**, not a verified identity. It is whatever string you send, or whatever label a device carries, and PromptGuard never validates it. The one place a person is actually proven is device enrolment: a Device a Member approved in their own browser session is bound to that account, and the fleet device list reports `identity_verified` for it. Nothing on this page carries that guarantee, so do not build access decisions on a label alone.

## Next steps

> [card] [Request tags](https://docs.promptguard.co/gateway/request-tags.md)
>
> Label requests and filter their events by label

> [card] [Access lists](https://docs.promptguard.co/gateway/access-lists.md)
>
> Allow or deny by IP, CIDR, end-user ID or country

> [card] [Analytics cookbook](https://docs.promptguard.co/platform/analytics-cookbook.md)
>
> SQL for latency, tokens, risky users and blocks


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.