> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cnap.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a personal access token

> Creates a new PAT. The full token is returned in the response and never shown again.



## OpenAPI

````yaml /openapi.json post /v1/user/tokens
openapi: 3.1.0
info:
  title: CNAP API
  version: 1.0.0
  description: >-
    Public API for managing CNAP workspaces, clusters, templates, products, and
    deployments.


    Authenticate with a Personal Access Token via the `Authorization: Bearer
    cnap_pat_...` header.


    Workspace-scoped endpoints require the `X-Workspace-Id` header.
servers:
  - url: https://api.cnap.tech
    description: Production
security: []
paths:
  /v1/user/tokens:
    post:
      tags:
        - Auth
      summary: Create a personal access token
      description: >-
        Creates a new PAT. The full token is returned in the response and never
        shown again.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 100
                  description: Human-readable name for the token
                  example: My CLI token
                expires_at:
                  type: integer
                  exclusiveMinimum: 0
                  description: >-
                    Unix timestamp (seconds) when the token expires. Omit for no
                    expiry.
                  example: 1742169600
              required:
                - name
      responses:
        '201':
          description: Token created. The `token` field is shown only once.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedToken'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - BearerAuth: []
components:
  schemas:
    CreatedToken:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        token:
          type: string
          description: The full token. This is shown only once — store it securely.
          example: cnap_pat_a3b2c4d5e6f7g8h9i0j1k2l3m4n5o6p7
      required:
        - id
        - name
        - token
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: not_found
            message:
              type: string
              example: Resource not found
            param:
              type: string
              description: The request field that caused the error
              example: name
            suggestion:
              type: string
              example: Run `cnap clusters list` to see available clusters
            details: {}
          required:
            - code
            - message
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Personal Access Token (cnap_pat_...) or OAuth2 JWT. Create tokens at
        https://cnap.tech/account/tokens

````