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

# Emit event

> Create a behavior event. This will trigger matching campaigns to offer rewards to the customer. For PURCHASE events, campaign e-commerce scope is evaluated against order.store_id, order.channel_id, and product skus. Campaigns with null e-commerce scope have no e-commerce restriction; campaigns with non-empty scope arrays only match events that contain the required entities.



## OpenAPI

````yaml POST /behavior/events
openapi: 3.0.1
info:
  title: Masivo's REST API
  description: Learn how to use Masivo's REST API
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://app.masivo.ai/api/storefront/v1
security:
  - bearerAuth: []
paths:
  /behavior/events:
    post:
      description: >-
        Create a behavior event. This will trigger matching campaigns to offer
        rewards to the customer. For PURCHASE events, campaign e-commerce scope
        is evaluated against order.store_id, order.channel_id, and product skus.
        Campaigns with null e-commerce scope have no e-commerce restriction;
        campaigns with non-empty scope arrays only match events that contain the
        required entities.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - customer_id
                - brand_id
                - type
              properties:
                customer_id:
                  type: string
                  description: The customer unique identifier in your system
                brand_id:
                  type: string
                  description: The id of the brand that originate the event
                type:
                  type: string
                  description: The type of the event
                  example: PURCHASE
                platform:
                  type: string
                  description: Platform name where the event originated
                  nullable: true
                order:
                  $ref: '#/components/schemas/Order'
                  description: The order in case of a PURCHASE event
                product:
                  $ref: '#/components/schemas/OrderProduct'
                  description: The product in case of an ADD_TO_CART event
                fulfilled:
                  type: boolean
                  description: >-
                    If the event was fulfilled, when false, rewards to be
                    redeemed will be reserved until fulfilled
                  default: true
                reserve:
                  type: number
                  format: int2
                  description: The number of days to reserve the rewards
                  default: 1
                redeem:
                  type: array
                  description: The rewards to redeem in the order
                  items:
                    $ref: '#/components/schemas/RedemptionReward'
                tags:
                  type: object
                  description: Include your conditions event tags here
                referral_code:
                  type: string
                  description: (Optional) The referral code to track the event
                metadata:
                  type: object
                  description: Include any additional info here
                issued_at:
                  type: string
                  format: date-time
                  description: >-
                    Optional ISO 8601 timestamp of when the event occurred. Must
                    be within the last 72 hours and cannot be in the future.
                    Defaults to the current server time if not provided.
                  example: '2026-03-25T10:00:00.000Z'
            example: {}
        required: true
      responses:
        '200':
          description: Event enqueued for processing
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Event'
        '422':
          description: Invalid event
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Order:
      type: object
      required:
        - purchase_id
        - value
        - products
        - payment_method
      properties:
        purchase_id:
          type: string
          description: The id of a placed order in your system
        channel_id:
          type: string
          description: >-
            The channel unique identifier in your system. Used to match campaign
            and reward e-commerce channel restrictions.
        store_id:
          type: string
          description: >-
            The store unique identifier in your system. Used to match campaign
            and reward e-commerce store restrictions.
        value:
          type: number
          description: The order total or subtotal
          example: 20.95
        discounted_value:
          type: number
          description: The order total or subtotal after discounts
          example: 10.95
        products:
          type: array
          description: >-
            Products in the order. Product sku values are used to match campaign
            and reward e-commerce product restrictions.
          minimum: 1
          items:
            $ref: '#/components/schemas/OrderProduct'
        shipping:
          $ref: '#/components/schemas/Shipping'
          description: The shipping information of the order
        payment_method:
          type: string
          description: The payment method used in the order
          enum:
            - CREDIT
            - DEBIT
            - CASH
            - BANK_TRANSFER
            - OTHER
        redeem:
          type: array
          description: The rewards to redeem in the order
          items:
            $ref: '#/components/schemas/RedemptionReward'
        metadata:
          type: object
          description: The metadata of the order
    OrderProduct:
      type: object
      required:
        - sku
        - amount
        - value
      properties:
        sku:
          type: string
          description: >-
            The product sku. Used to match campaign and reward e-commerce
            product restrictions.
        amount:
          type: number
          description: The quantity of the product
        value:
          type: number
          description: The total or subtotal of the product
        discounted_value:
          type: number
          description: The total or subtotal of the product after discounts
        redeem:
          type: array
          description: The rewards to redeem in the product
          items:
            $ref: '#/components/schemas/RedemptionReward'
        tags:
          type: object
          description: Include your conditions event tags here
        metadata:
          type: object
          description: Include any additional info here
    RedemptionReward:
      type: object
      properties:
        id:
          type: string
          description: The reward id to redeem
          format: uuid
        amount:
          type: number
          description: The amount of the reward to redeem. (Per product if applicable)
          example: 1
    Event:
      type: object
      properties:
        id:
          type: string
          description: The event internal unique identifier
          format: uuid
        customer_id:
          type: string
          description: The customer id of the event
          format: uuid
        type:
          type: string
          description: The type of the event
          example: PURCHASE
        data:
          type: object
          description: The data used in the event
        fulfilled:
          type: boolean
          description: If the event was fulfilled.
        reserve:
          type: number
          format: int2
          description: The number of days to reserve the rewards
        queue_message_id:
          type: string
          description: The message id in the queue
        rewarding_campaigns:
          type: array
          description: >-
            The campaigns that rewarded the event including the rules that
            matched
        status:
          type: string
          description: The status of the event
          enum:
            - PENDING
            - PROCESSING
            - FAILED
            - RESOLVED
            - CANCELLED
            - EXPIRED
            - REVERSED
        result:
          type: object
          properties:
            wallet:
              type: object
              description: The wallet state after the event
              items:
                $ref: '#/components/schemas/Wallet'
            customer:
              type: object
              description: The customer state after the event
              items:
                $ref: '#/components/schemas/Customer'
            gift_card:
              type: array
              description: Gift cards related to the event
              items:
                $ref: '#/components/schemas/GiftCard'
            accumulations:
              type: array
              description: Total accumulations after the event
              items:
                $ref: '#/components/schemas/Line'
            redemptions:
              type: array
              description: Redemptions made during the event
              items:
                $ref: '#/components/schemas/Line'
            transactions:
              type: array
              description: Total transactions after the event
              items:
                $ref: '#/components/schemas/Transaction'
            customer_by_tier:
              type: array
              description: Customer tier changes resulting from the event
              items:
                type: object
          description: The result of the event
        issued_at:
          type: string
          description: The date when the event was issued
          format: date-time
        processing_at:
          type: string
          description: The date when the event was processed
          format: date-time
          nullable: true
        resolved_at:
          type: string
          description: The date when the event was resolved either succeed or failed
          format: date-time
          nullable: true
        cancelled_at:
          type: string
          description: The date when the event was cancelled
          format: date-time
          nullable: true
        expired_at:
          type: string
          description: The date when the event expired
          format: date-time
          nullable: true
        reversed_at:
          type: string
          description: The date when the event was reversed
          format: date-time
          nullable: true
    Error:
      required:
        - error
        - details
      type: object
      properties:
        error:
          type: string
        details:
          type: string
    Shipping:
      type: object
      properties:
        value:
          type: number
          description: The shipping cost
          example: 3.25
        discounted_value:
          type: number
          description: The shipping cost after discounts
          example: 2.25
        redeem:
          type: array
          description: The rewards to redeem in the shipping
          items:
            $ref: '#/components/schemas/RedemptionReward'
        tags:
          type: object
          description: Include your conditions event tags here
        metadata:
          type: object
          description: Include any additional info here
    Wallet:
      type: object
      properties:
        id:
          type: string
          description: The wallet internal unique identifier
          format: uuid
        owner_id:
          type: string
          description: The customer internal unique identifier
          format: uuid
        lines:
          $ref: '#/components/schemas/Lines'
          description: >-
            Each line represents a batch of a given reward_id that expires at
            the same time
        totals:
          type: array
          description: The wallet totals by reward
          items:
            type: object
            properties:
              total:
                type: number
                description: The total amount of the reward
                example: 127.6
              reward_id:
                type: string
                description: The reward id of the total
                format: uuid
              expiration_date:
                type: string
                description: The expiration date of the total
                format: date-time
              reward:
                $ref: '#/components/schemas/Reward'
    Customer:
      type: object
      required:
        - id
        - name
        - email
        - registration_date
      properties:
        id:
          type: string
          description: Your customer unique identifier
        status:
          description: The status of the customer
          type: string
          enum:
            - ACTIVE
            - INACTIVE
        is_anonymous:
          description: Whether the customer is anonymous
          type: boolean
          default: false
        name:
          description: The full name of the customer
          type: string
          example: John Smith
        email:
          description: The email of the customer
          type: string
          format: email
        gender:
          description: The gender of the customer
          type: string
          nullable: true
          enum:
            - MALE
            - FEMALE
        dob:
          description: The date of birth of the customer
          type: string
          nullable: true
          format: date-time
        document_type:
          description: The document type of the customer
          type: string
          nullable: true
        document_number:
          description: The document number of the customer
          type: string
          nullable: true
          maxLength: 50
        country:
          description: The country of the customer
          type: string
          nullable: true
          maxLength: 100
        phone:
          description: >-
            The customer's phone number in international format. Required for
            WhatsApp delivery.
          type: string
          nullable: true
          example: +593 99 123 4567
        phone_verified:
          description: Whether the customer's phone number is verified
          type: boolean
          default: false
        registration_date:
          description: The date when the customer was registered
          type: string
          format: date-time
        tier_id:
          description: The id of the tier the customer currently belongs to
          type: string
          format: uuid
        tags:
          type: object
          description: Include your conditions customer tags here
        consent:
          $ref: '#/components/schemas/Consent'
          description: The customer's consent preferences
          nullable: true
        metrics:
          description: The metrics of the customer
          type: object
        metadata:
          description: The metadata of the customer
          type: object
    GiftCard:
      type: object
      required:
        - code
        - reward_id
        - customer_id
        - rewarded_at
      properties:
        code:
          type: string
          description: The gift card code to use in the store
        description:
          type: string
          description: The gift card description
        reward_id:
          type: string
          description: The reward id of the gift card
          format: uuid
        customer_id:
          type: string
          description: The customer id that owns the gift card
          format: uuid
        expired_at:
          type: string
          description: The expiration date of the gift card
          format: date-time
          nullable: true
        rewarded_at:
          type: string
          description: The date when the gift card was issued to a customer
          format: date-time
        redeemed_at:
          type: string
          description: The date when the gift card was redeemed
          format: date-time
          nullable: true
    Line:
      type: object
      properties:
        amount:
          type: number
          description: The amount of the line
        reward_id:
          type: string
          description: The reward id of the line
          format: uuid
        campaign_id:
          type: string
          description: The campaign id of the line
          format: uuid
          nullable: true
        brand_id:
          type: string
          description: The id of the brand that originated the line
          format: uuid
          nullable: true
        issued_at:
          type: string
          description: The date when the line was issued
          format: date-time
        expiration_date:
          type: string
          description: The expiration date of the line
          format: date-time
        reservation_expires_at:
          type: string
          description: The reservation expiration date of the line
          format: date-time
          nullable: true
    Transaction:
      type: object
      properties:
        id:
          type: string
          description: The transaction internal unique identifier
          format: uuid
        brand_id:
          type: string
          description: The brand id of the transaction
          nullable: true
        event_id:
          type: string
          description: The id of the event the created the transaction
          format: uuid
          nullable: true
        campaign_id:
          type: string
          description: The id of the campaign that created the transaction
          format: uuid
          nullable: true
        channel_id:
          type: string
          description: The id of the channel that created the transaction
          format: uuid
          nullable: true
        store_id:
          type: string
          description: The id of the store that created the transaction
          format: uuid
          nullable: true
        funded_by:
          type: string
          description: Who funded the rewards used in this transaction
          nullable: true
          example: MARKETING
        event_type:
          type: string
          description: The type of the event that created the transaction
          example: PURCHASE
        reward_type:
          type: string
          description: The type of the reward used in the transaction
          enum:
            - POINTS
            - DISCOUNT
            - GIFT_CARD
            - PRODUCT
        reward_id:
          type: string
          description: The reward id of the transaction
          format: uuid
        amount:
          type: number
          description: The amount of the transaction
        cost:
          type: number
          description: The cost of the rewards used in the transaction
          nullable: true
        details:
          type: string
          description: The explanation of why transaction was created
        type:
          type: string
          description: The type of the transaction
          enum:
            - ACCUMULATION
            - REDEMPTION
            - EXPIRATION
            - MIGRATION
            - TRANSFER
            - REVERSAL
        receiver_id:
          type: string
          description: The receiver id of the transaction
        sender_id:
          type: string
          description: The sender id of the transaction
        created_at:
          type: string
          description: The date when the transaction was created
          format: date-time
        issued_at:
          type: string
          description: The date when the transaction was issued
          format: date-time
        attributes:
          type: object
          description: The attributes of the transaction
          required:
            - line
          properties:
            line:
              $ref: '#/components/schemas/Line'
              description: The line used to create the transaction
              nullable: true
            campaign_name:
              type: string
              description: The name of the campaign that created the transaction
        metadata:
          type: object
          description: The metadata of the transaction
    Lines:
      type: array
      items:
        $ref: '#/components/schemas/Line'
    Reward:
      allOf:
        - type: object
          properties:
            id:
              type: string
              description: The reward internal unique identifier
              format: uuid
        - $ref: '#/components/schemas/RewardInsert'
    Consent:
      type: object
      required:
        - consent_string
      properties:
        version:
          type: string
          description: IAB TCF version
          example: '2.0'
        consent_timestamp:
          type: string
          format: date-time
          description: The timestamp when consent was given
        customer_id:
          type: string
          description: The customer unique identifier
        purposes:
          $ref: '#/components/schemas/ConsentPurposes'
        vendors:
          type: object
          description: 'Vendor consent mapping (vendor_id: boolean)'
          additionalProperties:
            type: boolean
          example:
            vendor_123: true
            vendor_456: false
        consent_string:
          type: string
          description: >-
            IAB TCF consent string in base64url format, starting with 'CO',
            minimum 20 characters, maximum 500 characters
          example: COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA
          minLength: 20
          maxLength: 500
          pattern: ^CO[A-Za-z0-9_-]+$
    RewardInsert:
      type: object
      properties:
        brand_id:
          type: string
          description: The brand id of the reward, null if is a global reward
          nullable: true
        platforms:
          type: array
          description: Platforms where this reward applies
          items:
            type: string
          nullable: true
        stores:
          type: array
          description: >-
            Store ids this reward is restricted to. null means no store
            restriction; a non-empty array restricts the reward to those stores;
            [] is an explicit empty restriction and matches no stores.
          items:
            type: string
          nullable: true
        channels:
          type: array
          description: >-
            Channel ids this reward is restricted to. null means no channel
            restriction; a non-empty array restricts the reward to those
            channels; [] is an explicit empty restriction and matches no
            channels.
          items:
            type: string
          nullable: true
        products:
          type: array
          description: >-
            Product ids this reward is restricted to. null means no product
            restriction; a non-empty array restricts the reward to those
            products; [] is an explicit empty restriction and matches no
            products.
          items:
            type: string
          nullable: true
        name:
          type: string
          description: The name of the reward
        description:
          type: string
          description: The description of the reward
        type:
          type: string
          description: The type of the reward
          enum:
            - POINTS
            - DISCOUNT
            - GIFT_CARD
            - PRODUCT
            - CUSTOM
        conditions:
          $ref: '#/components/schemas/AlternativeCondition'
        attributes:
          description: The attributes of the reward
          oneOf:
            - type: object
              description: The attributes of rewards of type POINTS
              properties:
                conversion_factor:
                  type: number
                  description: How much 1 point is worth in your currency
                  example: 0.1
            - description: The attributes of rewards of type DISCOUNT
              type: object
              properties:
                discount_value:
                  type: number
                  description: The discount value
                  example: 10
                discount_type:
                  type: string
                  description: The type of discount
                  enum:
                    - fixed
                    - percentage
                type:
                  type: string
                  description: The discount will be applied to
                  enum:
                    - shipping
                    - order
                    - product
    ConsentPurposes:
      type: object
      properties:
        behavioral_campaigns:
          type: boolean
          description: Consent for behavioral campaigns
        coupon_campaigns:
          type: boolean
          description: Consent for coupon campaigns
        punchcard_campaigns:
          type: boolean
          description: Consent for punchcard campaigns
        email_marketing:
          type: boolean
          description: Consent for email marketing
        push_notifications:
          type: boolean
          description: Consent for push notifications
        link_tracking:
          type: boolean
          description: Consent for link tracking
    AlternativeCondition:
      type: array
      description: OR conditions
      items:
        $ref: '#/components/schemas/CompoundCondition'
    CompoundCondition:
      type: array
      description: AND conditions
      items:
        $ref: '#/components/schemas/Condition'
    Condition:
      type: object
      properties:
        type:
          type: string
          description: The type of the condition
          example: Order Value
        operator:
          type: string
          description: The operator to compare the attribute
          example: grater than
        primitive:
          type: string
          description: The primitive of the value to compare
          enum:
            - string
            - number
            - currency
            - boolean
            - absolute date
            - relative date
            - recurring date
        value:
          oneOf:
            - type: number
              example: 9.95
            - type: string
            - type: boolean
          description: The value to compare
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````