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

# Enviar evento

> Registra que algo le ocurrió a un cliente e inicia los flows activos que escuchan ese nombre de evento. No se registra nada antes: ni el evento, ni las propiedades, ni el cliente. Los identificadores del cliente se prueban en el orden id, external_id, tax_id, email, phone; el primero que coincida decide y, si ninguno coincide, se crea el cliente. Responde 201 para un evento nuevo y 200 con duplicate: true cuando ya existía un evento con el mismo name y external_id en los últimos 90 días. Tiene un límite propio de 100 solicitudes por segundo por clave API. Exige una clave API con el permiso write o events:write.



## OpenAPI

````yaml /openapi.es.json post /v1/events
openapi: 3.1.0
info:
  title: API de Bevits
  version: 1.0.0
  description: >-
    API pública para consultar datos de CRM, compras y automatización de una
    organización de Bevits, crear automatizaciones como borrador para revisarlas
    y activarlas, crear campañas de WhatsApp Oficial como borrador y armar
    segmentos y etiquetas de clientes.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.bevits.com
    description: Producción
security:
  - bearerAuth: []
tags:
  - name: Sistema
    description: Disponibilidad de la API.
  - name: Identidad
    description: Identidad de la organización y de la clave API.
  - name: Clientes
    description: Clientes y sus relaciones.
  - name: Segmentos
    description: Segmentos de clientes.
  - name: Compras
    description: Compras importadas desde las integraciones.
  - name: Datos del CRM
    description: Etiquetas y definiciones de atributos.
  - name: Automatizaciones
    description: Flows de automatización.
  - name: Campañas
    description: Campañas de email.
  - name: Cuenta y marca
    description: Contexto de la cuenta, identidad de la marca e imágenes.
  - name: Recetas
    description: Automatizaciones listas creadas a partir de recetas, con deshacer.
  - name: Plantillas de email
    description: Creación e importación de plantillas de correo.
  - name: Eventos
    description: Eventos personalizados enviados por la tienda y sus tipos.
paths:
  /v1/events:
    post:
      tags:
        - Eventos
      summary: Enviar evento
      description: >-
        Registra que algo le ocurrió a un cliente e inicia los flows activos que
        escuchan ese nombre de evento. No se registra nada antes: ni el evento,
        ni las propiedades, ni el cliente. Los identificadores del cliente se
        prueban en el orden id, external_id, tax_id, email, phone; el primero
        que coincida decide y, si ninguno coincide, se crea el cliente. Responde
        201 para un evento nuevo y 200 con duplicate: true cuando ya existía un
        evento con el mismo name y external_id en los últimos 90 días. Tiene un
        límite propio de 100 solicitudes por segundo por clave API. Exige una
        clave API con el permiso write o events:write.
      operationId: sendEvent
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventInput'
            example:
              name: order_shipped
              customer:
                external_id: u_8842
                email: ana@exemplo.com.br
                phone: '+5511988887777'
                name: Ana Souza
                attributes:
                  plano: premium
              properties:
                order_number: '10293'
                tracking:
                  code: BR123
                  carrier: Correios
                items:
                  - sku: CAM-01
                    name: Camiseta
                    quantity: 2
              occurred_at: '2026-11-18T14:03:00-03:00'
              external_id: ship_10293
      responses:
        '200':
          $ref: '#/components/responses/EventDuplicate'
        '201':
          $ref: '#/components/responses/EventCreated'
        '400':
          $ref: '#/components/responses/InvalidBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/EventsScopeRequired'
        '404':
          $ref: '#/components/responses/EventCustomerNotFound'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '422':
          $ref: '#/components/responses/EventValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Clave única de la operación. Repetir la misma clave con el mismo cuerpo
        devuelve la respuesta original en lugar de ejecutarla de nuevo.
      schema:
        type: string
  schemas:
    EventInput:
      type: object
      required:
        - name
        - customer
      additionalProperties: false
      properties:
        name:
          type: string
          pattern: ^[a-z][a-z0-9_]*$
          maxLength: 64
          description: >-
            Qué ocurrió, como order_shipped. Letras minúsculas, números y
            guiones bajos, empezando por una letra.
        customer:
          $ref: '#/components/schemas/EventCustomerInput'
        properties:
          type: object
          additionalProperties: true
          description: >-
            Detalles del evento, en formato libre y sin claves reservadas. Hasta
            200 claves en total, 5 niveles de profundidad y 100 elementos por
            lista.
        occurred_at:
          type: string
          format: date-time
          description: >-
            Cuándo ocurrió, en ISO 8601 con offset. Por defecto: el momento de
            la recepción.
        external_id:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            ID del hecho en tu sistema. Reenviar el mismo name y external_id
            dentro de 90 días devuelve el evento original y no dispara nada.
        backfill:
          type: boolean
          default: false
          description: >-
            Si es true, guarda el evento sin disparar flows. Úsalo para importar
            historial.
    EventCustomerInput:
      type: object
      description: >-
        A quién le ocurrió. Envía al menos un identificador: id, external_id,
        tax_id, email o phone.
      additionalProperties: false
      anyOf:
        - required:
            - id
        - required:
            - external_id
        - required:
            - tax_id
        - required:
            - email
        - required:
            - phone
      properties:
        id:
          type: string
          pattern: ^cus_[A-Za-z0-9_-]+$
          description: >-
            ID del cliente en Bevits. Un ID que no existe responde 404 y no se
            prueba ningún otro identificador.
        external_id:
          type: string
          minLength: 1
          maxLength: 255
          description: ID del cliente en tu sistema, comparado como texto exacto.
        tax_id:
          type: string
          minLength: 1
          maxLength: 32
          description: >-
            CPF o CNPJ válido (documentos fiscales de Brasil), con o sin
            puntuación.
        email:
          type: string
          format: email
          maxLength: 256
          description: Email del cliente, comparado en minúsculas.
        phone:
          type: string
          minLength: 3
          maxLength: 32
          description: >-
            Teléfono en E.164, como +5511988887777. Sin código de país, se asume
            el país de la tienda.
        name:
          type: string
          minLength: 1
          maxLength: 256
          description: Nombre del cliente.
        attributes:
          type: object
          description: >-
            Atributos del cliente a guardar. Solo cambian las claves enviadas;
            los atributos nuevos se crean con el tipo inferido.
          additionalProperties:
            oneOf:
              - type: string
                maxLength: 256
              - type: number
              - type: boolean
        consent:
          type: object
          description: >-
            Opt-in de marketing, leído solo cuando el evento crea al cliente.
            Sin él, el cliente se crea sin opt-in de marketing.
          additionalProperties: false
          properties:
            email:
              type: boolean
            whatsapp:
              type: boolean
    Event:
      type: object
      required:
        - object
        - id
        - name
        - occurred_at
        - received_at
        - customer
        - flows
        - backfill
        - livemode
      properties:
        object:
          type: string
          const: event
        id:
          type: string
          pattern: ^evt_[A-Za-z0-9_-]+$
        name:
          type: string
        external_id:
          type: string
        occurred_at:
          type: string
          format: date-time
        received_at:
          type: string
          format: date-time
        customer:
          type: object
          description: >-
            Cliente al que se vinculó el evento. Una clave solo de envío
            (events:write) recibe únicamente id.
          properties:
            id:
              type: string
              pattern: ^cus_[A-Za-z0-9_-]+$
              description: >-
                Ausente cuando el evento crearía al cliente y no se creó: en la
                validación y en el modo de prueba.
            matched_by:
              type: string
              enum:
                - id
                - external_id
                - tax_id
                - email
                - phone
              description: >-
                Identificador que encontró al cliente. Ausente cuando el evento
                creó al cliente.
            created:
              type: boolean
              description: true cuando el evento creó al cliente.
            would_create:
              type: boolean
              const: true
              description: >-
                Presente en la validación y en el modo de prueba, cuando el
                envío crearía al cliente.
        flows:
          type: array
          description: >-
            Flows activos que escuchan ese nombre de evento. Una lista vacía
            significa que ningún flow está escuchando.
          items:
            $ref: '#/components/schemas/EventFlow'
        properties:
          type: object
          additionalProperties: true
          description: Propiedades tal como se enviaron. Ausente después de 30 días.
        backfill:
          type: boolean
        livemode:
          type: boolean
        warnings:
          type: array
          description: >-
            Presente solo cuando hay algo que avisar. Un aviso nunca sustituye a
            un error.
          items:
            $ref: '#/components/schemas/EventWarning'
        duplicate:
          type: boolean
          const: true
          description: >-
            Presente cuando la llamada devolvió un evento que ya existía con el
            mismo name y external_id.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
    RateLimitErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          required:
            - retry_after
          properties:
            retry_after:
              type: integer
              minimum: 1
              description: Segundos antes de volver a intentarlo.
    EventFlow:
      type: object
      required:
        - id
        - name
        - status
      properties:
        id:
          type: string
          pattern: ^flw_[A-Za-z0-9_-]+$
        name:
          type: string
        status:
          type: string
          enum:
            - queued
            - started
            - skipped
          description: >-
            queued se decide en la respuesta del envío. Al consultar el evento
            después, el flow aparece como started o skipped.
        reason:
          type: string
          enum:
            - backfill
            - stale
            - filter_not_matched
            - test_mode
            - no_contact_channel
            - no_consent
            - flow_inactive
            - flow_error
            - dispatch_failed
          description: Por qué se omitió el flow. Presente cuando status es skipped.
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/EventFlowWarning'
          description: >-
            Lo que un flow iniciado no pudo hacer y quien envía puede corregir,
            como un mensaje omitido por una variable sin valor. Presente solo
            cuando hay algo que avisar.
    EventWarning:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          enum:
            - ambiguous_identifier
            - identifier_conflict
            - identifier_mismatch
            - payload_mismatch
        message:
          type: string
        param:
          type: string
    Error:
      type: object
      required:
        - type
        - message
        - request_id
      properties:
        type:
          type: string
          enum:
            - authentication_error
            - conflict
            - internal_error
            - invalid_request
            - not_found
            - permission_denied
            - rate_limited
            - validation_error
        code:
          type: string
          description: >-
            Motivo estable y legible por máquina dentro de type, como
            invalid_event_name. Presente cuando el error tiene un motivo con
            nombre.
        message:
          type: string
        param:
          type: string
          description: >-
            Ruta completa del campo con problema, como customer.email o
            events[3].name.
        suggestion:
          type: string
          description: Un valor que sería aceptado, cuando existe uno obvio.
        request_id:
          type: string
          pattern: ^req_[a-f0-9]{24}$
    EventFlowWarning:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          enum:
            - missing_variable
          description: >-
            missing_variable: se omitió un mensaje del flow porque una variable
            de la plantilla no tenía valor ni texto alternativo.
        message:
          type: string
        param:
          type: string
          description: >-
            La propiedad del evento que faltó, como properties.tracking.code.
            Ausente cuando la variable no es del evento.
  responses:
    EventDuplicate:
      description: >-
        Ya existía un evento con el mismo name y external_id. Devuelve el evento
        original con duplicate: true; no se guarda ni se dispara nada de nuevo.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Event'
          example:
            object: event
            id: evt_01jd2v9k3m8q4r5s6t7u8v9w0x
            name: order_shipped
            external_id: ship_10293
            occurred_at: '2026-11-18T17:03:00.000Z'
            received_at: '2026-11-18T17:03:01.000Z'
            customer:
              id: cus_ckabc123
              matched_by: external_id
              created: false
            flows:
              - id: flw_ckdef456
                name: Pedido enviado
                status: queued
              - id: flw_ckghi789
                name: Entrega expressa
                status: skipped
                reason: filter_not_matched
            properties:
              order_number: '10293'
              tracking:
                code: BR123
                carrier: Correios
              items:
                - sku: CAM-01
                  name: Camiseta
                  quantity: 2
            backfill: false
            livemode: true
            warnings:
              - code: payload_mismatch
                message: >-
                  An event with this name and external_id already exists with a
                  different body. The first one stands; this one was not stored.
            duplicate: true
    EventCreated:
      description: Evento nuevo, guardado y vinculado a un cliente.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Event'
          example:
            object: event
            id: evt_01jd2v9k3m8q4r5s6t7u8v9w0x
            name: order_shipped
            external_id: ship_10293
            occurred_at: '2026-11-18T17:03:00.000Z'
            received_at: '2026-11-18T17:03:01.000Z'
            customer:
              id: cus_ckabc123
              matched_by: external_id
              created: false
            flows:
              - id: flw_ckdef456
                name: Pedido enviado
                status: queued
              - id: flw_ckghi789
                name: Entrega expressa
                status: skipped
                reason: filter_not_matched
            properties:
              order_number: '10293'
              tracking:
                code: BR123
                carrier: Correios
              items:
                - sku: CAM-01
                  name: Camiseta
                  quantity: 2
            backfill: false
            livemode: true
    InvalidBody:
      description: >-
        Cuerpo de la solicitud ausente, que no es un objeto JSON, o parámetro de
        ruta inválido.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Clave API ausente, inválida, expirada o revocada.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: authentication_error
              message: Invalid API key.
              request_id: req_07f6cdc3c20249d6afcd90b4
    EventsScopeRequired:
      description: La clave API no tiene el permiso write ni el permiso events:write.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: permission_denied
              code: missing_scope
              message: 'This API key needs one of these scopes: "write", "events:write".'
              param: scope
              request_id: req_07f6cdc3c20249d6afcd90b4
    EventCustomerNotFound:
      description: >-
        customer.id no corresponde a ningún cliente activo. Los demás
        identificadores no se prueban.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: not_found
              code: customer_not_found
              message: >-
                No customer has this id. Remove customer.id to match by the
                other identifiers.
              param: customer.id
              request_id: req_07f6cdc3c20249d6afcd90b4
    IdempotencyConflict:
      description: La Idempotency-Key ya se usó con otro cuerpo de solicitud.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    EventValidationError:
      description: >-
        El evento fue rechazado y no se guardó nada. error.code nombra el
        motivo, error.param trae la ruta completa del campo y error.suggestion,
        cuando existe, un valor que sería aceptado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: validation_error
              code: invalid_event_name
              message: >-
                Event names use lowercase letters, digits and underscores, start
                with a letter and have at most 64 characters. Did you mean
                "order_shipped"?
              param: name
              suggestion: order_shipped
              request_id: req_07f6cdc3c20249d6afcd90b4
    RateLimited:
      description: Límite de solicitudes superado.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitErrorResponse'
    InternalError:
      description: Error inesperado en el servidor.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  headers:
    RateLimitLimit:
      description: Límite total de la ventana actual.
      schema:
        type: integer
        example: 600
    RateLimitRemaining:
      description: Solicitudes restantes en la ventana actual.
      schema:
        type: integer
        example: 599
    RateLimitReset:
      description: Instante UTC en que termina la ventana actual.
      schema:
        type: string
        format: date-time
    RetryAfter:
      description: Segundos antes de volver a intentarlo.
      schema:
        type: integer
        minimum: 1
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: bvt_live_...
      description: Clave API creada en la configuración de la organización.

````

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