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

> Create a new ngrok-managed access key for AI Gateway traffic.

# Create an AI Gateway access key



## OpenAPI

````yaml openapi/ai-gateway.yaml POST /access-keys
openapi: 3.0.3
info:
  title: AI Gateway APIs
  version: 0.1.0
  description: |
    Control-plane HTTP APIs served by the ai-gateway-control service.
servers:
  - url: https://api.ngrok.ai
security:
  - bearerAuth: []
tags:
  - name: AI Gateway Access Key Configurations
    description: Manage reusable access key configurations (scope and routing rules).
  - name: AI Gateway Access Keys
    description: Manage ngrok-managed access keys associated with AI Gateway endpoints.
  - name: AI Gateway Configuration
    description: >-
      Manage per-account AI Gateway configuration (timeouts, token caps,
      metadata).
  - name: AI Gateway API Keys
    description: Manage customer-facing AI Gateway API Keys.
  - name: AI Gateway Credits
    description: Purchase AI Gateway credits via Stripe Checkout.
  - name: AI Gateway Providers
    description: Manage AI Gateway providers and the models they expose.
  - name: AI Gateway Custom Providers
    description: Manage custom AI Gateway providers and the models they expose.
  - name: AI Gateway Provider Keys
    description: Manage provider keys attached to AI Gateway managed access keys.
  - name: AI Gateway Usage
    description: >-
      Read-only AI Gateway usage events and aggregated usage overview for the
      authenticated account.
paths:
  /access-keys:
    post:
      tags:
        - AI Gateway Access Keys
      summary: Create an AI Gateway access key
      description: Create a new ngrok-managed access key for AI Gateway traffic.
      operationId: CreateAIGatewayAccessKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AIGatewayAccessKeyCreate'
      responses:
        '201':
          description: The created AI Gateway access key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIGatewayAccessKey'
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    AIGatewayAccessKeyCreate:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          maxLength: 255
          description: User-friendly label for this access key.
        description:
          type: string
          maxLength: 255
          description: Human-readable description of this access key.
        metadata:
          type: string
          maxLength: 4096
          description: Arbitrary user-defined metadata for this access key.
        accessKeyConfigurationId:
          type: string
          description: ID of an access key configuration to link. Omit for allow-all scope.
    AIGatewayAccessKey:
      type: object
      additionalProperties: false
      required:
        - id
        - uri
        - createdAt
        - updatedAt
        - createdBy
        - lastUpdatedBy
        - keyRedacted
      properties:
        id:
          type: string
          description: Unique identifier for this access key.
        name:
          type: string
          description: User-friendly label for this access key.
        uri:
          type: string
          description: URI of this AI Gateway Access Key API resource.
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the access key was created.
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when the access key was last updated.
        description:
          type: string
          description: Human-readable description of this access key.
        metadata:
          type: string
          description: Arbitrary user-defined metadata for this access key.
        createdBy:
          $ref: '#/components/schemas/Ref'
        lastUpdatedBy:
          $ref: '#/components/schemas/Ref'
        token:
          type: string
          description: >-
            Plaintext access key token. Only returned when the key is first
            created.
        keyRedacted:
          type: string
          description: Redacted display form of the access key token.
        lastUsed:
          type: string
          format: date-time
          nullable: true
          description: Timestamp when the access key was last used.
        accessKeyConfiguration:
          type: object
          nullable: true
          additionalProperties: false
          description: Linked access key configuration, or null for allow-all scope.
          required:
            - id
            - uri
            - name
          properties:
            id:
              type: string
              description: Configuration ID.
            uri:
              type: string
              description: URI of the linked configuration resource.
            name:
              type: string
              description: Configuration name.
    Ref:
      type: object
      additionalProperties: false
      required:
        - id
        - uri
      properties:
        id:
          type: string
          description: Resource identifier.
        uri:
          type: string
          description: URI for locating the resource.
    Error:
      type: object
      additionalProperties: false
      required:
        - statusCode
        - msg
        - details
      properties:
        errorCode:
          type: string
          description: Stable ngrok error code when available.
        statusCode:
          type: integer
          format: int32
          description: HTTP status code for this error.
        msg:
          type: string
          description: Human-readable error message.
        details:
          type: object
          description: Structured error details.
          additionalProperties:
            type: string
  responses:
    Error:
      description: API error response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````