> ## 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.

# Get the best OTP candidate

> Returns the highest-confidence, most recent OTP for the mailbox, restricted to messages of completed/active paid intervals. Does not wait server-side (SDKs poll). 200 with the best code, 204 when none matches.



## OpenAPI

````yaml /api-reference/mobilerun-mailbox.yaml get /mailboxes/{mailboxId}/otp
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/{mailboxId}/otp:
    get:
      tags:
        - Mailboxes
      summary: Get the best OTP candidate
      description: >-
        Returns the highest-confidence, most recent OTP for the mailbox,
        restricted to messages of completed/active paid intervals. Does not wait
        server-side (SDKs poll). 200 with the best code, 204 when none matches.
      operationId: getMailboxOtp
      parameters:
        - in: path
          name: mailboxId
          required: true
          schema:
            format: uuid
            type: string
        - in: query
          name: after
          required: false
          schema:
            format: date-time
            type: string
        - in: query
          name: sender
          required: false
          schema:
            type: string
        - in: query
          name: minLength
          required: false
          schema:
            default: 4
            maximum: 12
            minimum: 3
            type: integer
        - in: query
          name: maxLength
          required: false
          schema:
            default: 8
            maximum: 12
            minimum: 3
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/MailboxOtp'
                required:
                  - data
                type: object
          description: Best OTP candidate
        '204':
          description: No matching OTP yet
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                properties:
                  error:
                    type: string
                required:
                  - error
                type: object
          description: Not Found
        '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 response = await
            client.mailboxes.otp('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');


            console.log(response.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
            )
            response = client.mailboxes.otp(
                mailbox_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )
            print(response.data)
components:
  schemas:
    MailboxOtp:
      properties:
        code:
          description: String to preserve leading zeros
          example: '042911'
          type: string
        confidence:
          $ref: '#/components/schemas/OtpConfidence'
        messageId:
          type: string
        receivedAt:
          format: date-time
          type: string
        sender:
          type:
            - string
            - 'null'
        subject:
          type:
            - string
            - 'null'
      required:
        - code
        - confidence
        - messageId
        - sender
        - subject
        - receivedAt
      type: object
    OtpConfidence:
      enum:
        - high
        - medium
        - low
      type: string
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````