Report that a link opened the app
method
POST
host
strait.
version
/v1
resource
/
POST /v1/open
Auth: publishable key as publishableKey in the JSON body. Safe in apps and websites.
Request
Sent by the Strait SDKs for every link open they cannot report through /v1/resolve, /v1/referrer or /v1/match (browser hand-offs, your own https links), and to retry any open report that failed to send. De-duplicated by openId.
Body (JSON)
publishableKeyrequired stringopenIdrequired stringkindrequired "direct" | "deferred"routerequired "app_link" | "custom_scheme" | "install_referrer" | "fingerprint"appState"closed" | "background" | "foreground"platformrequired stringurlstring- The opened URL (only host + path are stored)
clickIdstring- The tap id from strait_click
linkIdstringmatchedbooleanreasonstringfirstLaunchbooleanatnumber- When it opened (epoch ms)
deviceClass"phone" | "tablet"- What the app runs on (iPad = tablet), stored on the tap this open records. iPadOS Safari sends a Mac user agent, so browser taps from an iPad count as desktop.
appVersionstring- The app's own version (iOS CFBundleShortVersionString, Android versionName), kept on the open. 1-64 printable ASCII characters; anything else is ignored, never an error.
sdkVersionstring- The Strait SDK version, kept on the open. Same rule as appVersion.
Response
- 202 Recorded (
duplicate: truewhen this openId was already recorded) - 400 Invalid fields
- 401 Missing or invalid key
- 429 Rate limited: per IP (60 burst, 1 a second) or per workspace (600 burst, 10 a second; Retry-After). The SDKs keep the report and retry it, de-duplicated by openId
curl -X POST https://strait.link/v1/open \
-H "Content-Type: application/json" \
-d '{
"publishableKey": "st_pub_live_…",
"openId": "o_lx3k2a_9f8e7d6c5b4a",
"kind": "direct",
"route": "custom_scheme",
"appState": "background",
"platform": "android",
"url": "hilltop://sale/summer",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"linkId": "lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63",
"matched": true,
"at": 1790000000000
}'const res = await fetch('https://strait.link/v1/open', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"publishableKey": "st_pub_live_…",
"openId": "o_lx3k2a_9f8e7d6c5b4a",
"kind": "direct",
"route": "custom_scheme",
"appState": "background",
"platform": "android",
"url": "hilltop://sale/summer",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"linkId": "lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63",
"matched": true,
"at": 1790000000000
}),
});
const data = await res.json();
console.log(res.status, data);import requests
res = requests.post(
"https://strait.link/v1/open",
json={
"publishableKey": "st_pub_live_…",
"openId": "o_lx3k2a_9f8e7d6c5b4a",
"kind": "direct",
"route": "custom_scheme",
"appState": "background",
"platform": "android",
"url": "hilltop://sale/summer",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"linkId": "lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63",
"matched": True,
"at": 1790000000000,
},
)
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/open');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'publishableKey' => 'st_pub_live_…',
'openId' => 'o_lx3k2a_9f8e7d6c5b4a',
'kind' => 'direct',
'route' => 'custom_scheme',
'appState' => 'background',
'platform' => 'android',
'url' => 'hilltop://sale/summer',
'clickId' => '9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34',
'linkId' => 'lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63',
'matched' => true,
'at' => 1790000000000,
], 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_…",
"openId": "o_lx3k2a_9f8e7d6c5b4a",
"kind": "direct",
"route": "custom_scheme",
"appState": "background",
"platform": "android",
"url": "hilltop://sale/summer",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"linkId": "lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63",
"matched": true,
"at": 1790000000000
}
""";
HttpRequest request = HttpRequest.newBuilder(URI.create("https://strait.link/v1/open"))
.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_…",
"openId": "o_lx3k2a_9f8e7d6c5b4a",
"kind": "direct",
"route": "custom_scheme",
"appState": "background",
"platform": "android",
"url": "hilltop://sale/summer",
"clickId": "9a1c7e52-4b3d-4f8e-a6d1-0c2b5e7f9a34",
"linkId": "lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63",
"matched": true,
"at": 1790000000000
}`)
req, err := http.NewRequest(http.MethodPost, "https://strait.link/v1/open", 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,
"duplicate": false
}