Who this key is
method
GET
host
strait.
version
/v1
resource
/
GET /v1/workspace
Auth: secret key as Authorization: Bearer. Server-side only.
Request
The workspace this secret key belongs to: its name, the link domain every shortUrl uses (linkBase, its custom domain when one is verified, else <handle>.strait.link), verified custom domains, the plan, and the key's own access (full, links or read) and prefix. Any secret key; 30 calls a minute per workspace.
No parameters.
Response
- 200 The workspace and the key
- 401 Missing or invalid secret key, or a publishable key
- 429 Over 30 calls a minute for this workspace
curl -X GET https://strait.link/v1/workspace \
-H "Authorization: Bearer $SECRET_KEY"const res = await fetch('https://strait.link/v1/workspace', {
headers: { Authorization: `Bearer ${process.env.SECRET_KEY}` },
});
const data = await res.json();
console.log(res.status, data);import os
import requests
res = requests.get(
"https://strait.link/v1/workspace",
headers={"Authorization": f"Bearer {os.environ['SECRET_KEY']}"},
)
print(res.status_code, res.json())<?php
// Plain PHP with ext-curl, no packages. In Laravel, Http::withToken($secretKey)->get($url) sends the same request.
$ch = curl_init('https://strait.link/v1/workspace');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SECRET_KEY'),
],
]);
$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 {
HttpRequest request = HttpRequest.newBuilder(URI.create("https://strait.link/v1/workspace"))
.header("Authorization", "Bearer " + System.getenv("SECRET_KEY"))
.GET()
.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"
)
func main() {
req, err := http.NewRequest(http.MethodGet, "https://strait.link/v1/workspace", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("SECRET_KEY"))
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
{
"name": "Hilltop Shoes",
"handle": "hilltop",
"linkBase": "https://hilltop.strait.link",
"linkDomain": "hilltop.strait.link",
"customDomains": [],
"plan": "starter",
"key": {
"scope": "read",
"prefix": "st_live_ab12"
}
}