Send Rewards from Server
curl --request POST \
--url https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"rewardsUserId": "<string>",
"amount": 123
}
'import requests
url = "https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward"
payload = {
"rewardsUserId": "<string>",
"amount": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({rewardsUserId: '<string>', amount: 123})
};
fetch('https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward', 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.zbdpay.com/api/v2/rewards/limited-achievement/reward",
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([
'rewardsUserId' => '<string>',
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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.zbdpay.com/api/v2/rewards/limited-achievement/reward"
payload := strings.NewReader("{\n \"rewardsUserId\": \"<string>\",\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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.zbdpay.com/api/v2/rewards/limited-achievement/reward")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"rewardsUserId\": \"<string>\",\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rewardsUserId\": \"<string>\",\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Success.",
"data": [
{
"transactionId": "f7553b31-5ae2-43bf-a200-c0a966e94071"
}
]
}
Send Rewards (Server)
Send Rewards from Server
Use your API key to send rewards securely from your backend using the Earn API (v2).
POST
/
api
/
v2
/
rewards
/
limited-achievement
/
reward
Send Rewards from Server
curl --request POST \
--url https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"rewardsUserId": "<string>",
"amount": 123
}
'import requests
url = "https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward"
payload = {
"rewardsUserId": "<string>",
"amount": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({rewardsUserId: '<string>', amount: 123})
};
fetch('https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward', 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.zbdpay.com/api/v2/rewards/limited-achievement/reward",
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([
'rewardsUserId' => '<string>',
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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.zbdpay.com/api/v2/rewards/limited-achievement/reward"
payload := strings.NewReader("{\n \"rewardsUserId\": \"<string>\",\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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.zbdpay.com/api/v2/rewards/limited-achievement/reward")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"rewardsUserId\": \"<string>\",\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rewardsUserId\": \"<string>\",\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Success.",
"data": [
{
"transactionId": "f7553b31-5ae2-43bf-a200-c0a966e94071"
}
]
}
Send rewards securely from your backend using the ZBD Earn API (v2).
This method ensures all rewards are issued from a trusted environment, preventing client-side abuse and maintaining full control over reward distribution.
Reward Unit Configuration. The reward unit (e.g., 1 satoshi or $0.10) is defined for your game by your ZBD Customer Success Manager.
Configuration
Header Parameters
API key used for authentication. Obtain this from the Create an API Key step.
Body Parameters
The recipient’s ZBD Rewards User ID
Reward amount in configured unitsExample:
10 (units defined by your ZBD Customer Success Manager){
"success": true,
"message": "Success.",
"data": [
{
"transactionId": "f7553b31-5ae2-43bf-a200-c0a966e94071"
}
]
}
Response Status Codes
| Code | Description |
|---|---|
201 | Reward sent successfully |
400 | Bad request – invalid parameters |
401 | Unauthorized – invalid or missing API key |
404 | Rewards user not found |
500 | Internal server error |
{
"success": false,
"message": "Invalid parameters"
}
{
"success": false,
"message": "Invalid or missing API key"
}
{
"success": false,
"message": "Rewards user not found"
}
{
"success": false,
"message": "Internal server error"
}
Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the request was successful |
message | string | Response message |
data | array | Array containing transaction details |
transactionId | string | Unique transaction identifier |
Security Reminder, Never expose your API key in client-side code. Always send rewards from your backend server where your API key is securely stored.
Code Examples
const apiKey = process.env.REWARDS_API_KEY;
async function sendReward(rewardsUserId, amount) {
const response = await fetch('https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward', {
method: 'POST',
headers: {
'x-api-key': apiKey
},
body: JSON.stringify({
rewardsUserId,
amount
})
});
const data = await response.json();
if (data.success) {
console.log(`Reward sent! Transaction ID: ${data.data[0].transactionId}`);
return data.data[0];
} else {
throw new Error(`Failed to send reward: ${data.message}`);
}
}
// Example: Send 10 reward units
await sendReward('f2154d1a-67e6-46f2-b293-b4b226948dc9', 10);
curl --location 'https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward' \
--header 'x-api-key: sdk_live_c21cfd2f98762456cac1729925be494d431c7c08127953c2434f39899c073aa6' \
--data '{
"rewardsUserId": "f2154d1a-67e6-46f2-b293-b4b226948dc9",
"amount": 10
}'
import requests
import os
api_key = os.getenv('REWARDS_API_KEY')
def send_reward(rewards_user_id, amount):
"""Send a reward to a user from your server"""
url = "https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward"
headers = {
"x-api-key": api_key
}
payload = {
"rewardsUserId": rewards_user_id,
"amount": amount
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
if data["success"]:
print(f"Reward sent! TX ID: {data['data'][0]['transactionId']}")
return data["data"][0]
else:
raise Exception(f"Failed: {data['message']}")
# Example usage
send_reward("f2154d1a-67e6-46f2-b293-b4b226948dc9", 10)
Try It Out
Ready to send your first reward from the server? Use our API playground on the right to test with your API key.Was this page helpful?
⌘I