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

# Create token

> Create a new personal access token with specified permissions and project access.



## OpenAPI

````yaml /openapi/brms.json post /api/users/service/{userId}/personal-access-tokens
openapi: 3.0.3
info:
  title: GoRules BRMS
  version: local
servers: []
security: []
tags:
  - name: AI
    description: >-
      AI-powered assistant for interactive conversations and decision logic
      generation
  - name: Audit log
    description: Track and export organisation activity logs for compliance and monitoring
  - name: Branches
    description: >-
      Manage feature branches for collaborative decision development with
      commits and merging
  - name: Change requests
    description: Review and approve changes before merging or deploying to environments
  - name: Cloud
    description: Cloud-specific endpoints for organisation and client management
  - name: Decision
    description: Evaluate and simulate decision graphs with trace and performance data
  - name: Deployment workflows
    description: Manage deployment workflow runs and job approvals
  - name: Deployments
    description: Configure cloud storage providers for release deployments
  - name: Document
    description: Manage decision documents, versions, and file operations within projects
  - name: Environment
    description: >-
      Configure deployment environments with approval workflows and access
      tokens
  - name: Group
    description: Manage permission groups for project-level access control
  - name: Infrastructure
    description: Health check and infrastructure status endpoints
  - name: Integration
    description: Configure external integrations for HTTP requests and data sources
  - name: Invitation
    description: Manage organisation invitations for new members
  - name: Member
    description: Manage project membership and group assignments
  - name: Organisation
    description: Manage organisation settings, preferences, and licensing
  - name: Personal access token
    description: Create and manage personal access tokens for API authentication
  - name: Profile
    description: Manage current user profile settings
  - name: Project
    description: Create and manage projects with approval workflows
  - name: Release
    description: >-
      Package, version, and deploy decision documents. Learn more about
      [Releases](https://gorules.io/developers/brms/multi-environment)
  - name: Roles
    description: Define custom roles with permissions for organisation-wide access control
  - name: Security
    description: Manage project access tokens for API authentication
  - name: Templates
    description: Browse and apply project templates for quick onboarding
  - name: Test events
    description: Manage test events for decision evaluation and testing
  - name: User
    description: Manage organisation users, invitations, and service accounts
paths:
  /api/users/service/{userId}/personal-access-tokens:
    post:
      tags:
        - Personal access token
      summary: Create token
      description: >-
        Create a new personal access token with specified permissions and
        project access.
      operationId: createPersonalAccessToken
      parameters:
        - schema:
            type: string
            nullable: true
            format: uuid
          in: path
          name: userId
          required: true
          description: Service user ID to create token for (admin only)
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                note:
                  type: string
                  minLength: 1
                  maxLength: 100
                  example: Token used to generate releases
                  description: A descriptive note for the token (1-100 characters)
                allProjects:
                  type: boolean
                  description: Indicates if token can be used for all projects.
                projects:
                  type: array
                  items:
                    type: string
                    format: uuid
                  default: []
                  description: >-
                    List of projects where token can be used. Applicable if
                    allProjects is false.
                permissions:
                  type: array
                  items:
                    type: string
                    enum:
                      - owner
                      - documents
                      - releases
                      - releases:manage
                      - releases:deploy
                      - releases:delete
                      - integrations:manage
                      - documents:full
                      - documents:view-content
                      - documents:edit-content
                      - documents:edit-view
                      - branches
                      - branches:create
                      - branches:merge
                      - branches:delete
                      - project:manage
                      - environments
                      - environments:manage
                      - environments:delete
                  default: []
                  description: List of permissions to grant to the token
                expiry:
                  type: string
                  enum:
                    - week
                    - month
                    - three_months
                    - year
                    - indefinite
                  description: >-
                    Token expiration period (week, month, three_months, year, or
                    indefinite)
              required:
                - note
                - allProjects
                - expiry
        required: true
      responses:
        '200':
          description: Created personal access token with the generated token value
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier of the personal access token
                  note:
                    type: string
                    description: Description or note for the token
                  permissions:
                    type: array
                    items:
                      type: string
                      enum:
                        - owner
                        - documents
                        - releases
                        - releases:manage
                        - releases:deploy
                        - releases:delete
                        - integrations:manage
                        - documents:full
                        - documents:view-content
                        - documents:edit-content
                        - documents:edit-view
                        - branches
                        - branches:create
                        - branches:merge
                        - branches:delete
                        - project:manage
                        - environments
                        - environments:manage
                        - environments:delete
                    description: List of permissions granted to this token
                  allProjects:
                    type: boolean
                    description: Whether the token has access to all projects
                  projects:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: Unique identifier of the project
                        name:
                          type: string
                          description: Name of the project
                        key:
                          type: string
                          description: Project key
                        organisationId:
                          type: string
                          format: uuid
                          description: Organisation ID the project belongs to
                        version:
                          type: string
                          description: Project version
                        createdAt:
                          type: string
                          description: Timestamp when the project was created
                        updatedAt:
                          type: string
                          description: Timestamp when the project was last updated
                        protected:
                          type: boolean
                          description: Whether the project is protected
                      required:
                        - id
                        - name
                        - organisationId
                        - version
                        - createdAt
                        - updatedAt
                    description: List of projects the token has access to
                  user:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: Unique identifier of the user
                      email:
                        type: string
                        format: email
                        description: Email address of the user
                      firstName:
                        type: string
                        nullable: true
                        description: First name of the user
                      lastName:
                        type: string
                        nullable: true
                        description: Last name of the user
                      type:
                        type: string
                        description: User type (e.g., member, admin, owner)
                      status:
                        type: string
                        description: User status (e.g., active, disabled)
                      isService:
                        type: boolean
                        description: Whether the user is a service account
                      createdAt:
                        type: string
                        description: Timestamp when the user was created
                      updatedAt:
                        type: string
                        description: Timestamp when the user was last updated
                    required:
                      - id
                      - email
                      - type
                      - status
                      - createdAt
                      - updatedAt
                    description: User who owns the token
                  createdAt:
                    type: string
                    description: Timestamp when the token was created
                  updatedAt:
                    type: string
                    description: Timestamp when the token was last updated
                  expiresAt:
                    type: string
                    nullable: true
                    description: Timestamp when the token expires, null if indefinite
                  token:
                    type: string
                    description: >-
                      The generated token value (only returned on create or
                      regenerate)
                required:
                  - id
                  - note
                  - permissions
                  - allProjects
                  - projects
                  - user
                  - createdAt
                  - updatedAt
                  - token
                description: Created personal access token with the generated token value
      security:
        - internalAuth: []
components:
  securitySchemes:
    internalAuth:
      type: http
      scheme: internal
      description: Cannot be used directly

````