Record a conversion / revenue event
method
POST
host
strait.
version
/v1
resource
/
POST /v1/event
Auth: publishable key as publishableKey in the JSON body. Safe in apps and websites.
Request
From an app or website send publishableKey; from a server you may instead authenticate with the secret key as a Bearer token. clickId names the tap the conversion came from: every tap gets a unique id (a UUID, sent with the tap's redirect and passed to your app with the open), which the mobile SDKs remember from the attributed app open and attach for 7 days. It is kept only when it is a tap of this workspace; otherwise it is ignored and the event is still recorded. Each new event (not an eventId retry) is sent to your webhooks subscribed to app.event, with data and sentWith (publishable_key or secret_key: trust revenue sent from your server) and userId / userIdHashed (your user, when set). Webhook sends for events sent with the publishable key are capped per workspace (600 burst, then 10 a second): past that, they are still recorded but not sent. Events sent with the secret key are not capped.
Body (JSON)
publishableKeystringeventrequired stringvaluenumbercurrencystringlinkIdstring- Optional: with a known clickId it is filled in from that tap
platformstringclickIdstring- The id of the tap this conversion came from (the mobile SDKs fill it in)
eventIdstring- Optional idempotency id, e.g. your order id: a retry with the same eventId is accepted but stored once. An event sent with your secret key replaces one sent first with the publishable key (keeping its tap and link when it has none) and is sent to your webhooks again, so a receiver de-duplicates on eventId + sentWith; nothing replaces a secret-key event.
dataobject,null- Optional custom key-values (at most 20, 2 KB as JSON) passed to the app.event webhook. Not stored with the event; kept 30 days with the webhook delivery. Do not send personal data your receiver does not need.
userIdstring- Optional: your own user id (the SDKs' setUserId), passed to the app.event webhook as
userIdso you can join events to your users. Not stored with the event; kept 30 days with the webhook delivery. An email (any@,@or﹫) or phone number (8-15 digits with spaces, dashes, dots, brackets or slashes, an optional + / 00 / tel:; Indian, Arabic and full-width digits too) is replaced by its SHA-256 hex (of the lower-cased email; of + and the digits when written with + or 00, else of the digits, e.g.sha256("+919876543210")) and sent withuserIdHashed: true; the SDKs do this on the device. Trimmed; empty, longer than 128 characters or with control characters = dropped (the event is still recorded). Sent with the publishable key,userIdis a claim anyone with your app key can make: trust it only onsentWith: secret_keyevents or check it against your own records. userIdHashedboolean- True when
userIdis already the SHA-256 of an email or phone as 64 lower-case hex characters (the SDKs set it); anything else is treated as a raw id.
Response
- 202 Accepted.
clickIdechoes the tap id that was stored, or null when none was given or it was not a tap of this workspace. - 401 Missing or invalid key
curl -X POST https://strait.link/v1/event \
-H "Content-Type: application/json" \
-d '{
"publishableKey": "st_pub_live_…",
"event": "purchase",
"value": 499,
"currency": "INR",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"eventId": "ord_1001",
"data": {
"plan": "gold"
},
"linkId": "<link id from POST /v1/links>"
}'const res = await fetch('https://strait.link/v1/event', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"publishableKey": "st_pub_live_…",
"event": "purchase",
"value": 499,
"currency": "INR",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"eventId": "ord_1001",
"data": {
"plan": "gold"
},
"linkId": "<link id from POST /v1/links>"
}),
});
const data = await res.json();
console.log(res.status, data);import requests
res = requests.post(
"https://strait.link/v1/event",
json={
"publishableKey": "st_pub_live_…",
"event": "purchase",
"value": 499,
"currency": "INR",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"eventId": "ord_1001",
"data": {
"plan": "gold",
},
"linkId": "<link id from POST /v1/links>",
},
)
print(res.status_code, res.json())<?php
// Plain PHP with ext-curl, no packages. In Laravel, Http::post($url, $body) sends the same request.
$ch = curl_init('https://strait.link/v1/event');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'publishableKey' => 'st_pub_live_…',
'event' => 'purchase',
'value' => 499,
'currency' => 'INR',
'clickId' => '9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34',
'eventId' => 'ord_1001',
'data' => [
'plan' => 'gold',
],
'linkId' => '<link id from POST /v1/links>',
], JSON_THROW_ON_ERROR),
]);
$response = curl_exec($ch);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status, PHP_EOL;
print_r(json_decode($response, true));import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
// Java 17+, java.net.http only (no dependencies).
public class Main {
public static void main(String[] args) throws Exception {
String body = """
{
"publishableKey": "st_pub_live_…",
"event": "purchase",
"value": 499,
"currency": "INR",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"eventId": "ord_1001",
"data": {
"plan": "gold"
},
"linkId": "<link id from POST /v1/links>"
}
""";
HttpRequest request = HttpRequest.newBuilder(URI.create("https://strait.link/v1/event"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());
}
}package main
import (
"fmt"
"io"
"log"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"publishableKey": "st_pub_live_…",
"event": "purchase",
"value": 499,
"currency": "INR",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"eventId": "ord_1001",
"data": {
"plan": "gold"
},
"linkId": "<link id from POST /v1/links>"
}`)
req, err := http.NewRequest(http.MethodPost, "https://strait.link/v1/event", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
data, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(res.StatusCode, string(data))
}The response, printed
{
"ok": true,
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"linkId": "lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63"
}