Remove a custom domain
method
DELETE
host
strait.
version
/v1
resource
/
DELETE /v1/domains/{hostname}
Auth: secret key as Authorization: Bearer. Server-side only.
Coming soon: custom domains aren't switched on yet. Until they are, this endpoint answers enabled: false (the list) or 503 domains_not_enabled.
Request
Deletes the hostname at Cloudflare, then the domain; links stop working on it. Then delete the CNAME and TXT records at your DNS provider. Owners, admins and members. Shares the add limit (10, then 1 every 6 minutes).
Parameters
hostnamerequired string path- The domain to remove
tenantIdstring query- Required with a dashboard session
Response
- 204 Removed
- 401 Missing or invalid secret key or session
- 403 Viewers cannot remove domains
- 404 No such domain in this workspace
- 429 Too many domain changes (Retry-After: 360)
- 502 Cloudflare didn't answer; the domain is still listed
- 503 domains_read_only: removing is switched off right now
curl -X DELETE https://strait.link/v1/domains/hostname \
-H "Authorization: Bearer $SECRET_KEY"const res = await fetch('https://strait.link/v1/domains/hostname', {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.SECRET_KEY}` },
});
console.log(res.status); // no bodyimport os
import requests
res = requests.delete(
"https://strait.link/v1/domains/hostname",
headers={"Authorization": f"Bearer {os.environ['SECRET_KEY']}"},
)
print(res.status_code) # no body<?php
// Plain PHP with ext-curl, no packages. In Laravel, Http::withToken($secretKey)->delete($url) sends the same request.
$ch = curl_init('https://strait.link/v1/domains/hostname');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
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; // no bodyimport 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/domains/hostname"))
.header("Authorization", "Bearer " + System.getenv("SECRET_KEY"))
.DELETE()
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode()); // no body
}
}package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest(http.MethodDelete, "https://strait.link/v1/domains/hostname", 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()
fmt.Println(res.StatusCode) // no body
}The response, printed
HTTP/1.1 204 No Content