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

# Create a token for a service account in the current org

> Create an API token for a service account in the current org.

Defaults to a duration of one year (`8760h`) if `duration` is not
specified. If `invalidate` is set, all existing tokens for the service
account are invalidated before the new token is created.




## OpenAPI

````yaml post /v1/service-accounts/{account_id}/tokens
openapi: 3.0.3
info:
  contact:
    email: support@nuon.co
    name: Nuon Support
  description: API for managing nuon apps, components, installs, and actions.
  title: Nuon
  version: 0.19.1099
servers:
  - url: https://api.nuon.co/
security: []
tags:
  - description: orgs
    name: orgs
  - description: components
    name: components
  - description: slack
    name: slack
  - description: auth
    name: auth
  - description: accounts
    name: accounts
  - description: apps
    name: apps
  - description: vcs
    name: vcs
  - description: notebooks
    name: notebooks
  - description: installs
    name: installs
  - description: runners
    name: runners
  - description: actions
    name: actions
  - description: policy-reports
    name: policy-reports
  - description: runners/runner
    name: runners/runner
  - description: runbooks
    name: runbooks
  - description: onboarding
    name: onboarding
  - description: general
    name: general
  - description: queues
    name: queues
  - description: actions/runner
    name: actions/runner
paths:
  /v1/service-accounts/{account_id}/tokens:
    post:
      tags:
        - accounts
      summary: Create a token for a service account in the current org
      description: |
        Create an API token for a service account in the current org.

        Defaults to a duration of one year (`8760h`) if `duration` is not
        specified. If `invalidate` is set, all existing tokens for the service
        account are invalidated before the new token is created.
      operationId: CreateServiceAccountToken
      parameters:
        - description: service account ID
          in: path
          name: account_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/service.CreateServiceAccountTokenRequest'
        description: Input
        required: true
        x-originalParamName: req
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/service.CreateServiceAccountTokenResponse'
          description: Created
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stderr.ErrResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stderr.ErrResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stderr.ErrResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stderr.ErrResponse'
          description: Not Found
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stderr.ErrResponse'
          description: Internal Server Error
      security:
        - APIKey: []
        - OrgID: []
components:
  schemas:
    service.CreateServiceAccountTokenRequest:
      properties:
        duration:
          default: 8760h
          description: Duration defaults to one year.
          type: string
        invalidate:
          type: boolean
      type: object
    service.CreateServiceAccountTokenResponse:
      properties:
        token:
          type: string
      type: object
    stderr.ErrResponse:
      properties:
        description:
          type: string
        error:
          type: string
        user_error:
          type: boolean
      type: object
  securitySchemes:
    APIKey:
      description: Type "Bearer" followed by a space and token.
      in: header
      name: Authorization
      type: apiKey
    OrgID:
      description: Nuon org ID
      in: header
      name: X-Nuon-Org-ID
      type: apiKey

````