---
title: Create an access token
slug: andrei/create-an-access-token
createdAt: 2026-10-05T10:36:01.732Z
---

{
  "id": "cKHZaouBvyYEPfm6Yfz3e",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.detected.app/api/v2/public/oauth/token",
    "servers": [
      {
        "url": "https://api.detected.app/api/v2/public/oauth/token",
        "description": "Production"
      }
    ],
    "name": "Create an access token",
    "description": "<p>Requests an OAuth 2.0 access token for your integration client, using the <code>app_credentials</code> grant type. Send the client ID and client secret of the integration client, and your account slug.</p>\n<p>Send the returned <code>access_token</code> in the <code>Authorization</code> header of your requests, in the format <code>Bearer &#x3C;access_token></code>. The token expires after <code>expires_in</code> seconds. Request a new one when it does.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "CreateTokenRequest",
          "schema": [
            {
              "name": "grant_type",
              "kind": "required",
              "type": "string<app_credentials>",
              "description": "<p>Grant type to use. Use <code>app_credentials</code>.</p>",
              "enum": [
                "app_credentials"
              ]
            },
            {
              "name": "client_id",
              "kind": "required",
              "type": "string",
              "description": "<p>Client ID of your integration client, from the dashboard.</p>"
            },
            {
              "name": "client_secret",
              "kind": "required",
              "type": "string",
              "description": "<p>Client secret of your integration client, from the dashboard.</p>"
            },
            {
              "name": "slug",
              "kind": "required",
              "type": "string",
              "description": "Account slug."
            }
          ],
          "modelRef": "#/components/schemas/CreateTokenRequest",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "OK",
        "jsonExample": "",
        "isExpanded": true,
        "headers": [
          {
            "kind": "optional",
            "name": "X-RateLimit-Limit",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "X-RateLimit-Remaining",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "x-ratelimit-reset",
            "description": ""
          },
          {
            "kind": "optional",
            "name": "retry-after",
            "description": ""
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "data",
                "kind": "optional",
                "type": "object",
                "description": "",
                "modelRef": "#/components/schemas/TokenResourceResponse",
                "customType": "TokenResourceResponse",
                "schema": [
                  {
                    "name": "token_type",
                    "kind": "required",
                    "type": "string<Bearer>",
                    "description": "<p>Type of the access token. Always <code>Bearer</code>.</p>",
                    "enum": [
                      "Bearer"
                    ]
                  },
                  {
                    "name": "expires_in",
                    "kind": "required",
                    "type": "number",
                    "description": "Number of seconds until the access token expires."
                  },
                  {
                    "name": "access_token",
                    "kind": "required",
                    "type": "string",
                    "description": "<p>Access token to send in the <code>Authorization</code> header.</p>"
                  }
                ]
              }
            ],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "<p>Bad Request. The request could not be processed because it is invalid. The <code>message</code> field explains why.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": "<p>A human-readable description of the error.</p>"
              }
            ],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "<p>Unauthorized. The access token is missing, invalid or has expired.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": "<p>A human-readable description of the error.</p>"
              }
            ],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "429",
        "description": "<p>Too Many Requests. You have exceeded the rate limit. Wait for the number of seconds given in the <code>Retry-After</code> header before trying again.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": "<p>A human-readable description of the error.</p>"
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.detected.app/api/v2/public/oauth/token \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"grant_type\": \"\",\n     \"client_id\": \"\",\n     \"client_secret\": \"\",\n     \"slug\": \"\"\n     }'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"grant_type\": \"\",\n   \"client_id\": \"\",\n   \"client_secret\": \"\",\n   \"slug\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.detected.app/api/v2/public/oauth/token\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.detected.app/api/v2/public/oauth/token\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"grant_type\": \"\",\n   \"client_id\": \"\",\n   \"client_secret\": \"\",\n   \"slug\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.detected.app/api/v2/public/oauth/token\"\n\npayload = json.dumps({\n   \"grant_type\": \"\",\n   \"client_id\": \"\",\n   \"client_secret\": \"\",\n   \"slug\": \"\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// OK\n{\n  \"data\": {\n    \"token_type\": \"\",\n    \"expires_in\": 0,\n    \"access_token\": \"\"\n  }\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Bad Request. The request could not be processed because it is invalid. The message field explains why.\n{\n  \"message\": \"\"\n}"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Unauthorized. The access token is missing, invalid or has expired.\n{\n  \"message\": \"\"\n}"
        },
        {
          "id": "response-3-429",
          "language": "429",
          "code": "// Too Many Requests. You have exceeded the rate limit. Wait for the number of seconds given in the Retry-After header before trying again.\n{\n  \"message\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}