建立訂閱事件
curl --request POST \
--url https://api.zangsho.com/v1/subscriptions/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_email": "customer@example.com",
"event_type": "upgrade",
"old_amount": "500.00",
"new_amount": "990.00",
"amount_change": "490.00",
"old_plan": "Basic",
"new_plan": "Pro",
"occurred_at": "2026-01-09T00:00:00Z"
}
'import requests
url = "https://api.zangsho.com/v1/subscriptions/events"
payload = {
"customer_email": "customer@example.com",
"event_type": "upgrade",
"old_amount": "500.00",
"new_amount": "990.00",
"amount_change": "490.00",
"old_plan": "Basic",
"new_plan": "Pro",
"occurred_at": "2026-01-09T00: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_email: 'customer@example.com',
event_type: 'upgrade',
old_amount: '500.00',
new_amount: '990.00',
amount_change: '490.00',
old_plan: 'Basic',
new_plan: 'Pro',
occurred_at: '2026-01-09T00:00:00Z'
})
};
fetch('https://api.zangsho.com/v1/subscriptions/events', 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/events",
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_email' => 'customer@example.com',
'event_type' => 'upgrade',
'old_amount' => '500.00',
'new_amount' => '990.00',
'amount_change' => '490.00',
'old_plan' => 'Basic',
'new_plan' => 'Pro',
'occurred_at' => '2026-01-09T00: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/events"
payload := strings.NewReader("{\n \"customer_email\": \"customer@example.com\",\n \"event_type\": \"upgrade\",\n \"old_amount\": \"500.00\",\n \"new_amount\": \"990.00\",\n \"amount_change\": \"490.00\",\n \"old_plan\": \"Basic\",\n \"new_plan\": \"Pro\",\n \"occurred_at\": \"2026-01-09T00: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/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_email\": \"customer@example.com\",\n \"event_type\": \"upgrade\",\n \"old_amount\": \"500.00\",\n \"new_amount\": \"990.00\",\n \"amount_change\": \"490.00\",\n \"old_plan\": \"Basic\",\n \"new_plan\": \"Pro\",\n \"occurred_at\": \"2026-01-09T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zangsho.com/v1/subscriptions/events")
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_email\": \"customer@example.com\",\n \"event_type\": \"upgrade\",\n \"old_amount\": \"500.00\",\n \"new_amount\": \"990.00\",\n \"amount_change\": \"490.00\",\n \"old_plan\": \"Basic\",\n \"new_plan\": \"Pro\",\n \"occurred_at\": \"2026-01-09T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"customer_id": 123,
"old_amount": "<string>",
"new_amount": "<string>",
"amount_change": "<string>",
"old_plan": "<string>",
"new_plan": "<string>",
"occurred_at": "2023-11-07T05:31:56Z",
"created_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."
]
}
}訂閱事件 Subscription Events
建立訂閱事件
手動記錄訂閱事件(升級、降級、取消等)。
POST
/
subscriptions
/
events
建立訂閱事件
curl --request POST \
--url https://api.zangsho.com/v1/subscriptions/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_email": "customer@example.com",
"event_type": "upgrade",
"old_amount": "500.00",
"new_amount": "990.00",
"amount_change": "490.00",
"old_plan": "Basic",
"new_plan": "Pro",
"occurred_at": "2026-01-09T00:00:00Z"
}
'import requests
url = "https://api.zangsho.com/v1/subscriptions/events"
payload = {
"customer_email": "customer@example.com",
"event_type": "upgrade",
"old_amount": "500.00",
"new_amount": "990.00",
"amount_change": "490.00",
"old_plan": "Basic",
"new_plan": "Pro",
"occurred_at": "2026-01-09T00: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_email: 'customer@example.com',
event_type: 'upgrade',
old_amount: '500.00',
new_amount: '990.00',
amount_change: '490.00',
old_plan: 'Basic',
new_plan: 'Pro',
occurred_at: '2026-01-09T00:00:00Z'
})
};
fetch('https://api.zangsho.com/v1/subscriptions/events', 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/events",
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_email' => 'customer@example.com',
'event_type' => 'upgrade',
'old_amount' => '500.00',
'new_amount' => '990.00',
'amount_change' => '490.00',
'old_plan' => 'Basic',
'new_plan' => 'Pro',
'occurred_at' => '2026-01-09T00: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/events"
payload := strings.NewReader("{\n \"customer_email\": \"customer@example.com\",\n \"event_type\": \"upgrade\",\n \"old_amount\": \"500.00\",\n \"new_amount\": \"990.00\",\n \"amount_change\": \"490.00\",\n \"old_plan\": \"Basic\",\n \"new_plan\": \"Pro\",\n \"occurred_at\": \"2026-01-09T00: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/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_email\": \"customer@example.com\",\n \"event_type\": \"upgrade\",\n \"old_amount\": \"500.00\",\n \"new_amount\": \"990.00\",\n \"amount_change\": \"490.00\",\n \"old_plan\": \"Basic\",\n \"new_plan\": \"Pro\",\n \"occurred_at\": \"2026-01-09T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zangsho.com/v1/subscriptions/events")
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_email\": \"customer@example.com\",\n \"event_type\": \"upgrade\",\n \"old_amount\": \"500.00\",\n \"new_amount\": \"990.00\",\n \"amount_change\": \"490.00\",\n \"old_plan\": \"Basic\",\n \"new_plan\": \"Pro\",\n \"occurred_at\": \"2026-01-09T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"customer_id": 123,
"old_amount": "<string>",
"new_amount": "<string>",
"amount_change": "<string>",
"old_plan": "<string>",
"new_plan": "<string>",
"occurred_at": "2023-11-07T05:31:56Z",
"created_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
客戶 Email
事件類型
Available options:
created, upgrade, downgrade, cancel, reactivated MRR 變化金額
Example:
"490.00"
事件發生時間
變更前金額
變更後金額
變更前方案
變更後方案
Response
事件建立成功
Show child attributes
Show child attributes
⌘I