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

# Record an event, or a batch

> Writes down what a person did: an order, a basket left behind, a page seen. Events start automations (trigger **The person does something**), feed segments, and an event named `order` with a `value` is credited as revenue to the e-mail that earned it.

Send one event as the body, or up to 1,000 under `events`. In a batch each row gets its own answer, in the order it came: one bad row does not cost the others. The person does not have to be a subscriber yet: the event is kept under their address and joins their profile when they subscribe.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/events
openapi: 3.1.0
info:
  title: Lekalao API
  version: 1.0.0
  description: >-
    Everything the interface does, your application can do too. Every call
    carries an API token (Settings → API tokens).
servers:
  - url: https://api.lekalao.com
    description: Lekalao
  - url: https://{host}/api
    description: Your own installation
    variables:
      host:
        default: lekalao.example.com
        description: The domain of your installation
security:
  - bearer: []
tags:
  - name: Lists
  - name: Subscribers
  - name: Tags
  - name: Segments
  - name: Imports
  - name: Templates
  - name: Campaigns
  - name: Automations
  - name: Transactional e-mails
  - name: Revenue
  - name: Contact fields
  - name: Events
  - name: Webhooks
  - name: Platform
paths:
  /v1/events:
    post:
      tags:
        - Events
      summary: Record an event, or a batch
      description: >-
        Writes down what a person did: an order, a basket left behind, a page
        seen. Events start automations (trigger **The person does something**),
        feed segments, and an event named `order` with a `value` is credited as
        revenue to the e-mail that earned it.


        Send one event as the body, or up to 1,000 under `events`. In a batch
        each row gets its own answer, in the order it came: one bad row does not
        cost the others. The person does not have to be a subscriber yet: the
        event is kept under their address and joins their profile when they
        subscribe.
      operationId: api.events.store
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/EventInput'
                - type: object
                  required:
                    - events
                  properties:
                    events:
                      type: array
                      minItems: 1
                      maxItems: 1000
                      items:
                        $ref: '#/components/schemas/EventInput'
            example:
              email: ada@example.com
              name: order
              value: 15000
              currency: XAF
              reference: CMD-1024
              properties:
                items:
                  - name: Darjeeling
                    quantity: 2
      responses:
        '200':
          description: >-
            One event whose `reference` was already known (`duplicate`), or a
            batch: `data` holds one result per row and `failed` counts the
            invalid ones.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    oneOf:
                      - $ref: '#/components/schemas/EventResult'
                      - type: array
                        items:
                          $ref: '#/components/schemas/EventResult'
                  failed:
                    type: integer
        '201':
          description: Recorded (one event).
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/EventResult'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          description: >-
            The event is invalid — or every row of the batch is. `errors` says
            why, row by row.
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        maxLength: 255
      description: >-
        Replay a write safely: the same key gives back the first answer for 24
        hours (header Idempotent-Replay: true).
  schemas:
    EventInput:
      type: object
      required:
        - email
        - name
      properties:
        email:
          type: string
          format: email
        name:
          type: string
          maxLength: 100
          pattern: ^[A-Za-z0-9 _.:-]+$
          example: cart.abandoned
          description: >-
            Yours to choose. `order` is counted as revenue; `cart.abandoned`
            starts the ready-made basket journey.
        properties:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: >-
            Whatever describes it. Available in the e-mails of the automation it
            starts, as `{{ event.… }}`.
        value:
          type:
            - integer
            - 'null'
          minimum: 0
          description: 'In the smallest unit: 1250 is 12.50 €. Requires `currency`.'
        currency:
          type:
            - string
            - 'null'
          minLength: 3
          maxLength: 3
        occurred_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Now, when absent. At most one day ahead.
        reference:
          type:
            - string
            - 'null'
          maxLength: 255
          description: >-
            Your own identifier — an order number. The same reference twice is
            recorded once.
    EventResult:
      type: object
      properties:
        index:
          type: integer
        status:
          type: string
          enum:
            - recorded
            - duplicate
            - invalid
        id:
          type: string
          format: uuid
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
    Message:
      type: object
      properties:
        message:
          type: string
  responses:
    Unauthenticated:
      description: No token, or an invalid or revoked one.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Message'
          example:
            message: Unauthenticated.
    Forbidden:
      description: The token lacks the ability needed, or the team is suspended.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Message'
    TooManyRequests:
      description: >-
        The token's limit is reached. Wait the number of seconds Retry-After
        gives.
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
          description: Calls allowed per minute for this token.
        X-RateLimit-Remaining:
          schema:
            type: integer
        Retry-After:
          schema:
            type: integer
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: >-
        An API token. The "read" ability: GET routes only. "read + write": every
        route.

````