# Conversion goals

Source: https://kirora.io/docs/api/reference/conversion-goals

A conversion goal says what counts as a result for a campaign or a journey: an event, such as an order, done within a window after one of its messages, with an event property summed as revenue. A journey's and a campaign's metrics report their goals; a journey can also end each enrollment when its goal is reached. Goals need a paid plan.

## Endpoints

- [List the conversion goals of a campaign or journey](https://kirora.io/docs/api/reference/listConversionGoals): `GET /v1/conversion-goals`
- [Create a conversion goal](https://kirora.io/docs/api/reference/createConversionGoal): `POST /v1/conversion-goals`
- [Change a conversion goal](https://kirora.io/docs/api/reference/updateConversionGoal): `PATCH /v1/conversion-goals/{id}`
- [Delete a conversion goal](https://kirora.io/docs/api/reference/deleteConversionGoal): `DELETE /v1/conversion-goals/{id}`
- [Report a conversion goal's results](https://kirora.io/docs/api/reference/getConversionGoalMetrics): `GET /v1/conversion-goals/{id}/metrics`

## The ConversionGoal object

```json
{
  "id": "018f2a4e-6b1c-7d3e-9f40-37386ae05a6b",
  "campaignId": "018f2a4e-6b1c-7d3e-9f40-3478765e5a6b",
  "journeyId": "018f2a4e-6b1c-7d3e-9f40-7cf2bf7e5a6b",
  "eventName": "eventName_example",
  "where": [
    {
      "property": "property_example",
      "operator": "equals",
      "value": "value_example"
    }
  ],
  "occurrence": "first",
  "attributionWindow": {
    "value": 1,
    "unit": "seconds"
  },
  "windowChangedAt": "2030-03-14T09:30:00Z",
  "valueProperty": "valueProperty_example",
  "currency": "currency_example",
  "countedFrom": "2030-03-14T09:30:00Z",
  "createdAt": "2030-03-14T09:30:00Z"
}
```

- `id` (string, required, uuid)
- `campaignId` (string | null, required, uuid) — The campaign it measures.
- `journeyId` (string | null, required, uuid) — The journey it measures.
- `eventName` (string, required) — The event that counts as a conversion.
- `where` (object[] | null, required, at least 1 item, at most 5 items) — Property conditions the event must meet; `null` counts every one.
  - `property` (string, required, 1–64 characters) — The event property key.
  - `operator` (string, required, one of `equals`, `notEquals`, `gt`, `gte`, `lt`, `lte`) — `notEquals` also matches an event without the property. `equals` and `notEquals` compare the property as text, ignoring case and accents.
  - `value` (string, required, up to 255 characters) — What to compare with, as text (`"pro"`, `"true"`); a number (`"50"`) for `gt`, `gte`, `lt` and `lte`.
- `occurrence` (string | null, required, one of `first`, `repeat`) — `first`: only the contact's first event of this name; `repeat`: any after it; `null`: every one.
- `attributionWindow` (Duration, required) — How long after a message the event still counts, in days.
  - `value` (integer, required, min > 0)
  - `unit` (string, required, one of `seconds`, `minutes`, `hours`, `days`)
- `windowChangedAt` (string | null, required, date-time) — When the attribution window was last changed; `null` if never. A change applies to events processed after it: conversions counted before keep the window they were counted under.
- `valueProperty` (string | null, required) — The event property summed as revenue; `null` counts no value.
- `currency` (string | null, required) — The revenue's currency, if named.
- `countedFrom` (string, required, date-time) — The earliest events the goal can count: when it was created, the start of the event history then retained. Events from then on are matched to the sends before them, those tracked before the goal existed included; older ones are gone.
- `createdAt` (string, required, date-time)
