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

# Create Domain

> Register a new sending domain with your account. The domain will be created with SparkPost and stored as approved by default, unless global domain reputation marks it for review or blacklist.

Adds a new sending domain to your team. After creating, you'll need to add the required DNS records and [verify the domain](/api-reference/domains/verify-domain) before you can send from it.


## OpenAPI

````yaml POST /domains
openapi: 3.1.0
info:
  title: Lettr API
  version: 1.0.0
  description: >-
    Lettr Email API - Send transactional emails with tracking, attachments, and
    personalization.
  contact:
    name: Lettr Support
    url: https://lettr.com
  license:
    name: Proprietary
    url: https://lettr.com/terms
servers:
  - url: https://app.lettr.com/api
    description: Production
security: []
tags:
  - name: Emails
    description: Email sending operations
  - name: Templates
    description: Email template management operations
  - name: Domains
    description: Domain management operations
  - name: Webhooks
    description: Webhook management operations
  - name: Audience
    description: 'Audience management: lists, contacts, topics, properties, and segments'
  - name: Campaigns
    description: >-
      Campaign operations: listing, stats, engagement events, and
      dispatch/scheduling
paths:
  /domains:
    post:
      tags:
        - Domains
      summary: Create Domain
      description: >-
        Register a new sending domain with your account. The domain will be
        created with SparkPost and stored as approved by default, unless global
        domain reputation marks it for review or blacklist.
      operationId: createDomain
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StoreDomainRequest'
            example:
              domain: example.com
      responses:
        '201':
          description: Domain created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StoreDomainResponse'
              example:
                message: Domain created successfully.
                data:
                  domain: example.com
                  status: approved
                  status_label: Approved
                  dkim:
                    public: MIGfMA0GCSqGSIb3DQEBA...
                    selector: scph0123
                    headers: from:to:subject:date
                    signing_domain: example.com
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '409':
          description: Conflict - Domain already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: This domain is already registered.
                error_code: resource_already_exists
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
              example:
                message: Validation failed.
                error_code: validation_error
                errors:
                  domain:
                    - >-
                      The domain must be a valid domain name (e.g.,
                      example.com).
        '500':
          description: Server error - Failed to create domain
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: We could not register your domain. Please try again later.
                error_code: send_error
      security:
        - bearerAuth: []
components:
  schemas:
    StoreDomainRequest:
      type: object
      description: Request to create a new sending domain
      required:
        - domain
      properties:
        domain:
          type: string
          maxLength: 255
          pattern: ^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$
          description: The domain name to register (e.g., example.com)
          example: example.com
    StoreDomainResponse:
      type: object
      description: Response after successfully creating a domain
      required:
        - message
        - data
      properties:
        message:
          type: string
          description: Human-readable success message
          example: Domain created successfully.
        data:
          $ref: '#/components/schemas/DomainView'
    ErrorResponse:
      type: object
      required:
        - message
        - error_code
      description: Error response for non-validation errors (400, 409, 500, 502).
      properties:
        message:
          type: string
          description: Human-readable error message
          example: The sender domain could not be determined from the email address.
        error_code:
          $ref: '#/components/schemas/ErrorCode'
    ValidationErrorResponse:
      type: object
      required:
        - message
        - error_code
        - errors
      properties:
        message:
          type: string
          description: Human-readable error message
          example: Validation failed.
        error_code:
          type: string
          description: Error code (always `validation_error` for 422 responses)
          const: validation_error
          example: validation_error
        errors:
          type: object
          description: Field-specific validation errors
          additionalProperties:
            type: array
            items:
              type: string
          example:
            from:
              - The sender email address is required.
            to:
              - At least one recipient email address is required.
    DomainView:
      type: object
      description: View of a sending domain
      required:
        - domain
        - status
        - status_label
      properties:
        domain:
          type: string
          description: The domain name
          example: example.com
        status:
          type: string
          enum:
            - pending
            - approved
            - blocked
          description: Current status of the domain
          example: pending
        status_label:
          type: string
          description: Human-readable status label
          example: Pending Review
        dkim:
          type:
            - object
            - 'null'
          description: DKIM configuration for the domain
          properties:
            public:
              type: string
              description: Public DKIM key
            selector:
              type: string
              description: DKIM selector
            headers:
              type: string
              description: Headers to sign
            signing_domain:
              type: string
              description: >-
                Domain used for DKIM signing. Normally matches the top-level
                `domain` field.
    UnauthorizedResponse:
      type: object
      required:
        - message
      description: Error response for authentication failures (401).
      properties:
        message:
          type: string
          description: Human-readable error message
          example: API key is required.
    ErrorCode:
      type: string
      description: >-
        Error codes returned by the API.


        | Code | HTTP Status | Description |

        |------|-------------|-------------|

        | `validation_error` | 422 | Request validation failed. Check the
        `errors` object for field-specific messages. |

        | `invalid_domain` | 400 | The sender domain could not be determined
        from the email address. |

        | `unconfigured_domain` | 400 | The sender domain is not configured or
        approved for sending. |

        | `send_error` | 400, 500 | General error during email send preparation
        or domain registration. |

        | `retrieval_error` | 400, 500 | Failed to retrieve resources (e.g.,
        sandbox key without associated user, upstream error). |

        | `transmission_failed` | 502 | Email transmission to the upstream
        provider failed. |

        | `resource_already_exists` | 409 | The resource (e.g., domain) already
        exists. |

        | `not_found` | 404 | The specified resource was not found. |

        | `template_not_found` | 404 | The specified template, project, or
        template version was not found. |

        | `insufficient_scope` | 403 | The API key does not have the required
        scope for this endpoint. |

        | `schedule_cancellation_failed` | 409, 500 | Could not cancel the
        scheduled transmission (already sent or upstream error). |

        | `quota_exceeded` | 429 | Monthly sending quota exceeded. Upgrade your
        plan to continue sending. |

        | `daily_quota_exceeded` | 429 | Daily sending quota exceeded. Try again
        tomorrow. |

        | `campaign_not_sendable` | 422 | The campaign cannot be sent in its
        current state (not a draft, or missing subject/sender/content). |

        | `campaign_not_scheduled` | 422 | The campaign is not scheduled, so it
        cannot be unscheduled. |
      enum:
        - validation_error
        - invalid_domain
        - unconfigured_domain
        - send_error
        - retrieval_error
        - transmission_failed
        - resource_already_exists
        - not_found
        - template_not_found
        - insufficient_scope
        - schedule_cancellation_failed
        - quota_exceeded
        - daily_quota_exceeded
        - campaign_not_sendable
        - campaign_not_scheduled
      example: invalid_domain
  responses:
    UnauthorizedError:
      description: Unauthorized - Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedResponse'
          examples:
            missing_key:
              summary: Missing API key
              value:
                message: API key is required.
            invalid_key:
              summary: Invalid API key
              value:
                message: Invalid API key.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````