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

# Send events

> Each event is checked on its own, so a 200 can still list rejected events. Send a rejected event again only when its `retryable` is `true`. Event ids are stored once, so a batch sent twice stores its events once, and `accepted` counts them both times.



## OpenAPI

````yaml /api-reference/openapi.json post /api/mcp/events/v2/batch
openapi: 3.1.0
info:
  title: Waniwani API
  version: 1.0.0
  description: >-
    The HTTP routes the Waniwani SDK and chat widget call. Use them from any
    language. Server routes take a secret `wwk_` API key; chat routes take a
    channel's `wwp_` public key, which is meant to ship in a web page.
servers:
  - url: https://app.waniwani.ai
    description: US region
  - url: https://eu.app.waniwani.ai
    description: EU region
security: []
tags:
  - name: Server API
    description: Called from your server with a secret `wwk_` API key.
  - name: Chat API
    description: Called from a web page with a channel's `wwp_` public key.
paths:
  /api/mcp/events/v2/batch:
    post:
      tags:
        - Server API
      summary: Send events
      description: >-
        Each event is checked on its own, so a 200 can still list rejected
        events. Send a rejected event again only when its `retryable` is `true`.
        Event ids are stored once, so a batch sent twice stores its events once,
        and `accepted` counts them both times.
      operationId: ingestEventBatch
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventBatch'
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventBatchResult'
        '400':
          description: '400'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventBatchError'
        '401':
          description: '401'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventBatchError'
        '403':
          description: '403'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventBatchError'
        '410':
          description: '410'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventBatchError'
        '500':
          description: '500'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventBatchError'
      security:
        - apiKeyAuth: []
        - publicKeyAuth: []
components:
  schemas:
    EventBatch:
      type: object
      properties:
        sentAt:
          type: string
          format: date-time
        source:
          type: object
          properties:
            sdk:
              type: string
              minLength: 1
            version:
              type: string
              minLength: 1
          required:
            - sdk
            - version
          additionalProperties: false
        events:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                minLength: 1
              type:
                type: string
                const: mcp.event
              name:
                type: string
                minLength: 1
                maxLength: 200
              source:
                type: string
                minLength: 1
              timestamp:
                type: string
                format: date-time
                pattern: >-
                  ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
              correlation:
                type: object
                properties:
                  sessionId:
                    type: string
                    minLength: 1
                  traceId:
                    type: string
                    minLength: 1
                  requestId:
                    type: string
                    minLength: 1
                  correlationId:
                    type: string
                    minLength: 1
                  externalUserId:
                    type: string
                    minLength: 1
                    maxLength: 256
                  visitorId:
                    type: string
                    minLength: 1
                    maxLength: 256
                additionalProperties: false
              properties:
                type: object
                propertyNames:
                  type: string
                additionalProperties: {}
              metadata:
                type: object
                properties:
                  meta:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties: {}
                  rawLegacy:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties: {}
                additionalProperties: {}
              rawLegacy:
                type: object
                propertyNames:
                  type: string
                additionalProperties: {}
            required:
              - id
              - type
              - name
              - timestamp
            additionalProperties: false
          minItems: 1
          description: >-
            Each event is checked on its own: one that fails is listed in
            `rejected` and the others are still accepted. Each event needs a
            `sessionId`, `externalUserId` or `visitorId` in `correlation`.
      required:
        - sentAt
        - source
        - events
      additionalProperties: false
    EventBatchResult:
      type: object
      properties:
        accepted:
          type: integer
          minimum: 0
          description: >-
            How many events passed the checks. An event whose id is already
            stored counts again but is not stored twice, so this is not a count
            of new events.
        rejected:
          type: array
          items:
            type: object
            properties:
              eventId:
                type: string
              code:
                type: string
                enum:
                  - validation_failed
                  - temporary_unavailable
              message:
                type: string
              retryable:
                type: boolean
                description: Send the event again later when `true`.
            required:
              - eventId
              - code
              - message
              - retryable
          description: The events that did not pass. Absent when every event was accepted.
        requestId:
          type: string
      required:
        - accepted
        - requestId
    EventBatchError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        details:
          type: array
          items: {}
        requestId:
          type: string
      required:
        - error
        - requestId
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: WaniWaniApiKey
      description: 'Waniwani API key passed as `Authorization: Bearer wwk_<key>`.'
    publicKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: WaniwaniPublicKey
      description: >-
        Waniwani public key passed as `Authorization: Bearer wwp_<key>`. A
        channel's public key is meant to ship in a web page.

````

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