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

# サブアカウントのキーを発行

> サブアカウント用の API キーを発行します。



## OpenAPI

````yaml POST /v1/sub-accounts/{id}/keys
openapi: 3.1.0
info:
  title: querying.ai
  description: >-
    One API for every AI answer engine. Every task is asynchronous: submit, then
    collect the result via webhook or polling.
  version: 1.0.0
servers:
  - url: https://api.querying.ai
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/sub-accounts/{id}/keys:
    post:
      tags:
        - Sub-accounts
      summary: Issue a sub-account key
      description: >-
        Issue an API key for the sub-account. The response carries key once;
        store it. Up to 5 active keys per sub-account.
      operationId: createSubAccountKey
      parameters:
        - name: id
          in: path
          required: true
          description: The sub-account id.
          schema:
            type: string
            format: uuid
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubAccountKeyRequest'
            example:
              name: production
              allowedTaskTypes:
                - CHATGPT
                - GEMINI
      responses:
        '201':
          description: The new key, with the raw key in key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubAccountKeyCreatedResponse'
        '400':
          description: A field is missing, out of range or unknown.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: VALIDATION_ERROR
                  message: >-
                    unknown field creditLimit; allowed: name, externalId,
                    monthlyCreditLimit, concurrencyLimit
                  timestamp: '2026-10-09T09:00:00.000Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            The key cannot manage sub-accounts: it has an engine scope or a
            daily credit limit, it is a sub-account's key, or it is an operator
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: SUB_ACCOUNT_FORBIDDEN
                  message: >-
                    Managing sub-accounts needs an API key without an engine
                    scope or a daily credit limit
                  timestamp: '2026-10-09T09:00:00.000Z'
        '404':
          description: No sub-account with this id belongs to your account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: No sub-account with that id
                  timestamp: '2026-10-09T09:00:00.000Z'
        '409':
          description: The sub-account already has 5 active keys.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: KEY_LIMIT
                  message: Max 5 active keys per sub-account — revoke one first
                  timestamp: '2026-10-09T09:00:00.000Z'
components:
  schemas:
    SubAccountKeyRequest:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 64
          default: default
        allowedTaskTypes:
          type: array
          items:
            type: string
          description: >-
            Self-serve engines the key may submit. Empty or absent means all of
            them.
        dailyCreditLimit:
          type:
            - number
            - 'null'
          minimum: 0.01
          multipleOf: 0.01
          maximum: 20000000
        expiresAt:
          type:
            - string
            - 'null'
          format: date-time
          description: Between 5 minutes and 2 years from now.
    SubAccountKeyCreatedResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            keyPrefix:
              type: string
              description: The first 11 characters of the key, for display.
            createdAt:
              type: string
              format: date-time
            allowedTaskTypes:
              type: array
              items:
                type: string
              description: Engines the key may submit. Empty means every self-serve engine.
            dailyCreditLimit:
              type:
                - number
                - 'null'
              description: Credits the key may spend per UTC day. Null means no cap.
            expiresAt:
              type:
                - string
                - 'null'
              format: date-time
            key:
              type: string
              description: The API key (vt_...). Shown in this response only.
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          const: false
        error:
          $ref: '#/components/schemas/ErrorDetail'
    ErrorDetail:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Stable, safe to branch on. See the Errors guide for the full list.
        message:
          type: string
          description: For humans. May change.
        details:
          description: >-
            Context for the error. An array of `{field, message}` on most
            `VALIDATION_ERROR`s; an object elsewhere (for example `{id}` on
            `RESOURCE_NOT_FOUND`, `retryAfterSec` on 429 and 503 codes). Omitted
            when there is nothing to add.
          oneOf:
            - type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
            - type: object
              additionalProperties: true
        timestamp:
          type: string
          format: date-time
  responses:
    Unauthorized:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: MISSING_API_KEY
              message: Missing or invalid API key
              timestamp: '2026-07-09T04:12:00.000Z'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your API key, sent as `Authorization: Bearer <key>`.'

````

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