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

# Create API key

> Generates a new API key for the authenticated user. Optionally restrict it to a set of scopes (see GET /keys/scopes) and/or brands. Empty scopes or brand_ids mean unrestricted.



## OpenAPI

````yaml /api-reference/openapi.json post /keys
openapi: 3.0.0
info:
  description: >-
    Unified social media inbox API. Read and respond to comments, DMs, reviews,
    and mentions across Instagram, Facebook, Threads, Google Business Profile,
    TikTok, LinkedIn, and YouTube through a single REST API. X/Twitter and
    Trustpilot coming soon.
  title: SocialAPI.AI
  contact:
    name: SocialAPI.AI Support
    email: support@social-api.ai
  license:
    name: MIT
  version: '1.0'
servers:
  - url: https://api.social-api.ai/v1
security: []
paths:
  /keys:
    post:
      tags:
        - API Keys
      summary: Create API key
      description: >-
        Generates a new API key for the authenticated user. Optionally restrict
        it to a set of scopes (see GET /keys/scopes) and/or brands. Empty scopes
        or brand_ids mean unrestricted.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api_endpoints.CreateKeyRequest'
        description: Key name and optional restrictions
        required: true
      responses:
        '201':
          description: Key created (raw key shown once)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.CreateKeyResponse'
        '400':
          description: >-
            Invalid request body, missing name, unknown scope, or invalid brand
            ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.ErrorResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    api_endpoints.CreateKeyRequest:
      type: object
      properties:
        brand_ids:
          description: >-
            BrandIDs restricts the key to specific brands. Empty means all
            brands.
          type: array
          items:
            type: string
        name:
          type: string
          example: My App
        scopes:
          description: >-
            Scopes restricts the key to specific actions. Empty means full
            access.
          type: array
          items:
            type: string
          example:
            - posts:write
            - inbox:read
    api_endpoints.CreateKeyResponse:
      type: object
      properties:
        brand_ids:
          type: array
          items:
            type: string
        id:
          type: string
        message:
          type: string
          example: Store this key securely. It will not be shown again.
        name:
          type: string
        raw_key:
          type: string
          example: sapi_key_...
        scopes:
          type: array
          items:
            type: string
          example:
            - posts:write
            - inbox:read
    api_endpoints.ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/api_endpoints.ErrorBody'
    api_endpoints.ErrorBody:
      type: object
      properties:
        code:
          type: string
          example: resource.not_found
        message:
          type: string
          example: Account not found
        meta:
          type: object
          additionalProperties: {}
  securitySchemes:
    BearerAuth:
      description: >-
        Prefix your API key with "Bearer ". Example: `Authorization: Bearer
        sapi_key_...`
      type: apiKey
      name: Authorization
      in: header

````