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

# Generate migration code (OTP)

> Generate a one-time code to migrate a WhatsApp Web session.

Generates a **one-time code** (8 characters, `A-Z0-9`) bound to a session.
The code is shown to the end user, who enters it in the **Integration
Assistant** extension to migrate an **already authenticated** WhatsApp Web
connection to this session — without scanning the QR code.

* **Validity:** 30 minutes.
* **Single use:** consumed on the first successful migration (a failure keeps the
  code valid until it expires, allowing another attempt).
* **Authentication:** your `apiKey` in the `Authorization` header. The session given in
  `sessionId` must belong to your account.

> [!NOTE]
>
> This endpoint only **generates** the code. The migration itself is done by the extension,
> which reads the WhatsApp Web session credentials and sends them along with the code.
> See [Install the Integration Assistant](https://docs.d-api.cloud/en/whatsapp/instalar-assistente.md).

> [!TIP]
>
> In the Dashboard, the code also appears on the **Connect device** screen, right below
> the QR code, ready to copy.


## OpenAPI

````yaml api-reference/openapi.en.json POST /api/v1/sessions/{sessionId}/migration-otp
openapi: 3.1.0
info:
  title: D-API - Complete WhatsApp Infrastructure
  description: >-
    A scalable, robust solution for automation managers, SaaS products and end
    users who need a reliable WhatsApp integration. It offers multiple
    simultaneous instances, real-time webhooks, an intuitive dashboard and a
    documented REST API with 99.9% uptime and latency under 30ms.
  version: 1.2.1
  contact:
    name: Suporte D-API
    email: suporte@d-api.cloud
    url: https://d-api.cloud
servers:
  - url: https://api.d-api.cloud
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Home
    description: Base endpoints
  - name: Sessions
    description: Endpoints for managing sessions
  - name: Messages
    description: Endpoints for sending messages
  - name: Cloud API
    description: >-
      WhatsApp Official API (Meta Cloud API): manual connection, template
      management (list/create/delete) and template sending.
  - name: IVR Calls
    description: 'Voice call dispatch (IVR): single or bulk, with audio or an IVR flow.'
  - name: SMS
    description: 'SMS sending: single or bulk.'
  - name: Commands
    description: >-
      Look up asynchronous commands (async: true) by the commandId returned when
      enqueued.
paths:
  /api/v1/sessions/{sessionId}/migration-otp:
    post:
      tags:
        - Sessions
      summary: Generate single-use WhatsApp Web migration code
      operationId: postApiV1SessionsBySessionIdMigration-otp
      parameters:
        - schema:
            type: string
          in: path
          name: sessionId
          required: true
      responses:
        '200':
          description: Successful response
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'API Key for authentication. Format: <API_KEY>'

````

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