兌換碼
兌換碼是玩家輸入後可換取獎勵的字串。每個兌換碼歸屬於一個 redemption_code_group,並可關聯多個獎勵。
資料模型
- Name
id- Type
- integer
- Description
- 兌換碼 ID。
- Name
code- Type
- string
- Description
- 兌換碼字串(玩家輸入用)。
- Name
current_uses- Type
- integer
- Description
- 已被使用的次數。
- Name
group- Type
- object
- Description
- 所屬群組(
{ id, name })。
- Name
game- Type
- object
- Description
- 所屬遊戲(從 group 帶出,
{ id, name })。
- Name
rewards- Type
- array
- Description
- 關聯獎勵列表,元素為 reward 物件。
GET/redemption-codes
列出兌換碼
分頁列出所有兌換碼,可依群組、字串、遊戲過濾。
選填參數
- Name
group_id- Type
- integer
- Description
- 過濾特定兌換碼群組。
- Name
code- Type
- string
- Description
- 依字串過濾(精確)。
- Name
game_id- Type
- integer
- Description
- 過濾特定遊戲。
- Name
per_page- Type
- integer
- Description
- 每頁筆數。
Request
GET
/redemption-codescurl -G https://api.poshentw.com/redemption-codes \
-H "Authorization: Bearer {token}" \
-d group_id=5
Response
{
"data": [
{
"id": 99,
"code": "WELCOME2026",
"current_uses": 12,
"group": { "id": 5, "name": "新春活動" },
"game": { "id": 1, "name": "咖波疊疊樂" },
"rewards": [
{ "id": 1, "code": "GOLD_100", "name": "金幣 100", "type": "金幣" }
]
}
],
"meta": { "current_page": 1, "total": 1 }
}
POST/redemption-codes
建立單一兌換碼
建立一個兌換碼並可一併綁定獎勵。
想要批次建立多個兌換碼,請改用 兌換碼群組 的
POST /redemption-code-groups,可指定quantity一次建立 N 個。
必填欄位
- Name
code- Type
- string
- Description
- 兌換碼字串,需在所有兌換碼中唯一。
- Name
redemption_code_group_id- Type
- integer
- Description
- 所屬群組 ID。
選填欄位
- Name
rewards- Type
- array
- Description
- 獎勵綁定,每個元素為
{ "reward_id": integer }。
Request
POST
/redemption-codescurl https://api.poshentw.com/redemption-codes \
-X POST \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"code": "WELCOME2026",
"redemption_code_group_id": 5,
"rewards": [{ "reward_id": 1 }]
}'
GET/redemption-codes/{id}
取得單一兌換碼
依 ID 取得詳細資料,含群組、遊戲、獎勵。
Request
GET
/redemption-codes/99curl https://api.poshentw.com/redemption-codes/99 \
-H "Authorization: Bearer {token}"
PUT/redemption-codes/{id}
更新兌換碼
僅支援移動到另一個群組。回 204 No Content,無 response body。
可更新欄位
- Name
redemption_code_group_id- Type
- integer
- Description
- 改綁的群組 ID。
Request
PUT
/redemption-codes/99curl https://api.poshentw.com/redemption-codes/99 \
-X PUT \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{ "redemption_code_group_id": 6 }'
DELETE/redemption-codes/{id}
刪除兌換碼
回 204 No Content。
Request
DELETE
/redemption-codes/99curl https://api.poshentw.com/redemption-codes/99 \
-X DELETE \
-H "Authorization: Bearer {token}"