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

# Create Lead or Booking

> Creates a CRM entry for the patient. Set `phase: "lead"` (default) to drop the entry into the lead funnel — it will be auto-assigned to a telecaller and trigger a `NEW_LEAD` notification. Set `phase: "booking"` to skip the lead stage and create a confirmed booking directly — it will trigger a `BOOKING_CONFIRMED` notification.



## OpenAPI

````yaml POST /client/crm/lead/create
openapi: 3.0.3
info:
  title: Flabs CRM API
  version: 1.0.0
  description: Branches, tests, packages, and lead/booking ingestion for the Flabs CRM.
servers:
  - url: https://v2.flabs.in
    description: Production
security: []
paths:
  /client/crm/lead/create:
    post:
      summary: Create lead or booking
      description: >-
        Creates a CRM entry for the patient. Set `phase: "lead"` (default) to
        drop the entry into the lead funnel — it will be auto-assigned to a
        telecaller and trigger a `NEW_LEAD` notification. Set `phase: "booking"`
        to skip the lead stage and create a confirmed booking directly — it will
        trigger a `BOOKING_CONFIRMED` notification.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateLeadRequest'
            examples:
              Lead:
                summary: Create a lead (default phase)
                value:
                  branchID: 6530a4a6f1d2c8b7e9a12345
                  integratorID: EXT-LEAD-10231
                  phase: lead
                  first_name: Rahul
                  last_name: Sharma
                  contact: '9876543210'
                  country_code: '91'
                  email: rahul@example.com
                  age: 32
                  age_type: year
                  gender: male
                  address: 42 Park Street
                  pincode: '560001'
                  source: facebook_ads
                  priority: high
                  tests:
                    - test: 6530a4a6f1d2c8b7e9aabcde
                      cost: 350
                  packages:
                    - package: 6530a4a6f1d2c8b7e9afedcb
                      price: 1499
                  unmappedTests:
                    - name: Vitamin D3 (custom name)
                      cost: 800
                  unmappedPackages:
                    - name: Bridal Glow Panel
                      price: 2500
                  discountAmount: 100
                  totalAmount: 4549
              Booking:
                summary: Create a booking directly (phase = booking)
                value:
                  branchID: 6530a4a6f1d2c8b7e9a12345
                  integratorID: EXT-BOOK-55012
                  phase: booking
                  first_name: Anita
                  last_name: Verma
                  contact: '9123456780'
                  email: anita@example.com
                  age: 45
                  age_type: year
                  gender: female
                  address: 22 MG Road
                  pincode: '560001'
                  bookingType: Home Collection
                  scheduledAt: '2026-05-15T08:30:00.000Z'
                  specialInstructions: Patient is diabetic; please call before arrival.
                  paymentStatus: Pending
                  paymentMode: Cash
                  tests:
                    - test: 6530a4a6f1d2c8b7e9aabcde
                      cost: 350
                  totalAmount: 350
      responses:
        '201':
          description: Lead or booking created
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  leadId:
                    type: string
                    description: Identifier of the newly created CRM entry.
                  phase:
                    type: string
                    enum:
                      - lead
                      - booking
                  message:
                    type: string
              example:
                success: true
                leadId: 6530a4a6f1d2c8b7e9a54321
                phase: lead
                message: Lead created successfully
        '400':
          $ref: '#/components/responses/ClientError'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Duplicate'
        5XX:
          $ref: '#/components/responses/ServerError'
      security:
        - bearerAuth: []
components:
  schemas:
    CreateLeadRequest:
      type: object
      required:
        - branchID
        - first_name
        - contact
        - age
        - age_type
        - integratorID
      properties:
        branchID:
          type: string
          description: Branch identifier returned by `GET /client/labs`.
        integratorID:
          type: string
          description: >-
            Your own unique ID for this lead/booking. Required. It is stored on
            the entry, carried onto the bill when it converts, and echoed back
            in webhook payloads so you can correlate events with your records.
        corporateUser:
          type: string
          description: >-
            Corporate this entry belongs to. Party-scoped accounts must attach a
            party (any one of `corporateUser`, `referredOrganization`,
            `referredHospitalOrganization`).
        referredOrganization:
          type: string
          description: >-
            Referring doctor (organization) identifier. Party-scoped accounts
            must attach a party.
        referredHospitalOrganization:
          type: string
          description: >-
            Referring hospital (organization) identifier. Party-scoped accounts
            must attach a party.
        phase:
          type: string
          enum:
            - lead
            - booking
          default: lead
          description: >-
            `lead` enters the funnel and is auto-assigned. `booking` skips the
            funnel and creates a confirmed booking.
        designation:
          type: string
          description: Mr / Mrs / Dr / etc.
        first_name:
          type: string
        last_name:
          type: string
        contact:
          type: string
          description: Exactly 10 digits, no symbols or spaces.
        country_code:
          type: string
          default: '91'
        email:
          type: string
          format: email
        age:
          type: number
        age_type:
          type: string
          enum:
            - year
            - month
            - day
        gender:
          type: string
          enum:
            - male
            - female
            - other
        weight:
          type: number
          description: In kilograms.
        height:
          type: number
          description: In centimetres.
        address:
          type: string
        pincode:
          type: string
        googleLocation:
          type: string
          description: >-
            Free-form location string, e.g. `"12.97,77.59"` or a Google Maps
            URL.
        aadhaar_number:
          type: string
        insurance_number:
          type: string
        uhid:
          type: string
        passport_number:
          type: string
        owner_name:
          type: string
          description: Veterinary only — pet owner's name.
        breed:
          type: string
          description: Veterinary only — pet breed.
        category:
          type: string
          description: Veterinary only — animal category.
        source:
          type: string
          description: Channel that produced the lead, e.g. `"facebook_ads"`, `"website"`.
        priority:
          type: string
          enum:
            - urgent
            - high
            - medium
            - low
          default: medium
        tests:
          type: array
          items:
            $ref: '#/components/schemas/LeadTest'
        packages:
          type: array
          items:
            $ref: '#/components/schemas/LeadPackage'
        unmappedTests:
          type: array
          description: >-
            Tests that you couldn't match to a Flabs test ID. Sent as plain name
            + cost so they show up on the lead with an "unmapped" tag for the
            team to resolve later.
          items:
            $ref: '#/components/schemas/UnmappedTest'
        unmappedPackages:
          type: array
          description: >-
            Packages that you couldn't match to a Flabs package ID. Sent as
            plain name + price so they show up on the lead with an "unmapped"
            tag for the team to resolve later.
          items:
            $ref: '#/components/schemas/UnmappedPackage'
        discountAmount:
          type: number
          default: 0
        totalAmount:
          type: number
          default: 0
        bookingType:
          type: string
          enum:
            - Home Collection
            - Lab Visit
          description: Used when phase is `booking`.
        scheduledAt:
          type: string
          format: date-time
          description: >-
            ISO date-time when the booking is scheduled. Used when phase is
            `booking`.
        specialInstructions:
          type: string
          description: Notes for the phlebotomist or lab.
        paymentStatus:
          type: string
          enum:
            - Pending
            - Paid
            - Pay Later
          default: Pending
          description: Defaults to `Pending` for bookings.
        paymentMode:
          type: string
          enum:
            - Razorpay UPI
            - Card
            - Cash
        customFields:
          type: object
          description: >-
            Free-form key/value map. Keys must match custom fields configured in
            CRM settings. Example: `{ "utm_campaign": "summer_sale",
            "lead_score": 78 }`.
    LeadTest:
      type: object
      required:
        - test
        - cost
      properties:
        test:
          type: string
          description: Test identifier returned by `GET /client/crm/tests`.
        cost:
          type: number
          description: Cost charged for this test on this lead.
        isPackage:
          type: boolean
          description: Set to true if this test was added as part of a package.
        packageId:
          type: string
          description: Parent package identifier when `isPackage` is true.
    LeadPackage:
      type: object
      required:
        - package
        - price
      properties:
        package:
          type: string
          description: Package identifier returned by `GET /client/crm/packages`.
        price:
          type: number
          description: Price charged for the package on this lead.
    UnmappedTest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Free-text test name as you have it on your side.
        cost:
          type: number
          default: 0
          description: Cost you want recorded against the unmapped test.
    UnmappedPackage:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Free-text package name as you have it on your side.
        price:
          type: number
          default: 0
          description: Price you want recorded against the unmapped package.
    ErrorBody:
      type: object
      properties:
        success:
          type: boolean
          example: false
        status:
          type: integer
        message:
          type: string
        error:
          type: object
          properties:
            details:
              type: string
  responses:
    ClientError:
      description: Validation or auth error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            success: false
            status: 400
            message: Bad Request
            error:
              details: first_name is required
    Forbidden:
      description: '`branchID` does not belong to the authenticated account'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            success: false
            status: 403
            message: Forbidden
            error:
              details: branchID does not belong to your account
    Duplicate:
      description: A lead or booking with this contact/email already exists today
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            success: false
            status: 409
            message: Conflict
            error:
              details: Lead with contact 9876543210 already exists today
    ServerError:
      description: Unexpected server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            success: false
            status: 500
            message: Internal Server Error
            error:
              details: An unexpected error occurred
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT obtained from `POST /client/auth/token`.

````