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

# Send a conversion to an ad platform

> Builds the deal's conversion for the chosen platform: the value comes from the deal price, contact data from its contact, and the click from the deal's touches (a click-to-WhatsApp ad, a gclid or fbclid on the URL the lead came through) or its chatbot session; a deal from a Meta lead form also sends its lead id. On Meta a CRM or site event goes to the pixel `pixelId` names, through the project's Meta Ads connection, and an ad conversation's event to the dataset of its WhatsApp account; with no pixel named, only the ad conversation's event goes, through the WhatsApp Business channel, and anything else is skipped (NOT_CONFIGURED, or UNSUPPORTED_EVENT for a lead from an ad). On Google Ads it goes through the project's Google Ads connection, to the conversion action `event` names, no sooner than 6 hours after the click it credits (`scheduledFor`), when Google takes it. Delivery is queued: answers 202 with the conversion id. When there is nothing to send it answers 200 with `status: SKIPPED` and the reason, e.g. a Purchase on a deal without price, or the same event already sent for this deal. For a lead from a click-to-WhatsApp ad, an event Meta's messaging list lacks goes out as a CRM event: a custom one always, a site's standard one unless `messagingFallback` is SKIP.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/deals/{dealId}/conversions
openapi: 3.1.0
info:
  title: Leadstaker API
  version: 1.0.0
  description: Public REST API for Leadstaker projects.
servers:
  - url: https://n-api.leadstaker.com
    description: Production
security: []
tags:
  - name: Calls
    description: >-
      Phone calls made through the telephony app or posted from another phone
      system, with their recording, transcript and AI summary.
  - name: Chats
    description: Conversations with a contact over a connected channel.
  - name: Contacts
    description: >-
      People inside a project, holding the custom field values collected about
      them.
  - name: Deals
    description: Opportunities moving through a pipeline, each tied to a contact.
  - name: Field groups
    description: Sections that organize custom fields in the interface.
  - name: Fields
    description: >-
      Custom field definitions, both the built-in ones and the ones a project
      creates.
  - name: Leads
    description: >-
      Chatbot conversations captured in a project, with the answers given and
      where the visitor came from.
  - name: Loss reasons
    description: The catalog of reasons a deal can be marked as lost.
  - name: Messages
    description: Individual messages inside a chat, inbound and outbound.
  - name: Notes
    description: >-
      Free text attached to a contact or a deal, written by a user, an agent, or
      the system.
  - name: Pipelines
    description: Ordered sets of stages a deal travels through.
  - name: Stages
    description: Steps inside a pipeline, including the built-in open and closed ones.
  - name: Tags
    description: Free-form labels attached to deals.
  - name: Tasks
    description: >-
      Follow-up activities with a due date, attached to a deal and assigned to a
      user.
  - name: Touchpoints
    description: >-
      Each time a lead reached the business, traced to the ad, campaign, channel
      or form that brought it.
paths:
  /v1/deals/{dealId}/conversions:
    post:
      tags:
        - Deals
      summary: Send a conversion to an ad platform
      description: >-
        Builds the deal's conversion for the chosen platform: the value comes
        from the deal price, contact data from its contact, and the click from
        the deal's touches (a click-to-WhatsApp ad, a gclid or fbclid on the URL
        the lead came through) or its chatbot session; a deal from a Meta lead
        form also sends its lead id. On Meta a CRM or site event goes to the
        pixel `pixelId` names, through the project's Meta Ads connection, and an
        ad conversation's event to the dataset of its WhatsApp account; with no
        pixel named, only the ad conversation's event goes, through the WhatsApp
        Business channel, and anything else is skipped (NOT_CONFIGURED, or
        UNSUPPORTED_EVENT for a lead from an ad). On Google Ads it goes through
        the project's Google Ads connection, to the conversion action `event`
        names, no sooner than 6 hours after the click it credits
        (`scheduledFor`), when Google takes it. Delivery is queued: answers 202
        with the conversion id. When there is nothing to send it answers 200
        with `status: SKIPPED` and the reason, e.g. a Purchase on a deal without
        price, or the same event already sent for this deal. For a lead from a
        click-to-WhatsApp ad, an event Meta's messaging list lacks goes out as a
        CRM event: a custom one always, a site's standard one unless
        `messagingFallback` is SKIP.
      operationId: postDealsByDealIdConversions
      parameters:
        - name: dealId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                provider:
                  type: string
                  enum:
                    - META
                    - GOOGLE_ADS
                  description: The ad platform that receives the conversion.
                event:
                  type: string
                  minLength: 1
                  maxLength: 50
                  description: >-
                    The platform's standard name or any custom name. Meta's
                    standard names (Lead, Contact, Schedule, Purchase,
                    QualifiedLead…) are matched case-insensitively and sent the
                    way the lead's origin expects: Lead goes out as
                    LeadSubmitted for leads from a click-to-WhatsApp ad. Those
                    leads only take Meta's business messaging names: a site's
                    standard name follows `messagingFallback`, and a custom name
                    goes out as a CRM event. Purchase takes its value from the
                    deal price. On Google Ads it is the id of a conversion
                    action of the project's account, of the import-from-clicks
                    kind (GET /connections/google-ads/conversion-actions lists
                    them), and any conversion takes the deal price as its value.
                pixelId:
                  type: string
                  pattern: ^\d+$
                  description: >-
                    Meta: the pixel (dataset) a CRM or site event goes to, one
                    the project's Meta Ads connection was granted (GET
                    /connections/meta-ads/pixels lists them). An event of a
                    click-to-WhatsApp ad conversation goes to the dataset of its
                    WhatsApp account instead. Without it, only those go out,
                    through the WhatsApp Business channel.
                messagingFallback:
                  type: string
                  enum:
                    - CRM
                    - SKIP
                  description: >-
                    For a lead from a click-to-WhatsApp ad, what to do with a
                    site's standard event, which Meta's business messaging does
                    not take (Schedule, Contact…). CRM, the default, sends it as
                    a CRM event, matched by phone, email and cookies but no
                    longer tied to the ad click. SKIP sends nothing and answers
                    SKIPPED with UNSUPPORTED_EVENT. A custom name always goes
                    out as a CRM event. Meta only.
                testEventCode:
                  type: string
                  minLength: 1
                  description: >-
                    Meta: the code from the Test Events tab in Meta Events
                    Manager; test events still count as real data in Meta.
                    Google Ads: any value has Google only validate the
                    conversion, which it does not record.
              required:
                - provider
                - event
              additionalProperties: false
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      status:
                        type: string
                        const: QUEUED
                      conversionId:
                        type: string
                      eventName:
                        type: string
                        description: The name the platform will receive.
                      scheduledFor:
                        type: string
                        description: >-
                          Google Ads: when the send goes out, ISO 8601, set when
                          the click is too recent for Google to take it yet.
                    required:
                      - status
                      - conversionId
                      - eventName
                    additionalProperties: false
                  - type: object
                    properties:
                      status:
                        type: string
                        const: SKIPPED
                      reason:
                        type: string
                        enum:
                          - NO_IDENTIFIER
                          - UNSUPPORTED_EVENT
                          - DUPLICATE
                          - NOT_CONFIGURED
                          - MISSING_VALUE
                    required:
                      - status
                      - reason
                    additionalProperties: false
              example:
                status: SKIPPED
                reason: MISSING_VALUE
        '202':
          description: Success
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      status:
                        type: string
                        const: QUEUED
                      conversionId:
                        type: string
                      eventName:
                        type: string
                        description: The name the platform will receive.
                      scheduledFor:
                        type: string
                        description: >-
                          Google Ads: when the send goes out, ISO 8601, set when
                          the click is too recent for Google to take it yet.
                    required:
                      - status
                      - conversionId
                      - eventName
                    additionalProperties: false
                  - type: object
                    properties:
                      status:
                        type: string
                        const: SKIPPED
                      reason:
                        type: string
                        enum:
                          - NO_IDENTIFIER
                          - UNSUPPORTED_EVENT
                          - DUPLICATE
                          - NOT_CONFIGURED
                          - MISSING_VALUE
                    required:
                      - status
                      - reason
                    additionalProperties: false
              example:
                status: QUEUED
                conversionId: 3f2b9c1e-6a7d-4e1f-9b52-0c8d4a7e5f21
                eventName: Purchase
        '401':
          description: Missing or invalid credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: The payload failed validation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
components:
  schemas:
    Error:
      type: object
      required:
        - errorCode
        - message
        - status
      properties:
        errorCode:
          type: string
        message:
          type: string
        status:
          type: integer
        errors:
          type: array
          items:
            type: object
            required:
              - field
              - code
              - message
            properties:
              field:
                type: string
              code:
                type: string
              message:
                type: string
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key

````

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