# Assign New Mailboxes to Domains

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v2/mailboxes:
    post:
      summary: Assign New Mailboxes to Domains
      deprecated: false
      description: "This endpoint allows you to assign new mailboxes to specific domains.\n\n### Validation Rules\n\n1. Payload Structure\n\t-\tThe root object must have domain IDs as keys.\n\t-\tEach value must be an array of mailbox objects.\n\t-\tArrays cannot be empty.\n\n2. Mailbox Object Validation\n\t-\tEach mailbox object must include firstName, lastName, mailboxUsername, and domainName.\n\t-\tmailboxUsername must:\n\t\t1. Not start or end with ., _, or -.\n\t\t2. Not contain consecutive ., _, or -.\n\t\t3. **firstName**, **lastName**, and **domainName** must be strings.\n\n3. Microsoft Service Provider Rule\n\t-\tFor users with Microsoft, mailboxes cannot be assigned if previously assigned mailboxes are not yet active.\n\n4. Subscription and Quota Checks\n\t-\tUsers must have purchased mailboxes available for assignment.\n\t-\tThe total mailboxes being assigned cannot exceed the remaining mailbox quota.\n\t-\tScheduled and \"immedidate delete\" mailboxes in a subscription is deducted from the quota.\n\n5. Per-Domain Assignment Limit\n\t-\tTotal mailboxes assigned to a single domain cannot exceed **5**"
      tags:
        - mailbox
      parameters:
        - name: x-auth-zapmail
          in: header
          description: ''
          required: true
          example: ''
          schema:
            type: string
        - name: x-workspace-key
          in: header
          description: ''
          required: false
          example: ''
          schema:
            type: string
        - name: ' x-service-provider'
          in: header
          description: ''
          required: false
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                domainId:
                  type: array
                  items:
                    type: object
                    properties:
                      firstName:
                        type: string
                      lastName:
                        type: string
                      mailboxUsername:
                        type: string
                      domainName:
                        type: string
                    x-apidog-orders:
                      - firstName
                      - lastName
                      - mailboxUsername
                      - domainName
              required:
                - domainId
              x-apidog-orders:
                - domainId
                - 01K7EG7NV917N662E42K8HTVWY
            example:
              64e71b99-bc07-4b5d-90b6-6abc0120c08c:
                - firstName: Jaspreet
                  lastName: Singh
                  mailboxUsername: jaspreet
                  domainName: azhaz.com
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
          headers: {}
          x-apidog-name: Success
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  message:
                    type: string
                  errorId:
                    type: string
                required:
                  - status
                  - message
                  - errorId
                x-apidog-orders:
                  - status
                  - message
                  - errorId
          headers: {}
          x-apidog-name: No slots remaining
        '403':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  message:
                    type: string
                  errorId:
                    type: string
                required:
                  - status
                  - message
                  - errorId
                x-apidog-orders:
                  - status
                  - message
                  - errorId
          headers: {}
          x-apidog-name: Unauthorized
        '422':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  message:
                    type: string
                  errorId:
                    type: string
                required:
                  - status
                  - message
                  - errorId
                x-apidog-orders:
                  - status
                  - message
                  - errorId
          headers: {}
          x-apidog-name: Invalid Payload
        x-400:24 Hour Rule:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  message:
                    type: string
                  errorId:
                    type: string
                required:
                  - status
                  - message
                  - errorId
                x-apidog-orders:
                  - status
                  - message
                  - errorId
          headers: {}
          x-apidog-name: 24 Hour Rule
      security: []
      x-apidog-folder: mailbox
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/797058/apis/api-13490321-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://api.zapmail.ai/api
    description: Prod Env
security: []

```
