跳转到主要内容
POST
/
v2
/
apps
/
{app_id}
/
network
/
custom
设置自定义域名
curl --request POST \
  --url https://api.squarecloud.app/v2/apps/{app_id}/network/custom \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "custom": "<string>"
}
'
import requests

url = "https://api.squarecloud.app/v2/apps/{app_id}/network/custom"

payload = { "custom": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({custom: '<string>'})
};

fetch('https://api.squarecloud.app/v2/apps/{app_id}/network/custom', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/network/custom",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'custom' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.squarecloud.app/v2/apps/{app_id}/network/custom"

payload := strings.NewReader("{\n \"custom\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/network/custom")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"custom\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.squarecloud.app/v2/apps/{app_id}/network/custom")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"custom\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
    "status": "success"
}
使用此路由至少需要 Standard 套餐 同一账户可以将一个域名绑定到多个应用(负载均衡):Standard 最多 2 个应用,Pro 最多 5 个,Enterprise 最多 10 个。参见 列出负载均衡器
Authorization
string
必填
你账户的 API 密钥。你可以在账户设置中找到它。

参数

app_id
string
必填
应用的 ID。你可以在应用仪表盘的 URL 中找到它。
custom
string
必填
要绑定的完全限定域名,或使用 @ 移除应用当前的自定义域名。它不能是 Square Cloud 域名(squareweb.appsquarecloud.app……)。

响应

status
string
指示调用是否成功。成功时为 success,否则为 error
失败时,响应会包含一个错误 code
StatusCode含义
400REGEX_VALIDATION该域名不是有效的完全限定域名。
400RESERVED_DOMAINSquare Cloud 域名不能用作自定义域名。
403UPGRADE_REQUIRED当前套餐不包含自定义域名(需要 Standard、Pro 或 Enterprise)。
403LOAD_BALANCER_LIMIT_REACHED已达到该套餐在此域名上的应用数量上限。
409DOMAIN_ALREADY_EXISTS该域名已绑定到另一账户拥有的应用。
502DNS_FAILED域名绑定在边缘提供商处失败。
{
    "status": "success"
}