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

# Create organization API key

> **Auth:** signed-in organization admin only. Organization API keys are rejected with `403`.

Returns the secret **once**. `scopes` defaults to `["read"]`; `expires_in_days` must be 30, 60 or 90 (default 90). At most 20 active keys per organization (`409`).



## OpenAPI

````yaml https://cp.xenovia.io/openapi.json post /api/v1/orgs/{org_id}/keys
openapi: 3.1.0
info:
  title: Xenovia Control Plane API
  version: 1.0.0
  description: >-
    Management API for proxies, providers, policies, telemetry, alerts and
    organization settings.
servers:
  - url: https://cp.xenovia.io
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v1/orgs/{org_id}/keys:
    post:
      tags:
        - api-keys
      summary: Create organization API key
      description: >-
        **Auth:** signed-in organization admin only. Organization API keys are
        rejected with `403`.


        Returns the secret **once**. `scopes` defaults to `["read"]`;
        `expires_in_days` must be 30, 60 or 90 (default 90). At most 20 active
        keys per organization (`409`).
      operationId: create_org_key_route_api_v1_orgs__org_id__keys_post
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
            title: Org Id
        - name: X-Request-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Request-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrgKeyCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgKeyCreatedResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    OrgKeyCreate:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
        expires_in_days:
          type: integer
          enum:
            - 30
            - 60
            - 90
          title: Expires In Days
          default: 90
        scopes:
          items:
            type: string
            enum:
              - read
              - write
          type: array
          minItems: 1
          title: Scopes
          default:
            - read
      type: object
      required:
        - name
      title: OrgKeyCreate
    OrgKeyCreatedResponse:
      properties:
        key:
          type: string
          title: Key
        key_id:
          type: string
          title: Key Id
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        org_id:
          type: string
          format: uuid
          title: Org Id
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Expires At
        scopes:
          items:
            type: string
          type: array
          title: Scopes
          default: []
      type: object
      required:
        - key
        - key_id
        - name
        - org_id
      title: OrgKeyCreatedResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token: an organization API key (`ak_…`) created under Settings →
        API Keys, or a dashboard user session token. Proxy keys (`xe_…`) are not
        accepted here. Endpoints marked as user-only in their description reject
        organization keys with `403`.

````