---
title: "Track Custom Event (client-side)"
method: POST
path: "/client/v1/events"
tags: ["Client-side"]
---

# Track Custom Event (client-side)

`POST /client/v1/events`

To track a custom event, you create an event object.  

The event object must be linked to the customer who performs the action. If a customer doesn't exist in Voucherify, the customer will be created.

## Headers

- `origin` string, hostname, required

## Request body

- ClientEventsCreateRequestBody — Request body schema for **POST** `v1/events`.
  - `event` string, required — Event name. This is the same name that you used to define a custom event in the **Dashboard** > **Project Settings** > **Event Schema**.
  - `customer` Customer, required
    - `id` string — The ID of an existing customer.
    - `source_id` string — A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored.
    - `name` string — Customer's first and last name.
    - `description` string — An arbitrary string that you can attach to a customer object.
    - `email` string — Customer's email address.
    - `phone` string — Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel.
    - `birthday` string, date — `Deprecated`. ~~Customer's birthdate; format YYYY-MM-DD~~.
    - `birthdate` string, date — Customer's birthdate; format YYYY-MM-DD.
    - `address` object, nullable — Customer's address.
      - `city` string — City
      - `state` string — State
      - `line_1` string — First line of address.
      - `line_2` string — Second line of address.
      - `country` string — Country.
      - `postal_code` string — Postal code.
    - `metadata` object — A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments.
  - `referral` object — If a **conversion event** for a referral program is set to a custom event, then you need to send the referral code in the payload to make a record of the conversion event.
    - `code` string, required — A code through which a new visitor has been referred to a service.
    - `referrer_id` string — Unique ID of the referring person - it is optional and not required if the referral **code** is provided.
  - `loyalty` object — If an earning rule in a loyalty program is based on a custom event. This objects let's you specify the loyalty card to which the custom event should be attributed to.
    - `code` string, required — Code of the loyalty card to receive points based on the calculation method defined in the related earning rule. An earning rule is triggered for the loyalty card when the event passed in the `event` parameter of the request payload gets sent along with this loyalty card code.
  - `metadata` object — The metadata object stores all custom attributes assigned to the event. A set of key/value pairs that you can attach to an event object. It can be useful for storing additional information about the event in a structured format. Event metadata schema is defined in the **Dashboard** > **Project Settings** > **Event Schema** > **Edit particular event** > **Metadata property definition**.

## Response `200`

Returns the event type if the event was received by the application.

- ClientEventsCreateResponseBody — Response body schema for **POST** `v1/events`.
  - `object` 'event', required — The object represented is an `event`.
  - `type` string, required — The event name.
  - `customer` SimpleCustomerRequiredObjectType, required — This is an object representing a customer with limited properties used in Event Tracking endpoints.
    - `id` string — The unique ID of a customer that is assigned by Voucherify.
    - `source_id` string — The merchant's customer ID if it is different from the Voucherify customer ID. It is really useful in case of an integration between multiple systems. It can be a customer ID from a CRM system, database or 3rd-party service.
    - `name` string — Customer's first and last name.
    - `email` string — Customer's email address.
    - `metadata` object — A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments.
    - `object` string, required — The type of the object represented by the JSON. This object stores information about the customer.
  - `referral` object, nullable, required — A `null` referral object.
  - `loyalty` object, nullable, required — A `null` loyalty object.
  - `metadata` object, required

## Other responses

- `400` — Returns an error if the request payload is incomplete.

---

[API](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions.md) · [All operations](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/voucherifyio/voucherify-api-async-actions/versions/4982266e0494/schema)
