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

# Create an inference key

> Create an inference key for all endpoints or a list of endpoints, with an optional expiry. The secret is returned once. Requires the keys:write scope.



## OpenAPI

````yaml api-reference/openapi.json POST /v1/keys
openapi: 3.1.0
info:
  title: TokenChange API
  description: >-
    Manage TokenChange resources with a gateway API token. Errors share one
    envelope: `{"error":{"type","code","message"}}`.
  license:
    name: ''
  version: '1'
servers:
  - url: https://api.tokenchange.io
security: []
tags:
  - name: models
    description: Catalog models and endpoints
  - name: keys
    description: Inference API keys
  - name: usage
    description: Usage analytics
  - name: billing
    description: Credit balance and history
  - name: provider
    description: Your provider account, endpoints, validations and earnings
paths:
  /v1/keys:
    post:
      tags:
        - keys
      operationId: create_key
      parameters:
        - name: Idempotency-Key
          in: header
          description: Makes retries safe for 24 hours
          required: false
          schema:
            type:
              - string
              - 'null'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKeyBody'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedKey'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
        - bearer:
            - keys:write
components:
  schemas:
    CreateKeyBody:
      type: object
      required:
        - name
      properties:
        endpoint_ids:
          type: array
          items:
            type: string
        expires_at:
          type:
            - string
            - 'null'
          description: RFC 3339 timestamp; omit for a key that never expires.
        name:
          type: string
        scope:
          oneOf:
            - $ref: '#/components/schemas/KeyScope'
              description: >-
                Defaults to `all`. `endpoints` restricts the key to
                `endpoint_ids`.
            - type: 'null'
      additionalProperties: false
    CreatedKey:
      type: object
      description: >-
        A key with its plaintext secret. The secret is shown only in this
        response.
      required:
        - key
        - secret
      properties:
        key:
          $ref: '#/components/schemas/Key'
        secret:
          type: string
    ErrorBody:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
    KeyScope:
      type: string
      enum:
        - all
        - endpoints
    Key:
      type: object
      required:
        - id
        - name
        - prefix
        - scope
        - endpoint_ids
        - status
        - created_at
        - updated_at
      properties:
        created_at:
          type: string
        endpoint_ids:
          type: array
          items:
            type: string
        expires_at:
          type:
            - string
            - 'null'
        id:
          type: string
        last_used_at:
          type:
            - string
            - 'null'
        name:
          type: string
        prefix:
          type: string
        scope:
          $ref: '#/components/schemas/KeyScope'
        status:
          $ref: '#/components/schemas/KeyStatus'
        updated_at:
          type: string
    ErrorDetail:
      type: object
      required:
        - type
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
        resource_id:
          type:
            - string
            - 'null'
        type:
          type: string
    KeyStatus:
      type: string
      enum:
        - active
        - revoked
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: A gateway API token (`tcg_…`) created in the dashboard

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.