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

# create device

> Create a new device device



## OpenAPI

````yaml api-reference/openapi.json post /devices
openapi: 3.1.0
info:
  title: Chatlevel API
  description: >-
    Chatlevel is a WhatsApp web API to manage any WhatsApp account
    programmatically.
  version: v1.0.0
servers:
  - url: https://api.chatlevel.io/v1
security:
  - bearerAuth: []
tags:
  - name: devices
    description: Operations related to managing devices.
  - name: messages
    description: Operations related to sending messages.
paths:
  /devices:
    post:
      tags:
        - devices
      summary: create device
      description: Create a new device device
      operationId: create-device
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: User-friendly device name
                webhookUrl:
                  type: string
                  description: Webhook URL for receiving events
                webhookEvents:
                  type: array
                  items:
                    type: string
                    enum:
                      - connection.open
                      - connection.closed
                      - connection.auth
                      - connection.timeout
                      - connection.logout
                      - message.received
                      - message.sent
                      - message.updated
                      - message.deleted
                      - call
                  description: >-
                    Events to send to webhook (defaults to all). See webhook
                    documentation for event payloads.
                phoneNumber:
                  type: string
                  description: >-
                    Phone number for pairing code authentication (alternative to
                    QR code). Must be digits only, include country code, no + or
                    spaces.
                  example: '31612345678'
      responses:
        '200':
          description: Device created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  device:
                    $ref: '#/components/schemas/device'
                  status:
                    $ref: '#/components/schemas/status'
              example:
                device:
                  id: 12345
                  name: My Device
                  status: qr
                  qr: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
                  webhookUrl: https://example.com/webhook
                  webhookEvents:
                    - message.received
                    - message.sent
                  messagesSent: 0
                  subscription_status: active
                  createdAt: '2024-01-15T10:30:00Z'
                status:
                  code: 200
                  message: Device created successfully
        '400':
          $ref: '#/components/responses/400InvalidJSON'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          description: >-
            Device limit reached - subscription does not allow creating more
            devices
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: integer
                        example: 403
                      message:
                        type: string
                        example: >-
                          Device limit reached. You have 2 active device(s) and
                          your subscription allows 2.
        '408':
          $ref: '#/components/responses/408Timeout'
        '413':
          $ref: '#/components/responses/413PayloadTooLarge'
        '429':
          $ref: '#/components/responses/429RateLimit'
        '500':
          $ref: '#/components/responses/500InternalError'
components:
  schemas:
    device:
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the device
        name:
          type: string
          description: Name of the device
        status:
          type: string
          enum:
            - connected
            - qr
            - timeout
          description: >-
            Current connection status: 'qr' when waiting for QR scan,
            'connected' when paired, 'timeout' when QR expired
        qr:
          type: string
          nullable: true
          description: Base64 encoded QR code data URL (available when status is 'qr')
        webhookUrl:
          type: string
          nullable: true
          description: Webhook URL for receiving events
        webhookEvents:
          type: array
          items:
            type: string
            enum:
              - connection.open
              - connection.closed
              - connection.auth
              - connection.timeout
              - connection.logout
              - message.received
              - message.sent
              - message.updated
              - message.deleted
              - call
          description: >-
            Events to send to webhook. See webhook documentation for event
            payloads.
        messagesSent:
          type: integer
          description: Total number of messages sent
        subscription_status:
          type: string
          enum:
            - active
            - inactive
          description: >-
            Subscription status of the device. Inactive devices have their
            WhatsApp sessions stopped.
        createdAt:
          type: string
          format: date-time
          description: When the device was created
    status:
      type: object
      properties:
        code:
          type: integer
          description: Status code
          example: 200
        message:
          type: string
          description: Status message
          example: Success
  responses:
    400InvalidJSON:
      description: Invalid JSON format
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 400
                  message:
                    type: string
                    example: Invalid JSON format
    401Unauthorized:
      description: Missing or invalid authorization header
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: error
              error:
                type: object
                properties:
                  code:
                    type: integer
                    example: 401
                  message:
                    type: string
                    example: >-
                      Missing or invalid authorization header. Please provide a
                      Bearer token.
    408Timeout:
      description: Request timeout
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 408
                  message:
                    type: string
                    example: Request timeout
    413PayloadTooLarge:
      description: Request payload too large
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 413
                  message:
                    type: string
                    example: Request payload too large
    429RateLimit:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 429
                  message:
                    type: string
                    example: >-
                      Rate limit exceeded. Maximum 100 requests per minute per
                      user.
    500InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 500
                  message:
                    type: string
                    example: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Provide your API key as: Authorization: Bearer
        <api_key>

````