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

# Create a service account token

> Creates a token for an active service account and returns its value in `token`. The value is shown only in this response, so store it when it is created. The workload sends it as `Authorization: Bearer <token>`. Once the organization has enabled IAM, the service account's roles decide each request it sends. A token without `expires_at` never expires.

This endpoint takes an API key or a Mission Control Portal session, not an OAuth access token.

Only the organization owner can call this endpoint. Its action is `service_account_tokens.create`. Other users and service account tokens get `403`.



## OpenAPI

````yaml /openapi/source/external/iam/iam.json post /iam/service_accounts/{id}/tokens
openapi: 3.1.0
info:
  title: Telnyx API
  version: 1.0.0
  description: >-
    Identity and Access Management (IAM) decides what the users and service
    accounts of an organization may do. The organization writes roles of allow
    and deny statements over actions, gives the roles to users and service
    accounts with grants, and enables IAM so that the grants decide. This API
    manages roles and their statements, grants, the IAM setting, service
    accounts and their tokens, and the organization's API keys and their scopes.
    It also reads the action catalog, explains and simulates decisions, and
    lists access logs.


    Only the organization owner can call these endpoints. Any other user, and
    any service account token, gets `403`. Each endpoint declares an action,
    named in its description. Once IAM is enabled, a scope on one of the owner's
    API keys narrows that key, so the key can call an endpoint only when its
    scope allows the endpoint's action.


    See [IAM](https://developers.telnyx.com/docs/iam) for how decisions are
    made.
  contact:
    email: support@telnyx.com
  x-latency-category: interactive
  x-endpoint-cost: light
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: IAM Roles
    description: >-
      Named sets of statements that the organization gives to users and service
      accounts with grants.
  - name: IAM Role Statements
    description: The statements of a role, each allowing or denying a list of actions.
  - name: IAM Grants
    description: Which users and service accounts hold which roles.
  - name: IAM Actions
    description: The catalog of actions that routes declare and statements allow or deny.
  - name: IAM Settings
    description: Whether the organization has enabled IAM.
  - name: IAM Service Accounts
    description: Principals for workloads, such as servers, pipelines, and integrations.
  - name: IAM Service Account Tokens
    description: The credentials a service account authenticates with.
  - name: IAM API Keys
    description: The API keys of every user of the organization, the owner's included.
  - name: IAM API Key Scopes
    description: Statements on one API key that narrow what it may do.
  - name: IAM Decisions
    description: >-
      What IAM decides for a principal, explained or simulated without changing
      anything.
  - name: IAM Access Logs
    description: >-
      The requests IAM allowed or denied, with the reasons and the roles behind
      them.
paths:
  /iam/service_accounts/{id}/tokens:
    post:
      tags:
        - IAM Service Account Tokens
      summary: Create a service account token
      description: >-
        Creates a token for an active service account and returns its value in
        `token`. The value is shown only in this response, so store it when it
        is created. The workload sends it as `Authorization: Bearer <token>`.
        Once the organization has enabled IAM, the service account's roles
        decide each request it sends. A token without `expires_at` never
        expires.


        This endpoint takes an API key or a Mission Control Portal session, not
        an OAuth access token.


        Only the organization owner can call this endpoint. Its action is
        `service_account_tokens.create`. Other users and service account tokens
        get `403`.
      operationId: CreateIamServiceAccountToken
      parameters:
        - name: id
          in: path
          required: true
          description: The service account's ID.
          schema:
            type: string
            format: uuid
          example: e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IamServiceAccountTokenCreateRequest'
            examples:
              pipeline:
                summary: A token for a release pipeline
                value:
                  name: release-pipeline
                  tags:
                    - ci
                  expires_at: '2027-05-24T00:00:00Z'
      responses:
        '201':
          description: The new token, with its value.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IamServiceAccountTokenCreateResponse'
              example:
                data:
                  id: SAT01A1D0299A618C233DCFFB31B8490913
                  service_account_id: e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2
                  name: release-pipeline
                  tags:
                    - ci
                  status: active
                  expires_at: '2027-05-24T00:00:00.000000Z'
                  last_used_at: null
                  record_type: service_account_token
                  created_at: '2026-11-24T10:06:40.551902Z'
                  updated_at: '2026-11-24T10:06:40.551902Z'
                  token: SAT01A1D0299A618C233DCFFB31B8490913_c2VjcmV0LXNob3duLW9uY2U
        '401':
          $ref: '#/components/responses/IamUnauthorized'
        '403':
          description: >-
            The caller is not the organization owner, or the scope of the
            owner's API key does not allow `service_account_tokens.create`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IamErrors'
              examples:
                not_owner:
                  summary: The caller is not the organization owner
                  value:
                    errors:
                      - code: '10010'
                        title: Authorization failed
                        detail: >-
                          You do not have permission to perform the requested
                          action on the specified resource or resources.
                        source:
                          pointer: /
                        meta:
                          url: >-
                            https://developers.telnyx.com/docs/overview/errors/10010
                key_scope:
                  summary: The scope of the owner's API key does not allow the action
                  value:
                    errors:
                      - code: '10010'
                        title: Authorization failed
                        detail: >-
                          the credential's scope does not allow
                          service_account_tokens.create
                        source:
                          pointer: /
                        meta:
                          url: >-
                            https://developers.telnyx.com/docs/overview/errors/10010
        '404':
          description: The organization has no service account with this ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IamErrors'
              example:
                errors:
                  - code: '10005'
                    title: Resource not found
                    detail: The requested resource or URL could not be found.
                    source:
                      pointer: /service_accounts/:id
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10005
        '422':
          description: >-
            The name is missing or already taken, a field is invalid, or the
            service account is not active.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IamErrors'
              examples:
                duplicate_name:
                  summary: Another token of the service account has this name
                  value:
                    errors:
                      - code: '10012'
                        title: Duplicate resource
                        detail: >-
                          This token name has already been taken for this
                          service account.
                        source:
                          pointer: /name
                        meta:
                          url: >-
                            https://developers.telnyx.com/docs/overview/errors/10012
                inactive_service_account:
                  summary: The service account is not active
                  value:
                    errors:
                      - code: '10027'
                        title: Unprocessable Entity
                        detail: The service account is not active.
                        source:
                          pointer: /service_account_id
                        meta:
                          url: >-
                            https://developers.telnyx.com/docs/overview/errors/10027
                missing_name:
                  summary: The name is missing
                  value:
                    errors:
                      - code: '10004'
                        title: Missing required parameter
                        detail: A required parameter was missing.
                        source:
                          pointer: /name
                        meta:
                          url: >-
                            https://developers.telnyx.com/docs/overview/errors/10004
components:
  schemas:
    IamServiceAccountTokenCreateRequest:
      type: object
      additionalProperties: false
      required:
        - name
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 150
          description: The token's name, unique among the service account's tokens.
        tags:
          type: array
          maxItems: 10
          items:
            type: string
            maxLength: 150
          description: >-
            Up to 10 labels for grouping and filtering tokens, each up to 150
            characters.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the token expires, in the future. Leave it out for a token that
            never expires.
    IamServiceAccountTokenCreateResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/IamServiceAccountTokenWithValue'
    IamErrors:
      type: object
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/IamError'
    IamServiceAccountTokenWithValue:
      type: object
      required:
        - id
        - service_account_id
        - name
        - tags
        - status
        - expires_at
        - last_used_at
        - record_type
        - created_at
        - updated_at
        - token
      properties:
        id:
          type: string
          description: The token's ID, starting with `SAT`.
        service_account_id:
          type: string
          format: uuid
          description: The service account the token belongs to.
        name:
          type: string
          description: The token's name, unique among the service account's tokens.
        tags:
          type: array
          items:
            type: string
          description: Labels for grouping and filtering tokens.
        status:
          type: string
          enum:
            - active
            - inactive
            - expired
          description: >-
            `inactive` once the token is deactivated, and `expired` once its
            `expires_at` has passed.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the token expires. `null` for a token that never expires.
        last_used_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the token last authenticated a request. `null` until it is
            used.
        record_type:
          type: string
          enum:
            - service_account_token
          description: Identifies the type of the resource.
        created_at:
          type: string
          format: date-time
          description: When the token was created.
        updated_at:
          type: string
          format: date-time
          description: When the token was last changed.
        token:
          type: string
          description: >-
            The token's value, `<id>_<secret>`. It is returned only in this
            response.
    IamError:
      type: object
      required:
        - code
        - title
      properties:
        code:
          type: string
          description: The Telnyx error code.
        title:
          type: string
          description: A short summary of the error.
        detail:
          type: string
          description: What went wrong.
        source:
          type: object
          description: The part of the request that caused the error.
          properties:
            pointer:
              type: string
              description: A JSON pointer to the field that caused the error.
            value:
              description: The value that caused the error.
        meta:
          type: object
          properties:
            url:
              type: string
              format: uri
              description: The documentation page for the error code.
            denied_role_ids:
              type: array
              items:
                type: string
                format: uuid
              description: >-
                The granted roles whose deny statements refused the request,
                when a role refused it.
  responses:
    IamUnauthorized:
      description: The request has no valid credential.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/IamErrors'
          example:
            errors:
              - code: '10009'
                title: Authentication failed
                detail: Could not find any usable credentials in the request.
                source:
                  pointer: /
                meta:
                  url: https://developers.telnyx.com/docs/overview/errors/10009
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````