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

# Create API key

> Create an API credential. Its token is returned once.

Required permission: `api_keys:manage`.



## OpenAPI

````yaml /openapi.json post /api-keys
openapi: 3.1.0
info:
  title: Moonemail API
  version: 0.1.0
  description: >-
    Generated request, response and authorization contract. Covers authenticated
    product endpoints, not public discovery, dashboard assets or Stripe inbound
    webhooks. Go handlers enforce state-dependent and cross-field business
    validation.
servers:
  - url: https://api.moonemail.co
security: []
paths:
  /api-keys:
    post:
      tags:
        - API keys
      summary: Create API key
      description: |-
        Create an API credential. Its token is returned once.

        Required permission: `api_keys:manage`.
      operationId: create_api_key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 50
                permission:
                  type: string
                  enum:
                    - full_access
                    - sending_access
                    - scoped_access
                scopes:
                  type: array
                  items:
                    type: string
                    enum:
                      - inboxes:read
                      - inboxes:write
                      - receiving:read
                      - emails:send
                      - emails:read
                      - emails:update
                      - domains:read
                      - domains:write
                      - domains:delete
                      - webhooks:read
                      - webhooks:write
                      - webhooks:delete
                      - suppressions:read
                      - suppressions:write
                      - suppressions:delete
                  minItems: 1
                  maxItems: 15
                domain_id:
                  type: string
                  format: uuid
                expires_at:
                  type: string
              required:
                - name
              additionalProperties: false
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    const: api_key
                  id:
                    type: string
                  token:
                    type: string
                    description: Returned once. Save securely.
                  hint:
                    type: string
                  permission:
                    type: string
                    enum:
                      - full_access
                      - sending_access
                      - scoped_access
                  scopes:
                    type: array
                    items:
                      type: string
                      enum:
                        - inboxes:read
                        - inboxes:write
                        - receiving:read
                        - emails:send
                        - emails:read
                        - emails:update
                        - domains:read
                        - domains:write
                        - domains:delete
                        - webhooks:read
                        - webhooks:write
                        - webhooks:delete
                        - suppressions:read
                        - suppressions:write
                        - suppressions:delete
                  expires_at:
                    type:
                      - string
                      - 'null'
                required:
                  - object
                  - id
                  - token
                  - hint
                  - permission
                  - scopes
                  - expires_at
                additionalProperties: true
        default:
          description: API error
          content:
            application/json:
              schema:
                type: object
                required:
                  - statusCode
                  - name
                  - message
                properties:
                  statusCode:
                    type: integer
                  name:
                    type: string
                  message:
                    type: string
      security:
        - bearerKey: []
components:
  securitySchemes:
    bearerKey:
      type: http
      scheme: bearer
      description: Moonemail API key; x-required-scope applies.

````

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