> ## Documentation Index
> Fetch the complete documentation index at: https://factory-docs-auto-sync-jp-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a service account API key

> Mints a new API key for a service account and returns the one-time key value. The value is shown only once and cannot be retrieved later.



## OpenAPI

````yaml https://api.factory.ai/api/v0/openapi.json post /api/v0/service-accounts/{serviceAccountId}/api-keys
openapi: 3.0.1
info:
  title: Factory Public API
  description: >-
    Public API for Factory platform. Requires authentication via the
    `Authorization: Bearer` header.
  version: 0.1.0
servers:
  - url: https://api.factory.ai/
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v0/service-accounts/{serviceAccountId}/api-keys:
    post:
      tags:
        - Service Accounts
      summary: Create a service account API key
      description: >-
        Mints a new API key for a service account and returns the one-time key
        value. The value is shown only once and cannot be retrieved later.
      operationId: createServiceAccountApiKey
      parameters:
        - name: serviceAccountId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
            description: Service account ID
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateServiceAccountApiKeyRequestBody'
      responses:
        '201':
          description: Response for status 201
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey201ResponseBody'
        '400':
          description: Response for status 400
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey400ResponseBody'
        '401':
          description: Response for status 401
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey401ResponseBody'
        '402':
          description: Response for status 402
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey402ResponseBody'
        '403':
          description: Response for status 403
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey403ResponseBody'
        '404':
          description: Response for status 404
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey404ResponseBody'
        '409':
          description: Response for status 409
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey409ResponseBody'
        '500':
          description: Response for status 500
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateServiceAccountApiKey500ResponseBody'
components:
  schemas:
    CreateServiceAccountApiKeyRequestBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 128
        expiresAt:
          type: integer
          exclusiveMinimum: true
          minimum: 0
      required:
        - name
      additionalProperties: false
    CreateServiceAccountApiKey201ResponseBody:
      type: object
      properties:
        apiKey:
          type: object
          properties:
            id:
              type: string
              minLength: 1
              description: API key ID
            value:
              type: string
              minLength: 1
              description: One-time presentation key value, returned only on creation
            fingerprint:
              type: string
              minLength: 1
              description: Non-reversible suffix for display
            name:
              type: string
              minLength: 1
              description: Human-readable name for the key
            expiresAt:
              type: number
              description: Unix epoch milliseconds when the key expires, if set
          required:
            - id
            - value
            - fingerprint
            - name
          additionalProperties: false
      required:
        - apiKey
      additionalProperties: false
    CreateServiceAccountApiKey400ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    CreateServiceAccountApiKey401ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    CreateServiceAccountApiKey402ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    CreateServiceAccountApiKey403ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    CreateServiceAccountApiKey404ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    CreateServiceAccountApiKey409ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    CreateServiceAccountApiKey500ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Factory API key or JWT token for authentication

````