Create a conversion goalMenu

Create a conversion goal

POST/v1/conversion-goals

Requires an API key with the conversion-goals:write scope. About keys and scopes

Works with integration, agent and partner keys.

A repeat after success is refused with 409 ALREADY_EXISTS: read the one the first created. About idempotency

Counts an event as a conversion when the contact was sent the campaign or journey within the attribution window before it. Narrow which events count with where (property conditions, all must hold) and occurrence (first or repeat of the contact's events of that name), as a workspace goal's event step does. Set valueProperty to sum an event property (such as total) as revenue, and currency to label it; an event whose own currency property names another currency converts without a value, since amounts are never converted, and so does one whose value is negative, not numeric, or too large. Events from the goal's creation on are matched as they are processed; the retained history before it is matched in the background from countedFrom, so the goal's results fill in shortly after it is created. A campaign or journey can count one event under several goals with different filters; a second goal with the same event and filter is refused with 409 ALREADY_EXISTS, since it would count every conversion twice. Goals count the workspace's own events, so the Free plan is refused with 403 PLAN_FEATURE_UNAVAILABLE.

Header parameters

Kirora-Workspacestringoptional

Partner keys only: the child workspace to act in, by the external id the partner gave it. Without it, a partner key acts in its own workspace. Any other key that sends it is refused with 403, and an unknown workspace is 404.

pattern ^[A-Za-z0-9._:-]{1,128}$

Idempotency-Keystringoptional

Makes a retry safe: a repeat with the same key and body within 24 hours gets the first response again, with Idempotency-Replay: true. The same key with another request is 409 IDEMPOTENCY_KEY_REUSED; while the first is still running, 409 IDEMPOTENCY_KEY_IN_USE; after an unsafe first request failed or never returned, 409 IDEMPOTENCY_KEY_OUTCOME_UNKNOWN. Use a new key, such as a UUID, for each new request.

8–255 characters

Request body

campaignIdstringoptional

The campaign it measures.

uuid

journeyIdstringoptional

The journey it measures.

uuid

eventNamestringrequired

The event that counts as a conversion.

1–128 characters

whereobject[]optional

Property conditions the event must meet, up to 5; with several names, each of them must meet them.

at least 1 item · at most 5 items

3 child attributes
propertystringrequired

The event property key.

1–64 characters

operatorstringrequired

notEquals also matches an event without the property. equals and notEquals compare the property as text, ignoring case and accents.

one of equals, notEquals, gt, gte, lt, lte

valuestringrequired

What to compare with, as text ("pro", "true"); a number ("50") for gt, gte, lt and lte.

up to 255 characters

occurrencestringoptional

first: only the contact's first event of these names; repeat: any after it. Read from the event history, so a contact whose earlier ones predate it counts as first seen (coverageFrom on progress says where the history starts); a property the customer sends (first_order) is the stricter signal. Absent: every one.

one of first, repeat

attributionWindowDurationInputoptional

How long after a message the event still counts: 1 to 3,650 whole days, default 30 days.

2 child attributes
valueintegerrequired

min > 0

unitstringrequired

one of seconds, minutes, hours, days

valuePropertystringoptional

The event property summed as revenue, such as total.

1–64 characters

currencystringoptional

The revenue's currency, an ISO 4217 code; needs valueProperty.

pattern ^[A-Z]{3}$

Returns

Returns 201 Created with a ConversionGoal in data. It can also return 409 Conflict, 413 Payload Too Large or 415 Unsupported Media Type; see the statuses below. Otherwise returns an error; Errors lists every code and which to retry.

  • 201 CreatedThe new goal.
  • 409 ConflictThe request conflicts with current state — a duplicate unique value, or a resource whose status does not allow this operation.
  • 413 Payload Too LargeThe body is larger than this operation accepts (PAYLOAD_TOO_LARGE).
  • 415 Unsupported Media TypeThe body is not JSON, or not the upload the operation takes (UNSUPPORTED_MEDIA_TYPE).
idstringrequired

uuid

campaignIdstring | nullrequired

The campaign it measures.

uuid

journeyIdstring | nullrequired

The journey it measures.

uuid

eventNamestringrequired

The event that counts as a conversion.

whereobject[] | nullrequired

Property conditions the event must meet; null counts every one.

at least 1 item · at most 5 items

3 child attributes
propertystringrequired

The event property key.

1–64 characters

operatorstringrequired

notEquals also matches an event without the property. equals and notEquals compare the property as text, ignoring case and accents.

one of equals, notEquals, gt, gte, lt, lte

valuestringrequired

What to compare with, as text ("pro", "true"); a number ("50") for gt, gte, lt and lte.

up to 255 characters

occurrencestring | nullrequired

first: only the contact's first event of this name; repeat: any after it; null: every one.

one of first, repeat

attributionWindowDurationrequired

How long after a message the event still counts, in days.

2 child attributes
valueintegerrequired

min > 0

unitstringrequired

one of seconds, minutes, hours, days

windowChangedAtstring | nullrequired

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.

date-time

valuePropertystring | nullrequired

The event property summed as revenue; null counts no value.

currencystring | nullrequired

The revenue's currency, if named.

countedFromstringrequired

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.

date-time

createdAtstringrequired

date-time

Headers on 201 Created

Idempotency-Replaystringoptional

true when this is the stored response to an earlier request with the same key.

one of true