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

# Add a new user token

> Create a new token for the authenticated user.



## OpenAPI

````yaml /api-reference/openapi.yml post /user/token
openapi: 3.0.3
info:
  title: DataLinks
  version: 2.2.3
servers:
  - url: https://api.datalinks.com/api/v1
    description: production server
security:
  - bearerAuth: []
  - openId:
      - implicit
paths:
  /user/token:
    post:
      tags:
        - user
      summary: Add a new user token
      description: Create a new token for the authenticated user.
      operationId: addToken
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTokenRequest'
        required: true
      responses:
        '200':
          description: Creates a user token and returns it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserToken'
        '403':
          description: Forbidden. Restricted token cannot manage API tokens.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateTokenRequest:
      required:
        - name
      type: object
      properties:
        expires_at:
          type: string
        name:
          type: string
        accessRestrictedTo:
          required:
            - datasets
            - namespaces
          type: array
          items:
            $ref: '#/components/schemas/TokenPermissionEntry'
    UserToken:
      required:
        - created_at
        - expires_at
        - id
        - name
        - token
      type: object
      properties:
        created_at:
          type: string
        expires_at:
          type: string
        id:
          type: string
        last_used_at:
          type: string
        name:
          type: string
        token:
          type: string
          nullable: true
    ErrorResponse:
      required:
        - error_code
        - message
      type: object
      properties:
        error_code:
          type: string
          example: UNAUTHORIZED
        error_message:
          type: string
          example: ''
        message:
          type: string
          example: Missing authentication token
        sub_errors:
          type: array
          items:
            required:
              - code
              - message
            type: object
            properties:
              code:
                type: string
              message:
                type: string
    TokenPermissionEntry:
      required:
        - namespace
        - username
      type: object
      properties:
        username:
          type: string
        namespace:
          type: string
        dataset:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      description: >
        Use a Bearer token for authentication. Submit the token using the
        `Authorization`

        header: `Authorization: Bearer <token>`.
      scheme: bearer
    openId:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: >-
            https://login.datalinks.com/realms/datalinks-realm/protocol/openid-connect/auth
          scopes:
            openid: openid

````