curl --request POST \
--url https://api.rigaly.com/api/v1/code-batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Summer 2027 bottles",
"points": 250,
"quantity": 30000,
"expires_at": "2027-12-31T23:59:59Z",
"prefix": "SUMMER"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Summer 2027 bottles',
points: 250,
quantity: 30000,
expires_at: '2027-12-31T23:59:59Z',
prefix: 'SUMMER'
})
};
fetch('https://api.rigaly.com/api/v1/code-batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.rigaly.com/api/v1/code-batches"
payload = {
"name": "Summer 2027 bottles",
"points": 250,
"quantity": 30000,
"expires_at": "2027-12-31T23:59:59Z",
"prefix": "SUMMER"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.rigaly.com/api/v1/code-batches",
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([
'name' => 'Summer 2027 bottles',
'points' => 250,
'quantity' => 30000,
'expires_at' => '2027-12-31T23:59:59Z',
'prefix' => 'SUMMER'
]),
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;
}{
"success": true,
"message": "<string>",
"data": {
"batch": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"business_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"batch_ref": "595Y",
"name": "Summer 2027 bottles",
"prefix": "SUMMER",
"points": 250,
"quantity": 30000,
"expires_at": "2023-11-07T05:31:56Z",
"active": true,
"created_via": "api",
"created_at": "2023-11-07T05:31:56Z",
"failed_attempts": 0
},
"example_code": "SUMMER-595Y-000-JT5-A5Q",
"example_deep_link": "HTTPS://LINK.RIGALY.COM/CODE/595Y000JT5A5Q"
}
}{
"success": false,
"error": {
"message": "Provide exactly one of \"user_id\" or \"identifier\""
}
}Create a code batch
Creates a batch of up to 32,768 unique single-use codes per batch (create multiple batches for larger runs) to print on physical products. Creation is instant — codes are derived from a per-batch cryptographic secret, not stored — and you are only charged the per-transaction fee when a code is actually redeemed by a customer in the Rigaly app.
Download the codes with the export endpoint. example_code shows the
exact print format ([PREFIX-]XXXX-XXX-XXX-XXX), and
example_deep_link the recommended QR payload — print each code’s
deep_link as a QR code so scanning it opens the Rigaly app with the
code ready to claim (or an install page when the app is missing).
curl --request POST \
--url https://api.rigaly.com/api/v1/code-batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Summer 2027 bottles",
"points": 250,
"quantity": 30000,
"expires_at": "2027-12-31T23:59:59Z",
"prefix": "SUMMER"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Summer 2027 bottles',
points: 250,
quantity: 30000,
expires_at: '2027-12-31T23:59:59Z',
prefix: 'SUMMER'
})
};
fetch('https://api.rigaly.com/api/v1/code-batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.rigaly.com/api/v1/code-batches"
payload = {
"name": "Summer 2027 bottles",
"points": 250,
"quantity": 30000,
"expires_at": "2027-12-31T23:59:59Z",
"prefix": "SUMMER"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.rigaly.com/api/v1/code-batches",
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([
'name' => 'Summer 2027 bottles',
'points' => 250,
'quantity' => 30000,
'expires_at' => '2027-12-31T23:59:59Z',
'prefix' => 'SUMMER'
]),
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;
}{
"success": true,
"message": "<string>",
"data": {
"batch": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"business_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"batch_ref": "595Y",
"name": "Summer 2027 bottles",
"prefix": "SUMMER",
"points": 250,
"quantity": 30000,
"expires_at": "2023-11-07T05:31:56Z",
"active": true,
"created_via": "api",
"created_at": "2023-11-07T05:31:56Z",
"failed_attempts": 0
},
"example_code": "SUMMER-595Y-000-JT5-A5Q",
"example_deep_link": "HTTPS://LINK.RIGALY.COM/CODE/595Y000JT5A5Q"
}
}{
"success": false,
"error": {
"message": "Provide exactly one of \"user_id\" or \"identifier\""
}
}Authorizations
API key from the Rigaly dashboard: Authorization: Bearer rgly_sk_...
Body
100"Summer 2027 bottles"
Points each code awards when claimed
x >= 1250
1 <= x <= 3276830000
"2027-12-31T23:59:59Z"
Cosmetic print prefix
^[A-Z0-9]{1,10}$"SUMMER"