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

# Add an Agent Mail address

> Adds one address to the workspace. Two forms:

* `{ "previewId": "…" }` confirms a quote from
  `POST /v1/emails/addresses/preview`. A paid address ($2/mo) is
  charged to the saved card now; an included one (one per paid Lusor
  Phone, `free: true` on the quote) is not charged.
* `{}` adds an address included with the workspace's Lusor Phones,
  without a quote. It needs an `Idempotency-Key`. If no included
  address is left the answer is `402 inbox_payment_required`:
  preview its price instead.

Either form may name the address's `username` (the part before the
`@`); without one the address gets a generated name. A
quote previewed with a `username` confirms only with that same
`username` (otherwise `409 preview_expired`). A name taken since the
quote is `409 username_taken` before any charge; one taken in the last
instant is refused after the charge and the charge is reversed.

Callers: an API key for the workspace, or a tenant administrator.

**Retries:** safe. With a `previewId` and no `Idempotency-Key`, the
quote itself is the request key, so a confirmed quote replays its
stored receipt (`created: false`) and never charges twice. With a
key, a repeat with the same key returns the same address.




## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/emails/addresses
openapi: 3.1.0
info:
  title: Lusor API
  version: 0.1.0
  description: |
    Run AI agents on real phones, or drive a phone directly with
    deterministic actions.

    ## Authentication

    Every `/v1/*` endpoint except `GET /v1/health` requires an API key.
    Create one in the Lusor dashboard under **Settings → API Keys**. A key
    is shown once and is bound to one workspace. Revoking it there stops it
    working immediately.

    Send it in either header:

    - `X-Api-Key: <your API key>`
    - `Authorization: Bearer <your API key>`

    Because a key is bound to its workspace, `workspaceId` query and body
    parameters are optional for API-key callers. A request that names a
    different workspace returns an opaque `404`.

    ## Runs

    `POST /v1/agent` runs one task on a phone and returns its id; read the
    result with `GET /v1/agent/{id}`.

    To keep a conversation with an agent instead, use
    `POST /v1/agents/{id}/turns` to start or continue an agent run.
    Read the run under `/v1/sessions/{id}`; poll
    `GET /v1/sessions/{id}/status` or `GET /v1/sessions/{id}/events` for
    progress.

    ## Errors

    Errors are JSON: `{ "error": "<code>", "message": "<text>" }`. A
    request that fails validation returns `400` in one of two shapes,
    depending on the endpoint: `{ "error": "validation_error", "details":
    { ... } }` (direct phone control actions, for example), or
    `{ "error": "bad_request", "message": "<text>" }` (agent endpoints, for
    example). Branch on `error`.
  contact:
    name: Lusor
    url: https://lusor.ai
  license:
    name: Proprietary
    url: https://lusor.ai/terms
servers:
  - url: https://api.lusor.ai
    description: Production
security:
  - ApiKey: []
  - BearerAuth: []
tags:
  - name: Agent
    description: |
      One call runs a task on a phone and returns its result: the answer
      as `data` (text, or the object a schema describes) and the run's
      recording.
  - name: Scrape
    description: |
      One call reads one screen of an app: the screen as Markdown, fields
      read off it, and its picture.
  - name: Interact
    description: |
      Keep working on the screen an agent or scrape task left open, then
      stop.
  - name: Map
    description: |
      List an app's known screens as `app://` addresses, from the screens
      earlier runs passed through. Never walks a phone.
  - name: Agents
    description: Persistent agents, the phone each one uses, and their turns (runs).
  - name: Secrets
    description: |
      Secrets saved in a workspace (passwords, sign-in details). A run uses
      them by name through `secrets`; values never travel in a request.
  - name: Sessions
    description: |
      Run records: list, inspect, stop, and read events and artifacts. Start
      a run with `POST /v1/agents/{id}/turns`, or without an agent through
      `POST /v1/workspaces/{workspaceId}/devices/{deviceId}/sessions`.
  - name: LiveView
    description: |
      View-only WebRTC live view of a session's phone: signaling, ICE
      servers, and stream control. API keys get live view only on the
      customer's own phone, not on a Lusor Phone.
  - name: Devices
    description: |
      The phones in your workspace, and reads of their current screen and
      UI tree.
  - name: DeviceVerbs
    description: |
      Direct phone control: deterministic actions (tap, swipe, type, key,
      clear, back, home, recent, screenshot, apps/start, apps/stop) and
      chains of them. On a Lusor Phone, API-key calls meter phone minutes.
  - name: Shell
    description: |
      Restricted shell escape hatch. Commands are checked against a
      denylist and audit-logged. No command output is returned.
  - name: Datasets
    description: Lists a run produced, saved as reusable Datasets.
  - name: Skills
    description: Reusable automation skills (Markdown documents).
  - name: PhoneNumbers
    description: |
      Workspace phone numbers and their stored SMS messages. Read-only for
      API keys.
  - name: Emails
    description: >
      Workspace Agent Mail addresses and stored inbound mail. Addresses

      are added and removed through a quote (billed to the workspace's

      Inbox plan). Mail is read-only: there is no compose, reply, or send
      endpoint, and message

      bodies are returned as raw plain text without HTML execution, remote

      asset fetches, or code extraction.
  - name: Workspaces
    description: The workspace an API key is bound to.
  - name: Billing
    description: The account's plan and the credits it has left.
  - name: Catalog
    description: The catalog of apps that can be installed on a Lusor Phone.
  - name: AppInstalls
    description: |
      Install catalog apps on a phone, follow the installs, and uninstall
      them. Viewers cannot install.
  - name: Notifications
    description: |
      Notifications the workspace's phones forward, the apps each phone
      forwards, and the rules that act on them. Read-only for API keys.
  - name: Files
    description: Files the workspace's agents saved from its phones. Read-only.
  - name: ModelKeys
    description: |
      The workspace's own OpenAI or Anthropic API key, used by its runs
      instead of Lusor's (paid plans).
  - name: Health
    description: Service health check.
paths:
  /v1/emails/addresses:
    post:
      tags:
        - Emails
      summary: Add an Agent Mail address
      description: |
        Adds one address to the workspace. Two forms:

        * `{ "previewId": "…" }` confirms a quote from
          `POST /v1/emails/addresses/preview`. A paid address ($2/mo) is
          charged to the saved card now; an included one (one per paid Lusor
          Phone, `free: true` on the quote) is not charged.
        * `{}` adds an address included with the workspace's Lusor Phones,
          without a quote. It needs an `Idempotency-Key`. If no included
          address is left the answer is `402 inbox_payment_required`:
          preview its price instead.

        Either form may name the address's `username` (the part before the
        `@`); without one the address gets a generated name. A
        quote previewed with a `username` confirms only with that same
        `username` (otherwise `409 preview_expired`). A name taken since the
        quote is `409 username_taken` before any charge; one taken in the last
        instant is refused after the charge and the charge is reversed.

        Callers: an API key for the workspace, or a tenant administrator.

        **Retries:** safe. With a `previewId` and no `Idempotency-Key`, the
        quote itself is the request key, so a confirmed quote replays its
        stored receipt (`created: false`) and never charges twice. With a
        key, a repeat with the same key returns the same address.
      operationId: addEmailAddress
      parameters:
        - $ref: '#/components/parameters/WorkspaceIdQuery'
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            minLength: 1
            maxLength: 255
            pattern: ^[\x21-\x7E]+$
          description: >-
            Required without a `previewId`. 1–255 visible ASCII characters; the
            same key returns the same address. A key that belonged to a deleted
            address returns `409 request_key_reused`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailAddressAddInput'
      responses:
        '200':
          description: The address and the Inbox plan after the change
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: '#/components/schemas/InboxAddressAddResult'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            `payment_failed` (the card was declined; nothing changed) or
            `inbox_payment_required` (no included address is left: preview its
            price).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/InboxChangeConflict'
        '422':
          $ref: '#/components/responses/InboxUsernameRefused'
        '503':
          $ref: '#/components/responses/InboxUnavailable'
components:
  parameters:
    WorkspaceIdQuery:
      name: workspaceId
      in: query
      required: false
      schema:
        type: string
        format: uuid
      description: |
        Workspace the request is scoped to. Optional for API keys: a key is
        bound to one workspace when it is created, and naming any other
        workspace returns an opaque 404.
  schemas:
    EmailAddressAddInput:
      type: object
      additionalProperties: false
      properties:
        previewId:
          type: string
          format: uuid
          description: >-
            The `previewId` of an unexpired quote. Omit it (send `{}`) to add an
            included address with an `Idempotency-Key`.
        username:
          $ref: '#/components/schemas/EmailAddressUsername'
    InboxAddressAddResult:
      type: object
      required:
        - status
        - quantity
        - paymentPending
        - created
        - address
      properties:
        status:
          type: string
          description: Billing status after the change.
        quantity:
          type: integer
          description: Paid Inbox addresses on the plan.
        paymentPending:
          type: boolean
          const: false
        created:
          type: boolean
          description: >-
            False when this request was already applied and its address is
            returned again.
        address:
          type: object
          required:
            - id
            - address
            - workspaceId
          properties:
            id:
              type: string
              format: uuid
            address:
              type: string
              description: The new mailbox address.
            workspaceId:
              type: string
              format: uuid
    ErrorResponse:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
        message:
          type: string
    EmailAddressUsername:
      type: string
      minLength: 1
      maxLength: 255
      description: |
        The address's name before the `@`, case-insensitive (stored
        lowercase). 3–30 characters of `a-z`, `0-9`, `.`, `_`, `-`, starting
        and ending with a letter or digit, never two of `.`, `_`, `-` in a row.
        Unique across all workspaces, deleted addresses included. Reserved
        names (e.g. `admin`, `postmaster`, `support`, `noreply`) are refused.
        Omit it for a generated name.
      example: alice.smith
    ValidationErrorResponse:
      type: object
      required:
        - error
        - details
      properties:
        error:
          type: string
          example: validation_error
        details:
          type: object
          additionalProperties: true
  responses:
    ValidationError:
      description: |
        Request validation failed. Either `validation_error` with per-field
        `details`, or `bad_request` with a `message`, depending on the
        endpoint.
      content:
        application/json:
          schema:
            anyOf:
              - $ref: '#/components/schemas/ValidationErrorResponse'
              - $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Authentication required or invalid credentials.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: The caller may not perform this action.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InboxChangeConflict:
      description: >
        The change was refused; nothing was charged or removed. `error` is one
        of:

        `no_subscription` (no paid plan), `checkout_open`, `payment_pending`,

        `preview_expired` (the quote expired, is unknown, or the plan changed
        since: preview again),

        `last_item` (the Inbox is the plan's only item: cancel the plan in
        billing management),

        `request_key_reused` (the `Idempotency-Key` belonged to a deleted
        address),

        `username_taken` (the chosen `username` is already an address, live or
        deleted),

        or `change_unresolved` (an earlier plan change has not settled).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InboxUsernameRefused:
      description: |
        The chosen `username` was refused; nothing was quoted or charged.
        `error` is `username_invalid` (the format rules) or
        `username_reserved` (a reserved name).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InboxUnavailable:
      description: |
        `billing_unavailable` (on a confirmation the outcome is unknown:
        retry with the SAME `previewId`), `address_unavailable` (no address
        could be created right now) or `inbox_not_configured`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: Workspace API key, created in the dashboard under Settings → API Keys.
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        The same workspace API key, sent as `Authorization: Bearer <your API
        key>`.

````

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