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

# Generate QR code for user

> Issues a long-lived WhatsApp QR-code link for a specific user in a partner-managed workspace. If the user already has a connected WhatsApp account, that account is disconnected first and the previous QR link (if any) is revoked. Only one active QR link per user is allowed at any given time; generating a new link invalidates any existing one. The request optionally accepts expires_in_hours (1–168, default 24) to control how long the QR link remains valid. The response includes the workspace_id, user_id, an unguessable qr_link URL, its expires_at timestamp, and flags indicating whether an existing WhatsApp account was disconnected and whether a previously active QR link was revoked. Generating a new QR code link is a destructive action: any currently connected WhatsApp account for this user will be forcibly disconnected.



## OpenAPI

````yaml post /workspaces/{workspace_id}/users/{user_id}/qr
openapi: 3.0.3
info:
  title: Partner API
  version: 1.0.1
  description: >-
    Partner-facing HTTP API used by approved integrators to provision and manage
    TimelinesAI workspaces, users and WhatsApp connections on behalf of their
    customers. All endpoints are versioned under /partner/api/v1 and secured
    with JWT bearer authentication. Obtaining a workspace Public API token,
    together with the capabilities of the Public API such as webhook
    subscriptions, enables partners to build complex integrations for their
    customers.
servers:
  - url: /partner/api/v1
    description: Partner API root URL
security:
  - bearerAuth: []
tags:
  - name: workspaces
  - name: users
  - name: whatsappAccounts
  - name: qr
  - name: publicAPI
paths:
  /workspaces/{workspace_id}/users/{user_id}/qr:
    post:
      tags:
        - qr
      summary: Generate QR code for user
      description: >-
        Issues a long-lived WhatsApp QR-code link for a specific user in a
        partner-managed workspace. If the user already has a connected WhatsApp
        account, that account is disconnected first and the previous QR link (if
        any) is revoked. Only one active QR link per user is allowed at any
        given time; generating a new link invalidates any existing one. The
        request optionally accepts expires_in_hours (1–168, default 24) to
        control how long the QR link remains valid. The response includes the
        workspace_id, user_id, an unguessable qr_link URL, its expires_at
        timestamp, and flags indicating whether an existing WhatsApp account was
        disconnected and whether a previously active QR link was revoked.
        Generating a new QR code link is a destructive action: any currently
        connected WhatsApp account for this user will be forcibly disconnected.
      operationId: userRequestQRLink
      parameters:
        - $ref: '#/components/parameters/X-TL-Partner-Id'
        - name: workspace_id
          in: path
          required: true
          description: The unique identifier for the workspace.
          schema:
            type: string
        - name: user_id
          in: path
          required: true
          description: The unique identifier for the user.
          schema:
            type: integer
      requestBody:
        required: false
        description: QR code link generation request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerAPIExpiresRequest'
      responses:
        '200':
          description: QR code generated
          headers:
            X-TL-API-Version:
              schema:
                type: string
              description: Partner API version. Current version is v1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerAPIQRCodeResponse'
        '404':
          $ref: '#/components/responses/UserNotFound'
components:
  parameters:
    X-TL-Partner-Id:
      name: X-TL-Partner-Id
      in: header
      description: The unique identifier for the partner.
      required: true
      schema:
        type: string
  schemas:
    PartnerAPIExpiresRequest:
      type: object
      properties:
        expires_in_hours:
          type: integer
          description: Number of hours until the link expires
          minimum: 1
          maximum: 168
          default: 24
      description: >-
        Request payload for configuring the lifetime of a WhatsApp QR link. The
        optional expires_in_hours field controls how long the issued qr_link
        remains valid. If omitted, a sensible default (24 hours) is applied by
        the server.
    PartnerAPIQRCodeResponse:
      type: object
      properties:
        workspace_id:
          type: string
          description: Unique identifier for the workspace
          example: my-first-workspace
        user_id:
          type: integer
          description: Unique identifier for the user
          example: 42
        qr_link:
          type: string
          description: QR code link for connecting to WhatsApp
        expires_at:
          type: string
          description: Expiration timestamp of the QR code link
          format: date-time
          example: '2024-01-01T12:00:00Z'
        whatsapp_disconnected:
          type: boolean
          description: >-
            Indicates whether an existing WhatsApp account was disconnected for
            this user
        previous_qr_revoked:
          type: boolean
          description: >-
            Indicates whether a previously issued QR link for this user was
            revoked
      required:
        - workspace_id
        - user_id
        - qr_link
        - expires_at
        - whatsapp_disconnected
        - previous_qr_revoked
      description: >-
        Response payload returned when issuing a WhatsApp QR link for a user.
        Includes the workspace_id and user_id, the unguessable qr_link URL, its
        expires_at timestamp, and boolean flags showing whether an existing
        WhatsApp account was disconnected and whether any previously issued QR
        link for this user was revoked.
    PartnerAPIError:
      type: object
      properties:
        error:
          type: string
          description: Machine-readable error code
        status:
          type: integer
          description: HTTP status code
        description:
          type: string
          description: Human-readable error description
      required:
        - error
        - status
      description: >-
        Standard error envelope used by Partner API endpoints. The error field
        contains a machine-readable error code such as partner_not_found,
        partner_not_active, invalid_signature, timestamp_out_of_range,
        workspace_not_found, workspace_not_owned_by_partner or
        workspace_billing_managed. The status field repeats the HTTP status
        code, and description may contain a human-readable explanation suitable
        for logs and troubleshooting.
  responses:
    UserNotFound:
      description: User not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PartnerAPIError'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT bearer authentication. The token payload must include partner_id,
        nbf (not-before) and exp (expiry) claims. All Partner API requests must
        be authenticated with Authorization: Bearer <token>.

````