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

# Claim or rent a mailbox

> Reserves a permanently-allocated, individually-rented mailbox and starts an Autumn rental checkout. An optional localPart selects the full address local part; omitting it keeps the default random, non-guessable mx_-prefixed address. The address is withheld until the first payment is confirmed. Idempotent on (owner, clientRequestId): same key + payload replays (200); a conflicting or already-held local part returns 409. 201 when the checkout URL is already persisted, otherwise 202 (poll GET for the URL).



## OpenAPI

````yaml /api-reference/mobilerun-mailbox.yaml post /mailboxes
openapi: 3.1.0
info:
  title: Mobilerun Mailbox
  version: v1
servers:
  - description: Droidrun Cloud API
    url: https://api.mobilerun.ai/v1
security:
  - bearerAuth: []
paths:
  /mailboxes:
    post:
      tags:
        - Mailboxes
      summary: Claim or rent a mailbox
      description: >-
        Reserves a permanently-allocated, individually-rented mailbox and starts
        an Autumn rental checkout. An optional localPart selects the full
        address local part; omitting it keeps the default random, non-guessable
        mx_-prefixed address. The address is withheld until the first payment is
        confirmed. Idempotent on (owner, clientRequestId): same key + payload
        replays (200); a conflicting or already-held local part returns 409. 201
        when the checkout URL is already persisted, otherwise 202 (poll GET for
        the URL).
      operationId: createMailbox
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMailboxRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/Mailbox'
                required:
                  - data
                type: object
          description: Existing mailbox returned (idempotent replay)
        '201':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/Mailbox'
                required:
                  - data
                type: object
          description: Mailbox rented; checkout URL persisted
        '202':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/Mailbox'
                required:
                  - data
                type: object
          description: Mailbox reserved; checkout URL still being minted (poll GET)
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '409':
          description: Conflict
        '422':
          content:
            application/json:
              schema:
                properties:
                  error:
                    type: string
                required:
                  - error
                type: object
          description: Invalid or unavailable custom local part
        '429':
          content:
            application/json:
              schema:
                properties:
                  error:
                    type: string
                required:
                  - error
                type: object
          description: Too Many Requests
        '500':
          description: Internal Server Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Mobilerun from '@mobilerun/sdk';


            const client = new Mobilerun({
              apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
            });


            const mailbox = await client.mailboxes.create({ clientRequestId: 'x'
            });


            console.log(mailbox.data);
        - lang: Python
          source: |-
            import os
            from mobilerun_sdk import Mobilerun

            client = Mobilerun(
                api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"),  # This is the default and can be omitted
            )
            mailbox = client.mailboxes.create(
                client_request_id="x",
            )
            print(mailbox.data)
components:
  schemas:
    CreateMailboxRequest:
      properties:
        billingPreference:
          $ref: '#/components/schemas/MailboxBillingPreference'
        clientRequestId:
          maxLength: 128
          minLength: 1
          type: string
        label:
          maxLength: 100
          type: string
        localPart:
          description: >-
            Optional full mailbox local part (the address before "@"). Trimmed
            and lowercased before validation. Omit for a random, non-guessable
            mx_-prefixed address.
          example: jane-doe
          maxLength: 64
          minLength: 1
          pattern: ^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,62}[A-Za-z0-9])?$
          type: string
      required:
        - clientRequestId
      type: object
    Mailbox:
      properties:
        address:
          example: mx_7k3q9p2m4v8d@inbox.example
          type:
            - string
            - 'null'
        billingMode:
          $ref: '#/components/schemas/MailboxBillingMode'
        cancelAtPeriodEnd:
          type: boolean
        checkoutExpiresAt:
          format: date-time
          type:
            - string
            - 'null'
        checkoutUrl:
          type:
            - string
            - 'null'
        createdAt:
          format: date-time
          type: string
        currentPeriodEnd:
          format: date-time
          type:
            - string
            - 'null'
        id:
          format: uuid
          type: string
        inboundMessages:
          $ref: '#/components/schemas/MailboxInboundMessagesUsage'
        label:
          maxLength: 100
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/MailboxStatus'
      required:
        - id
        - address
        - label
        - status
        - billingMode
        - cancelAtPeriodEnd
        - checkoutUrl
        - checkoutExpiresAt
        - currentPeriodEnd
        - createdAt
        - inboundMessages
      type: object
    MailboxBillingPreference:
      description: >-
        Funding preference. Omit or use included for included-first activation;
        rent always preserves package capacity and starts paid checkout.
      enum:
        - included
        - rent
      type: string
    MailboxBillingMode:
      enum:
        - rent
        - included
      type: string
    MailboxInboundMessagesUsage:
      properties:
        exhausted:
          type: boolean
        included:
          minimum: 0
          type: integer
        resetsAt:
          format: date-time
          type:
            - string
            - 'null'
        used:
          minimum: 0
          type: integer
      required:
        - used
        - included
        - exhausted
        - resetsAt
      type: object
    MailboxStatus:
      enum:
        - provisioning
        - awaiting_payment
        - active
        - cancel_scheduled
        - archived
        - billing_error
      type: string
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````