建立訂閱
curl --request POST \
--url https://api.zangsho.com/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": 123,
"plan_name": "Pro Plan",
"mrr": "990.00",
"billing_cycle": "monthly",
"started_at": "2026-01-01T00:00:00Z",
"current_period_start": "2026-01-01T00:00:00Z"
}
'import requests
url = "https://api.zangsho.com/v1/subscriptions"
payload = {
"customer_id": 123,
"plan_name": "Pro Plan",
"mrr": "990.00",
"billing_cycle": "monthly",
"started_at": "2026-01-01T00:00:00Z",
"current_period_start": "2026-01-01T00:00:00Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: 123,
plan_name: 'Pro Plan',
mrr: '990.00',
billing_cycle: 'monthly',
started_at: '2026-01-01T00:00:00Z',
current_period_start: '2026-01-01T00:00:00Z'
})
};
fetch('https://api.zangsho.com/v1/subscriptions', 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.zangsho.com/v1/subscriptions",
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([
'customer_id' => 123,
'plan_name' => 'Pro Plan',
'mrr' => '990.00',
'billing_cycle' => 'monthly',
'started_at' => '2026-01-01T00:00:00Z',
'current_period_start' => '2026-01-01T00:00:00Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.zangsho.com/v1/subscriptions"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"plan_name\": \"Pro Plan\",\n \"mrr\": \"990.00\",\n \"billing_cycle\": \"monthly\",\n \"started_at\": \"2026-01-01T00:00:00Z\",\n \"current_period_start\": \"2026-01-01T00:00:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.zangsho.com/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"plan_name\": \"Pro Plan\",\n \"mrr\": \"990.00\",\n \"billing_cycle\": \"monthly\",\n \"started_at\": \"2026-01-01T00:00:00Z\",\n \"current_period_start\": \"2026-01-01T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zangsho.com/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 123,\n \"plan_name\": \"Pro Plan\",\n \"mrr\": \"990.00\",\n \"billing_cycle\": \"monthly\",\n \"started_at\": \"2026-01-01T00:00:00Z\",\n \"current_period_start\": \"2026-01-01T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"customer_id": 123,
"plan_name": "<string>",
"mrr": "<string>",
"billing_cycle": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"current_period_start": "2023-11-07T05:31:56Z",
"cancelled_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required.",
"The email must be a valid email address."
]
}
}訂閱 Subscriptions
建立訂閱
為客戶建立新訂閱。每位客戶同時只能有一個有效訂閱。
POST
/
subscriptions
建立訂閱
curl --request POST \
--url https://api.zangsho.com/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": 123,
"plan_name": "Pro Plan",
"mrr": "990.00",
"billing_cycle": "monthly",
"started_at": "2026-01-01T00:00:00Z",
"current_period_start": "2026-01-01T00:00:00Z"
}
'import requests
url = "https://api.zangsho.com/v1/subscriptions"
payload = {
"customer_id": 123,
"plan_name": "Pro Plan",
"mrr": "990.00",
"billing_cycle": "monthly",
"started_at": "2026-01-01T00:00:00Z",
"current_period_start": "2026-01-01T00:00:00Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: 123,
plan_name: 'Pro Plan',
mrr: '990.00',
billing_cycle: 'monthly',
started_at: '2026-01-01T00:00:00Z',
current_period_start: '2026-01-01T00:00:00Z'
})
};
fetch('https://api.zangsho.com/v1/subscriptions', 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.zangsho.com/v1/subscriptions",
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([
'customer_id' => 123,
'plan_name' => 'Pro Plan',
'mrr' => '990.00',
'billing_cycle' => 'monthly',
'started_at' => '2026-01-01T00:00:00Z',
'current_period_start' => '2026-01-01T00:00:00Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.zangsho.com/v1/subscriptions"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"plan_name\": \"Pro Plan\",\n \"mrr\": \"990.00\",\n \"billing_cycle\": \"monthly\",\n \"started_at\": \"2026-01-01T00:00:00Z\",\n \"current_period_start\": \"2026-01-01T00:00:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.zangsho.com/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"plan_name\": \"Pro Plan\",\n \"mrr\": \"990.00\",\n \"billing_cycle\": \"monthly\",\n \"started_at\": \"2026-01-01T00:00:00Z\",\n \"current_period_start\": \"2026-01-01T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zangsho.com/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 123,\n \"plan_name\": \"Pro Plan\",\n \"mrr\": \"990.00\",\n \"billing_cycle\": \"monthly\",\n \"started_at\": \"2026-01-01T00:00:00Z\",\n \"current_period_start\": \"2026-01-01T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"customer_id": 123,
"plan_name": "<string>",
"mrr": "<string>",
"billing_cycle": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"current_period_start": "2023-11-07T05:31:56Z",
"cancelled_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required.",
"The email must be a valid email address."
]
}
}Authorizations
使用 Laravel Sanctum Token 進行認證。
Token 可在商家後台的「API 設定」頁面取得。
Body
application/json
客戶 ID
月經常性收入
Example:
"990.00"
訂閱週期
Available options:
monthly, quarterly, semi-annual, yearly 訂閱開始時間
目前週期開始時間
方案名稱
Example:
"Pro Plan"
Response
訂閱建立成功
Show child attributes
Show child attributes
⌘I