> For the complete documentation index, see [llms.txt](https://eventx-hq.gitbook.io/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eventx-hq.gitbook.io/knowledge-base/api-v2/auth.md).

# Auth

Token exchange

## Exchange API key for a JWT

> Accepts an API key (\`user:{userId}:{secret}\`) and returns a short-lived JWT for use as a Bearer token on subsequent API requests.

```json
{"openapi":"3.1.0","info":{"title":"EventX Public API v2","version":"v2"},"tags":[{"name":"auth","description":"Token exchange"}],"servers":[{"url":"https://api.eventx.io","description":"EventX Public API server"}],"paths":{"/auth":{"post":{"tags":["auth"],"summary":"Exchange API key for a JWT","description":"Accepts an API key (`user:{userId}:{secret}`) and returns a short-lived JWT for use as a Bearer token on subsequent API requests.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"apiToken":{"type":"string","minLength":1,"description":"API key: user:<uuid>:<secret>"}},"required":["apiToken"]}}}},"responses":{"200":{"description":"JWT issued successfully","content":{"application/json":{"schema":{"type":"object","properties":{"accessToken":{"type":"string","description":"Bearer JWT"},"userId":{"type":"string","description":"Authenticated user ID"},"expiresIn":{"type":"string","description":"Token expiry duration"}},"required":["accessToken","userId","expiresIn"]}}}},"400":{"description":"Invalid token format","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"status":{"type":"number"},"meta":{}},"required":["code","message","status"]}}}},"401":{"description":"Token not found, disabled, or expired","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"status":{"type":"number"},"meta":{}},"required":["code","message","status"]}}}}}}}}}
```
