v56

latestOpenAPI 3.0.3MITraw.githubusercontent.com2026-08-011,21696712.2 MB
apps

Create a scoped access token

Use a non-scoped user access token to create a repository-scoped and/or permission-scoped user access token. You can specify which repositories the token can access and which permissions are granted to the token.

Invalid tokens will return 404 NOT FOUND.

post/applications/{client_id}/token/scoped

Path parameters

client_idstring required

The client ID of the GitHub app.

Request body

access_tokenstring required

The access token used to authenticate to the GitHub API.

targetstring

The name of the user or organization to scope the user access token to. Required unless target_id is specified.

target_idinteger

The ID of the user or organization to scope the user access token to. Required unless target is specified.

repositoriesstring[]

The list of repository names to scope the user access token to. repositories may not be specified if repository_ids is specified.

repository_idsinteger[]

The list of repository IDs to scope the user access token to. repository_ids may not be specified if repositories is specified.

Example request

{
  "access_token": "e72e16c7e42f292c6912e7710c838347ae178b4a",
  "target": "octocat",
  "target_id": 1,
  "repositories": [
    "rails"
  ],
  "repository_ids": [
    1
  ],
  "permissions": {
    "contents": "read",
    "issues": "read",
    "deployments": "write",
    "single_file": "read"
  }
}

Response

Response

idinteger required
urlstring uri required
scopesstring[] nullable required

A list of scopes that this authorization is in.

tokenstring required
token_last_eightstring nullable required
hashed_tokenstring nullable required
notestring nullable required
note_urlstring uri nullable required
updated_atstring date-time required
created_atstring date-time required
fingerprintstring nullable required
expires_atstring date-time nullable required

Example response

{
  "user": {
    "login": "octocat",
    "id": 1,
    "node_id": "MDQ6VXNlcjE=",
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "gravatar_id": "41d064eb2195891e12d0413f63227ea7",
    "url": "https://api.github.com/users/octocat",
    "html_url": "https://github.com/octocat",
    "followers_url": "https://api.github.com/users/octocat/followers",
    "following_url": "https://api.github.com/users/octocat/following{/other_user}",
    "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
    "organizations_url": "https://api.github.com/users/octocat/orgs",
    "repos_url": "https://api.github.com/users/octocat/repos",
    "events_url": "https://api.github.com/users/octocat/events{/privacy}",
    "received_events_url": "https://api.github.com/users/octocat/received_events",
    "type": "User",
    "starred_at": "\"2020-07-09T00:17:55Z\"",
    "user_view_type": "public"
  },
  "installation": {
    "permissions": {
      "contents": "read",
      "issues": "read",
      "deployments": "write",
      "single_file": "read"
    },
    "single_file_name": "config.yaml",
    "has_multiple_single_files": true,
    "single_file_paths": [
      "config.yml",
      ".github/issue_TEMPLATE.md"
    ],
    "repositories_url": "https://api.github.com/users/octocat/repos",
    "account": {
      "login": "octocat",
      "id": 1,
      "node_id": "MDQ6VXNlcjE=",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "41d064eb2195891e12d0413f63227ea7",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "starred_at": "\"2020-07-09T00:17:55Z\"",
      "user_view_type": "public"
    }
  }
}