Issue a personal access token for the authenticated subject.

Inherits all restrictions of the authenticating PAT, if any.
The token cannot outlive that PAT. JWT tokens expire within seven days;
named PV1 tokens expire within 365 days and appear in the user's token list.

Request

POST

https://api.sourcecraft.tech/user/pats

Body

application/json
{
  "expires_at": "2025-01-01T00:00:00Z",
  "type": "jwt",
  "name": "example",
  "scope": {
    "role": "viewer",
    "repo_ids": [
      "example"
    ]
  }
}

Name

Description

expires_at

Type: string<date-time>

Required. Must be in the future, at most seven days (JWT) or 365 days (PV1)
from now, and no later than the expiration of the authenticating PAT.
Eternal tokens are not supported. Precision is rounded down to seconds.

Example: 2025-01-01T00:00:00Z

name

Type: string

Required for PV1. The display name in the user's token list.
Optional for JWT; JWT tokens do not appear in that list.

Example: example

scope

Type: CreatePATRequest.Scope

Example
{
  "role": "viewer",
  "repo_ids": [
    "example"
  ]
}

type

Type: TokenType

Enum: jwt, pv1

TokenType

Type: string

Enum: jwt, pv1

RepoRole

Type: string

Enum: viewer, contributor, developer, maintainer, admin

CreatePATRequest.Scope

Name

Description

repo_ids

Type: string[]

Public UUIDs of repositories to which the PAT is restricted (at most 100).
Empty means inherit the parent's objects, or all accessible repositories
when authenticating with IAM. Public repositories remain anonymously
readable unless the parent PAT disables anonymous-public access.

Example
[
  "example"
]

role

Type: RepoRole

Enum: viewer, contributor, developer, maintainer, admin

Example
{
  "role": "viewer",
  "repo_ids": [
    "example"
  ]
}

Responses

201 Created

A successful response.

Body

application/json
{
  "token": "example",
  "expires_at": "2025-01-01T00:00:00Z",
  "type": "jwt"
}

Name

Description

expires_at

Type: string<date-time>

Example: 2025-01-01T00:00:00Z

token

Type: string

Credential. Returned only on creation.

Example: example

type

Type: TokenType

Enum: jwt, pv1

default

Both Client Errors (4xx) and Server Errors (5xx) are serialized into this scheme

Body

application/json
{
  "error_code": "example",
  "message": "example",
  "request_id": "example",
  "details": null
}

Name

Description

details

Type: unknown

Example: null

error_code

Type: string

Example: example

message

Type: string

Example: example

request_id

Type: string

Example: example