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

# Request Pairing Code

> Request pairing code for authentication via phone number

## Description

This endpoint allows requesting a pairing code as alternative method of authentication, without the need to scan the QR Code. The received code must be entered in the WhatsApp app to establish the connection.

## URL Parameters

<ParamField path="session" type="string" required>
  Unique ID of the session to be authenticated
</ParamField>

## Body

```json theme={null}
{
  "phone": "5511999999999"
}
```

### Body Parameters

| Property | Type     | Required | Description                                               |
| -------- | -------- | -------- | --------------------------------------------------------- |
| `phone`  | `string` | ✅ Yes    | Phone number for which the pairing code will be requested |

## Response

<ResponseField name="code" type="string" required>
  Pairing code generated. This code must be entered in the WhatsApp app to complete authentication.
</ResponseField>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "code": "ABCD-1234"
  }
  ```
</ResponseExample>

## Status Codes

* `200` - Code generated successfully
* `400` - Invalid parameters (ex: invalid phone number)
* `401` - Unauthorized

## Usage Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.com.br/api/my-session/auth/request-code \
    -H "Content-Type: application/json" \
    -d '{
      "phone": "5511999999999"
    }'
  ```

  ```javascript JavaScript theme={null}
  const session = 'my-session';
  const response = await fetch(`https://api.wappfy.com.br/api/${session}/auth/request-code`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      phone: '5511999999999'
    })
  });
  const data = await response.json();
  console.log(data.code);
  ```

  ```python Python theme={null}
  import requests

  session = 'my-session'
  response = requests.post(
      f'https://api.wappfy.com.br/api/{session}/auth/request-code',
      json={
          'phone': '5511999999999'
      }
  )
  data = response.json()
  print(data['code'])
  ```
</CodeGroup>


## OpenAPI

````yaml viewer-en.json post /api/{session}/auth/request-code
openapi: 3.1.0
info:
  title: Wappfy - WhatsApp HTTP API
  version: '2.0'
  contact: {}
servers:
  - url: https://{host}
    description: Customizable Server
    variables:
      host:
        default: api.wappfy.com.br
        description: Server URL (e.g., api.wappfy.com.br or your-server.com)
security:
  - api_key: []
tags:
  - name: 🖥️ Sessions
    description: Control WhatsApp sessions (accounts)
  - name: 🔑 Auth
    description: Authentication
  - name: 🆔 Profile
    description: Your profile information
  - name: 🖼️ Screenshot
    description: Get WhatsApp screenshot and display QR code
  - name: 📤 Chatting
    description: Conversation methods
  - name: 📢 Channels
    description: Channels (newsletters) methods
  - name: 🟢 Status
    description: Status (aka stories) methods
  - name: 💬 Chats
    description: Conversations methods
  - name: 👤 Contacts
    description: |-
      Contacts methods.<br>
                      Use phone number (without +) or phone number and `@c.us` at the end as `contactId`.<br>
                      E.g: `12312312310` OR `12312312310@c.us`<br>
  - name: 👥 Groups
    description: Groups methods.<br>
  - name: ✅ Presence
    description: Presence information
  - name: 📅 Events
    description: Event Message
  - name: 🏷️ Labels
    description: Labels - available only for WhatsApp Business accounts
  - name: 🔍 Observability
    description: Other methods
  - name: 🗄️ Storage
    description: Storage methods
externalDocs:
  description: Wappfy - WhatsApp API
  url: https://docs.wappfy.com.br/
paths:
  /api/{session}/auth/request-code:
    post:
      tags:
        - 🔑 Auth
      summary: Request authentication code.
      description: The {session} parameter must be the session's instanceName.
      operationId: AuthController_requestCode
      parameters:
        - name: session
          required: true
          in: path
          description: The session name (instanceName) you want to authenticate
          example: my-session
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestCodeRequest'
      responses:
        '201':
          description: ''
      security:
        - api_key: []
components:
  schemas:
    RequestCodeRequest:
      type: object
      properties:
        phoneNumber:
          type: string
          description: Mobile phone number in international format
          example: '12132132130'
        method:
          type: string
          description: >-
            How would you like to receive the one time code for registration?
            |sms|voice. Leave empty for Web pairing.
          example: null
      required:
        - phoneNumber
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: apikey
      description: Your Wappfy API key (get it at dash.wappfy.com.br)

````