Skip to content
GitmoapAPIBeta
Organizeaccess-tokens
POST/user/tokens

Create a personal access token for the authenticated user

create_personal_token
  • token:manage
    A token needs the token:manage scope: Create and revoke access tokensGranted by write_api.Every operation this scope unlocks
  • Audited · mutation

    x-gitmoap-audit: {"kind":"audited","arg":"mutation"}

  • Quota · tokens per principal

    x-gitmoap-quota: {"kind":"enforced","arg":"tokens_per_principal"}

Mints a personal access token carrying the scopes you name. A bundle is expanded into its scopes now, so the token never gains a scope added to the platform later. Bind it to one group or repository to keep it there. The response holds the token itself once, and never again: store it straight away.

Request body

application/json
  • namestring
  • scopesarray of string
  • expires_in_daysinteger · int32 or nulloptional0–∞Days until the token expires. Omit for a non-expiring token.
  • resourceTokenResourceBinding or nulloptionalOptional resource binding restricting the token to one subtree.
Request body exampleSynthesized example
{
"name": "payments-api",
"scopes": [
"scopes-f6b0",
"scopes-86e1"
]
}

Responses

201Token created; plaintext returned onceapplication/json
  • access_tokenAccessTokenView
    • The AccessTokenView schema
    • access_token_idAccessTokenId (string · uuid)
    • created_atstring
    • namestring
    • principal_idstring
    • principal_kindTokenPrincipalKinduserservice_accountagentThe kind of principal an access token authenticates as.
    • scopesarray of string
    • expires_atstring or nulloptional
    • last_used_atstring or nulloptional
    • oauthAccessTokenOAuth or nulloptionalPresent when an app connected through sign-in minted this token. Revoking it disconnects the app.
    • resource_scope_idstring or nulloptional
    • resource_scope_typeScopeTypegrouprepositoryor nulloptional
  • tokenstringThe plaintext token. Store it securely — it is not shown again.
201 exampleSynthesized example
{
"access_token": {
"access_token_id": "4632103c-ab42-40fb-904e-e46917337015",
"created_at": "2026-10-10T09:24:20Z",
"name": "payments-api",
"principal_id": "06f7848a-0555-436e-95fe-1e51dd5569b0",
"principal_kind": "user",
"scopes": [
"scopes-fad1"
],
"expires_at": "2026-10-11T13:58:23Z",
"last_used_at": "2026-10-09T08:25:02Z",
"oauth": {
"client_name": "payments-api",
"grant_id": "5972bd9e-bec3-4574-80ff-769eb1900660"
},
"resource_scope_id": "a3f26174-49d9-4637-a5ac-54fe9a4d2545",
"resource_scope_type": "group"
},
"token": "token-db9b"
}
400Invalid requestapplication/json
Error codes
  • BAD_REQUESTThe request is malformed: a parameter or a body field is not a well-formed value of its type
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
400 exampleSynthesized example
{
"error": {
"code": "code-9446",
"message": "Inline scalar newtypes but keep their brand"
}
}
401Unauthorizedapplication/json
Error codes
  • UNAUTHORIZEDNo credential was sent, or the one sent is invalid, expired or revoked
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
401 exampleSynthesized example
{
"error": {
"code": "code-5075",
"message": "Inline scalar newtypes but keep their brand"
}
}
403Forbidden — the caller's access level or token scope is insufficientapplication/json
Error codes
  • FORBIDDENYou are signed in but may not do this here; reason names the permission or the rule that refused it
  • INSUFFICIENT_SCOPEThe access token lacks the scope this operation needs; required_scope names it
  • PERMISSION_REQUIREDYou need a permission you do not hold here; the message names it
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
403 exampleSynthesized example
{
"error": {
"code": "code-54f4",
"message": "Pin a page's payload to the build that rendered it"
}
}
409The request conflicts with the resource's current state; `reason` says howapplication/json
Error codes
  • CONFLICTThe request conflicts with the resource's current state; reason says how
  • LEGAL_ACCEPTANCE_REQUIREDAccept the current Terms of Service before changing anything; reading stays open
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
409 exampleSynthesized example
{
"error": {
"code": "code-0670",
"message": "Pin a page's payload to the build that rendered it"
}
}
429Token limit reached for this userapplication/json
Error codes
  • TOO_MANY_REQUESTSRetryableA quota, a rate limit or a transfer budget is spent. When the response carries Retry-After, retry after that many seconds
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
429 exampleSynthesized example
{
"error": {
"code": "code-fb35",
"message": "Inline scalar newtypes but keep their brand"
}
}

CLI

gitmoap access-tokens create-personal-token

  • --expires-in-daysnumberoptionalDays until the token expires. Omit for a non-expiring token.
  • --namestring
  • --resourcejsonoptional
  • --scopesjson

Used in these guides