Skip to content

Create a new personal access token​

POST
/users/personalAccessTokens

Mint a new personal access token for the user

Authorizations​

ApiKeyAuth

API Key for authentication. Retrieval from either API version login routes, or other authentication token type. See Authentication for more details.

Type
API Key (header: Authorization)
Example"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Request Body​

application/json
JSON
{
  
"description": "string",
  
"ttl": 0
}

Request example

Responses​

OK

application/json
JSON
{
  
"created": "string",
  
"description": "string",
  
"id": 0,
  
"token": "string",
  
"ttl": 0
}
Try this endpoint

Playground​

Authorization
Body

OpenAPI definition ​

References are expanded below, except recursive definitions and references with sibling fields. Documentation overrides are included. Full original OpenAPI spec (JSON).

View endpoint OpenAPI definition
yaml
info:
  title: Lightbug API
  version: '2'
externalDocs:
  description: ''
  url: ''
openapi: 3.1.0
servers:
  - url: https://api.lightbug.cloud/v2
security:
  - ApiKeyAuth: []
tags: []
paths:
  /users/personalAccessTokens:
    post:
      description: Mint a new personal access token for the user
requestBody:
yaml
        content:
          application/json:
            schema:
              properties:
                description:
                  description: Description of the token
                  type: string
                ttl:
                  description: |-
                    TTL of the token in seconds
                    Default to 1 months
                    Max 1 year
                  maximum: 31536000
                  type: integer
              required:
                - description
              type: object
        description: Create Token
        required: true
yaml
      responses:
'200':
yaml
          content:
            application/json:
              schema:
                properties:
                  created:
                    type: string
                  description:
                    description: Description of the token
                    type: string
                  id:
                    type: integer
                  token:
                    description: The token itself
                    type: string
                  ttl:
                    type: integer
                required:
                  - created
                  - description
                  - token
                  - ttl
                type: object
          description: OK
'400':
yaml
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: 400
                    type: integer
                  message:
                    example: status bad request
                    type: string
                type: object
          description: Bad Request
'401':
yaml
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: 400
                    type: integer
                  message:
                    example: status bad request
                    type: string
                type: object
          description: Unauthorized
'429':
yaml
          content:
            application/json:
              schema:
                type: string
          description: Limit exceeded
          headers:
            X-Ratelimit-Limit:
              schema:
                type: integer
            X-Ratelimit-Remaining:
              schema:
                type: integer
            X-Ratelimit-Reset:
              schema:
                type: integer
yaml
      security:
        - ApiKeyAuth: []
      summary: Create a new personal access token
      tags:
        - personalAccessTokens
      operationId: post-users-personalAccessTokens
components:
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: Authorization
      type: apiKey
      description: API Key for authentication. Retrieval from either API version login routes, or other authentication token type. See <a href='/apis/authentication'>Authentication</a> for more details.
      example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...