Sample - GitHub REST API
POST/applications/{client_id}/token/scoped

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.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

1 parameter · 6 body fields
client_idstringrequired
The client ID of the GitHub app.
access_tokenstringrequired
The access token used to authenticate to the GitHub API.
targetstringoptional
The name of the user or organization to scope the user access token to. **Required** unless `target_id` is specified.
target_idintegeroptional
The ID of the user or organization to scope the user access token to. **Required** unless `target` is specified.
repositoriesarray<string>optional
The list of repository names to scope the user access token to. `repositories` may not be specified if `repository_ids` is specified.
repository_idsarray<integer>optional
The list of repository IDs to scope the user access token to. `repository_ids` may not be specified if `repositories` is specified.
permissionsobjectoptional
The permissions granted to the fine-grained access token.

5 status codes
200Response
idintegerrequired
urlstringrequired
scopesarray<string>required
A list of scopes that this authorization is in.
tokenstringrequired
token_last_eightstringrequired
hashed_tokenstringrequired
appobjectrequired
notestringrequired
note_urlstringrequired
updated_atstringrequired
created_atstringrequired
fingerprintstringrequired
userobjectoptional
A GitHub user.
installationobjectoptional
expires_atstringrequired
401Requires authentication
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
403Forbidden
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 401 is returned: Requires authentication. A 403 is returned: Forbidden. A 404 is returned: Resource not found. A 422 is returned: Validation failed, or the endpoint has been spammed.