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

# Send a Workflow Event

> Tells a workflow campaign that something happened for a contact (a payment, a signed form), for its **Await (event)** blocks. Every event is kept: one that arrives before the contact reaches the Await still counts when they get there (if it arrived after they entered the workflow). A contact already waiting for it moves on at once by the Await's **Received** path; one that isn't waiting takes **Timed out** when the Await's time limit passes. The event's `data` is what later Conditionals read as the event's fields.

> [!NOTE]
>
> **Preview.** Workflow campaigns are being rolled out to pilot accounts.

Use this when a [workflow](/platform/workflows.md) waits for something to happen outside Osvi: a payment, a signed form, a visit. Put an **Await** block set to **Event** in the workflow, name the event (for example `payment_received`), and have your system send that event here with the contact's phone number when it happens.

* **Early events count.** An event that arrives before the contact reaches the Await is kept, and counts the moment they get there (as long as it arrived after they entered the workflow).
* **One event moves one contact on, once.** Send a `client_event_id` to make retries safe.
* **What it brings.** Later Conditionals can check the event's `data` fields (for example, "amount is greater than 1000").
* **Testing.** In the workflow editor, an Await (event) block waiting in a test run has **Send test event**, and **For your developer** shows this request ready to copy.


## OpenAPI

````yaml POST /v1/campaigns/{id}/events
openapi: 3.1.0
info:
  title: OSVI AI API
  description: REST API for the OSVI AI voice and chat platform
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.osvi.ai
security:
  - ApiToken: []
paths:
  /v1/campaigns/{id}/events:
    post:
      summary: Send a workflow event
      description: >-
        Tells a workflow campaign that something happened for a contact (a
        payment, a signed form), for its **Await (event)** blocks. Every event
        is kept: one that arrives before the contact reaches the Await still
        counts when they get there (if it arrived after they entered the
        workflow). A contact already waiting for it moves on at once by the
        Await's **Received** path; one that isn't waiting takes **Timed out**
        when the Await's time limit passes. The event's `data` is what later
        Conditionals read as the event's fields.
      parameters:
        - name: id
          in: path
          required: true
          description: The workflow campaign's numeric id.
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - event
              properties:
                event:
                  type: string
                  maxLength: 100
                  description: The event's name, as the Await block names it.
                  example: payment_received
                phone:
                  type: string
                  maxLength: 32
                  description: >-
                    The contact's phone number, as in their batch (10-digit
                    Indian mobile numbers and `+91` numbers are matched either
                    way). Give this or `run_ref`.
                  example: '+919876543210'
                run_ref:
                  type: string
                  description: >-
                    One run, as Logs shows it (`R-1042`), instead of a phone
                    number. A test run is only reached this way.
                  example: R-1042
                client_event_id:
                  type: string
                  maxLength: 200
                  description: >-
                    Your own id for the event. Sending the same id again changes
                    nothing (safe retries).
                  example: pay_8XK2
                data:
                  type: object
                  description: Anything about the event later blocks can check, up to 8 KB.
                  example:
                    amount: 5000
                    method: upi
            example:
              event: payment_received
              phone: '+919876543210'
              client_event_id: pay_8XK2
              data:
                amount: 5000
                method: upi
      responses:
        '200':
          description: Event received.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      event_id:
                        type: integer
                        example: 481
                      status:
                        type: string
                        enum:
                          - matched
                          - stored
                          - no_run
                        description: >-
                          `matched`: a contact was waiting for this event and
                          moves on now. `stored`: the contact is in the workflow
                          but not at an Await for this event yet; it counts when
                          they get there. `no_run`: nobody with that phone (or
                          run) is in the workflow now; the event is kept all the
                          same.
                        example: matched
                      duplicate:
                        type: boolean
                        description: >-
                          `true` when this `client_event_id` was sent before:
                          nothing changed, and the first event's answer is
                          returned.
                        example: false
                      run_ref:
                        type:
                          - string
                          - 'null'
                        description: The contact's run, as Logs shows it.
                        example: R-1042
        '400':
          description: >-
            `event`, or both `phone` and `run_ref`, missing; `data` not an
            object.
        '401':
          description: Missing or invalid API token.
        '403':
          description: >-
            Workflow campaigns aren't turned on for your account
            (`feature_disabled`).
        '404':
          description: No campaign with this id on your account.
        '409':
          description: >-
            The campaign is archived: new events are refused. A retry of an
            event it already took (same `client_event_id`) still gets that
            event's first answer.
        '413':
          description: '`data` is larger than 8 KB.'
        '422':
          description: Not a workflow campaign (`not_a_workflow_campaign`).
        '429':
          description: 'Too many events: 600 a minute per API token.'
components:
  securitySchemes:
    ApiToken:
      type: apiKey
      in: header
      name: API-Token
      description: >-
        16-character API token associated with your OSVI account. Find it in
        your dashboard under Settings → API.

````

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