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

# Authentication

Request an OAuth 2.0 access token to authenticate your API calls.

## Create an access token

> Requests an OAuth 2.0 access token for your integration client, using the \`app\_credentials\` grant type. Send the client ID and client secret of the integration client, and your account slug.\
> \
> Send the returned \`access\_token\` in the \`Authorization\` header of your requests, in the format \`Bearer \<access\_token>\`. The token expires after \`expires\_in\` seconds. Request a new one when it does.

```json
{"openapi":"3.0.0","info":{"title":"Detected API","version":"v2"},"tags":[{"name":"Authentication","description":"Request an OAuth 2.0 access token to authenticate your API calls."}],"servers":[{"url":"https://api.detected.app/api/v2/public","description":"Production"}],"security":[],"paths":{"/oauth/token":{"post":{"tags":["Authentication"],"summary":"Create an access token","description":"Requests an OAuth 2.0 access token for your integration client, using the `app_credentials` grant type. Send the client ID and client secret of the integration client, and your account slug.\n\nSend the returned `access_token` in the `Authorization` header of your requests, in the format `Bearer <access_token>`. The token expires after `expires_in` seconds. Request a new one when it does.","operationId":"a6ea5ec24e11aec46eafe891371465d0","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTokenRequest"}}}},"responses":{"200":{"description":"OK","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/TokenResourceResponse"}},"type":"object"}}}},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"429":{"$ref":"#/components/responses/429"}}}}},"components":{"schemas":{"CreateTokenRequest":{"title":"Create Token Request","required":["grant_type","client_id","client_secret","slug"],"properties":{"grant_type":{"description":"Grant type to use. Use `app_credentials`.","type":"string","enum":["app_credentials"],"nullable":false},"client_id":{"description":"Client ID of your integration client, from the dashboard.","type":"string","nullable":false},"client_secret":{"description":"Client secret of your integration client, from the dashboard.","type":"string","nullable":false},"slug":{"description":"Account slug.","type":"string","nullable":false}},"type":"object"},"TokenResourceResponse":{"title":"Token Resource Response","required":["token_type","expires_in","access_token"],"properties":{"token_type":{"description":"Type of the access token. Always `Bearer`.","type":"string","enum":["Bearer"],"nullable":false},"expires_in":{"description":"Number of seconds until the access token expires.","type":"number","nullable":false},"access_token":{"description":"Access token to send in the `Authorization` header.","type":"string","nullable":false}},"type":"object"}},"headers":{"X-RateLimit-Limit":{"description":"Maximum number of requests allowed in the rate limit window.","schema":{"type":"number","nullable":false}},"X-RateLimit-Remaining":{"description":"Number of requests remaining in the current rate limit window.","schema":{"type":"number","nullable":false}},"Retry-After":{"description":"Number of seconds to wait before making another request. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}},"X-RateLimit-Reset":{"description":"Unix timestamp (in seconds) at which the rate limit resets. Returned when the rate limit has been reached.","schema":{"type":"number","nullable":false}}},"responses":{"400":{"description":"Bad Request. The request could not be processed because it is invalid. The `message` field explains why.","content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}},"401":{"description":"Unauthorized. The access token is missing, invalid or has expired.","content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}},"429":{"description":"Too Many Requests. You have exceeded the rate limit. Wait for the number of seconds given in the `Retry-After` header before trying again.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"properties":{"message":{"description":"A human-readable description of the error.","type":"string"}},"type":"object"}}}}}}}
```


---

# 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://detected.gitbook.io/detected-docs/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.
