> For the complete documentation index, see [llms.txt](https://api-docs.hengelending.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.hengelending.com/api/api-reference/authentication.md). Agents can also search and read this documentation through its [MCP server](https://api-docs.hengelending.com/~gitbook/mcp).

# Authentication

Exchange your application's client credentials for a bearer access token. Every other call except `GET /test/ping` sends it as `Authorization: Bearer <token>`. Reuse the token until `expires_in` runs out instead of requesting one per call.

## Generate an OAuth token

> Errors use the OAuth shape \`{ "error", "error\_description" }\`. The authorization server's 400/401/403/429> \
> pass through with its reason (429 with its \`Retry-After\`); any other upstream failure is> \
> a 502. The submitted secret is never echoed or logged.

```json
{"openapi":"3.0.4","info":{"title":"Henge Partner API","version":"1.22.0"},"tags":[{"name":"Authentication","description":"Exchange your application's client credentials for a bearer access token. Every other call except `GET /test/ping` sends it as `Authorization: Bearer <token>`. Reuse the token until `expires_in` runs out instead of requesting one per call."}],"servers":[{"url":"https://uat-api.hengelending.com/partner","description":"UAT (sandbox): build and test here"},{"url":"https://api.hengelending.com/partner","description":"Production"}],"security":[],"paths":{"/oauth/token":{"post":{"tags":["Authentication"],"summary":"Generate an OAuth token","description":"Errors use the OAuth shape `{ \"error\", \"error_description\" }`. The authorization server's 400/401/403/429\r\npass through with its reason (429 with its `Retry-After`); any other upstream failure is\r\na 502. The submitted secret is never echoed or logged.","operationId":"OAuth_GetAccessToken","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenRequest"}}}},"responses":{"200":{"description":"Access token issued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenResponse"}}}},"400":{"description":"client_id or client_secret missing, or the request was malformed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenErrorResponse"}}}},"401":{"description":"Unknown client or wrong secret","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenErrorResponse"}}}},"403":{"description":"The client may not use client_credentials for the Partner API","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenErrorResponse"}}}},"429":{"description":"Too many token requests; honour Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenErrorResponse"}}}},"502":{"description":"The authorization server is unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenErrorResponse"}}}}}}}},"components":{"schemas":{"TokenRequest":{"required":["client_id","client_secret"],"type":"object","properties":{"client_id":{"type":"string","description":"Your application's client id, issued by Henge."},"client_secret":{"type":"string","description":"Your application's client secret. Keep it server-side; it is never echoed or logged."}},"additionalProperties":false},"TokenResponse":{"type":"object","properties":{"access_token":{"type":"string","description":"The bearer token. Send it as `Authorization: Bearer <token>` on every other call."},"scope":{"type":"string","description":"Space-separated scopes granted to your application. Each endpoint states the scope it needs.","nullable":true},"expires_in":{"type":"integer","description":"Seconds until the token expires. Cache the token and reuse it across calls; get a new one shortly before it expires (for example when under 60 seconds remain), not per request and not in a loop on 401.","format":"int32"},"token_type":{"type":"string","description":"Always `Bearer`.","nullable":true}},"additionalProperties":false},"TokenErrorResponse":{"type":"object","properties":{"error":{"type":"string","description":"The OAuth error code, for example `invalid_client` or `invalid_request`.","nullable":true},"error_description":{"type":"string","description":"A human-readable explanation of the error; omitted when there is none.","nullable":true}},"additionalProperties":false,"description":"The OAuth error body (RFC 6749 section 5.2) `POST /oauth/token` returns on failure."}}}}
```


---

# 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://api-docs.hengelending.com/api/api-reference/authentication.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.
