Create up to 500 links in one call
method
POST
host
strait.
version
/v1
resource
/
POST /v1/links/batch
Auth: secret key as Authorization: Bearer. Server-side only.
Request
For imports and migrations. Each item passes the same checks as POST /v1/links (slug rules, https destinations, the unsafe-destination check, plan limits) and gets its own result; a bad item never fails the batch. A slug already used in the workspace (or earlier in the same batch) is a per-item 409, so re-running an import is safe. The response is 200 whenever the request itself is valid: read results[i].ok. Items past a plan limit get 402.
Parameters
Idempotency-Keystring header- Optional (ADR 0055). Retry with the same key and the same body to get the first answer back (header
Idempotent-Replayed: true) instead of running again. 1 to 255 of[A-Za-z0-9_.:-], kept 24 hours per workspace and endpoint. 5xx, 429 and 402 answers are not kept.
Body (JSON)
linksrequired object[]
Response
- 200 One result per item, in order, plus totals
- 400
linksis missing, empty, or has more than 500 items - 401 Missing or invalid secret key
curl -X POST https://strait.link/v1/links/batch \
-H "Authorization: Bearer $SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"links": [
{
"slug": "summer",
"longUrl": "https://shop.example.com/sale/summer?utm_source=whatsapp&utm_campaign=summer-2026"
},
{
"slug": "winter",
"longUrl": "https://shop.example.com/sale/winter"
}
]
}'const res = await fetch('https://strait.link/v1/links/batch', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.SECRET_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"links": [
{
"slug": "summer",
"longUrl": "https://shop.example.com/sale/summer?utm_source=whatsapp&utm_campaign=summer-2026"
},
{
"slug": "winter",
"longUrl": "https://shop.example.com/sale/winter"
}
]
}),
});
const data = await res.json();
console.log(res.status, data);import os
import requests
res = requests.post(
"https://strait.link/v1/links/batch",
headers={"Authorization": f"Bearer {os.environ['SECRET_KEY']}"},
json={
"links": [
{
"slug": "summer",
"longUrl": "https://shop.example.com/sale/summer?utm_source=whatsapp&utm_campaign=summer-2026",
},
{
"slug": "winter",
"longUrl": "https://shop.example.com/sale/winter",
},
],
},
)
print(res.status_code, res.json())<?php
// Plain PHP with ext-curl, no packages. In Laravel, Http::withToken($secretKey)->post($url, $body) sends the same request.
$ch = curl_init('https://strait.link/v1/links/batch');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SECRET_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'links' => [
[
'slug' => 'summer',
'longUrl' => 'https://shop.example.com/sale/summer?utm_source=whatsapp&utm_campaign=summer-2026',
],
[
'slug' => 'winter',
'longUrl' => 'https://shop.example.com/sale/winter',
],
],
], 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 = """
{
"links": [
{
"slug": "summer",
"longUrl": "https://shop.example.com/sale/summer?utm_source=whatsapp&utm_campaign=summer-2026"
},
{
"slug": "winter",
"longUrl": "https://shop.example.com/sale/winter"
}
]
}
""";
HttpRequest request = HttpRequest.newBuilder(URI.create("https://strait.link/v1/links/batch"))
.header("Authorization", "Bearer " + System.getenv("SECRET_KEY"))
.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"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"links": [
{
"slug": "summer",
"longUrl": "https://shop.example.com/sale/summer?utm_source=whatsapp&utm_campaign=summer-2026"
},
{
"slug": "winter",
"longUrl": "https://shop.example.com/sale/winter"
}
]
}`)
req, err := http.NewRequest(http.MethodPost, "https://strait.link/v1/links/batch", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("SECRET_KEY"))
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
{
"results": [
{
"index": 0,
"ok": true,
"status": 201,
"link": {
"id": "lnk_5f0c2a8e-3b1d-4f6a-9c7e-2d8b1a0e4f63",
"tenantId": "0b8f6d2e-7a41-4c39-9e15-3f2a6c8d1b70",
"slug": "summer",
"shortUrl": "https://hilltop.strait.link/summer",
"longUrl": "https://shop.example.com/sale/summer?utm_source=whatsapp&utm_campaign=summer-2026",
"isActive": true,
"title": "Summer sale",
"campaign": "summer-2026",
"tags": [
"sale"
]
}
},
{
"index": 1,
"ok": false,
"status": 409,
"error": "slug already exists in this workspace"
}
],
"summary": {
"total": 2,
"created": 1,
"failed": 1
}
}