Verify Code
POST /v1/campaigns/codes/verifyValidates a campaign code without redeeming it. Returns the code’s status, associated campaign, point value, and whether it can be redeemed. This is useful for pre-validating codes in your UI before committing to redemption.
Authentication
Section titled “Authentication”| Header | Required | Value |
|---|---|---|
X-API-Secret | Yes | Your secret key |
Content-Type | Yes | application/json |
Request Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | The code to verify (e.g., SUMM-AX7K9M2P) |
Request Examples
Section titled “Request Examples”curl -X POST https://api.gamifyhost.com/v1/campaigns/codes/verify \ -H "X-API-Secret: sk_live_your_secret_key" \ -H "Content-Type: application/json" \ -d '{ "code": "SUMM-AX7K9M2P" }'const response = await fetch( 'https://api.gamifyhost.com/v1/campaigns/codes/verify', { method: 'POST', headers: { 'X-API-Secret': 'sk_live_your_secret_key', 'Content-Type': 'application/json', }, body: JSON.stringify({ code: 'SUMM-AX7K9M2P' }), });
const data = await response.json();if (data.data.valid) { console.log(`Code is valid! Worth ${data.data.pointsValue} points.`);} else { console.log(`Invalid: ${data.data.message}`);}import requests
response = requests.post( "https://api.gamifyhost.com/v1/campaigns/codes/verify", headers={ "X-API-Secret": "sk_live_your_secret_key", "Content-Type": "application/json", }, json={"code": "SUMM-AX7K9M2P"},)
data = response.json()if data["data"]["valid"]: print(f"Valid! Worth {data['data']['pointsValue']} points.")else: print(f"Invalid: {data['data']['message']}")import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.net.URI;
String body = """ { "code": "SUMM-AX7K9M2P" } """;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.gamifyhost.com/v1/campaigns/codes/verify")) .header("X-API-Secret", "sk_live_your_secret_key") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(body)) .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());payload := strings.NewReader(`{ "code": "SUMM-AX7K9M2P" }`)
req, _ := http.NewRequest("POST", "https://api.gamifyhost.com/v1/campaigns/codes/verify", payload)req.Header.Set("X-API-Secret", "sk_live_your_secret_key")req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)if err != nil { log.Fatal(err)}defer resp.Body.Close()
var result map[string]interface{}json.NewDecoder(resp.Body).Decode(&result)fmt.Println(result["data"])$ch = curl_init('https://api.gamifyhost.com/v1/campaigns/codes/verify');curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'X-API-Secret: sk_live_your_secret_key', 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode(['code' => 'SUMM-AX7K9M2P']),]);
$response = curl_exec($ch);curl_close($ch);
$data = json_decode($response, true);if ($data['data']['valid']) { echo "Valid! Worth {$data['data']['pointsValue']} points.\n";} else { echo "Invalid: {$data['data']['message']}\n";}require 'net/http'require 'json'
uri = URI('https://api.gamifyhost.com/v1/campaigns/codes/verify')req = Net::HTTP::Post.new(uri)req['X-API-Secret'] = 'sk_live_your_secret_key'req['Content-Type'] = 'application/json'req.body = { code: 'SUMM-AX7K9M2P' }.to_json
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }data = JSON.parse(res.body)puts data['data']['valid'] ? "Valid!" : "Invalid: #{data['data']['message']}"using var client = new HttpClient();client.DefaultRequestHeaders.Add("X-API-Secret", "sk_live_your_secret_key");
var content = new StringContent( JsonSerializer.Serialize(new { code = "SUMM-AX7K9M2P" }), Encoding.UTF8, "application/json");
var response = await client.PostAsync( "https://api.gamifyhost.com/v1/campaigns/codes/verify", content);var json = await response.Content.ReadAsStringAsync();Console.WriteLine(json);import 'dart:convert';import 'package:http/http.dart' as http;
final response = await http.post( Uri.parse('https://api.gamifyhost.com/v1/campaigns/codes/verify'), headers: { 'X-API-Secret': 'sk_live_your_secret_key', 'Content-Type': 'application/json', }, body: jsonEncode({'code': 'SUMM-AX7K9M2P'}),);
final data = jsonDecode(response.body);if (data['data']['valid']) { print('Valid! Worth ${data['data']['pointsValue']} points.');} else { print('Invalid: ${data['data']['message']}');}Response — Valid Code
Section titled “Response — Valid Code”Status: 200 OK
{ "status": "success", "data": { "valid": true, "status": "ACTIVE", "pointsValue": 500, "campaignName": "Summer Promo 2025", "campaignSlug": "summer-promo", "expired": false, "message": "Code is valid and redeemable" }}Response — Invalid Code
Section titled “Response — Invalid Code”{ "status": "success", "data": { "valid": false, "status": "REDEEMED", "pointsValue": 500, "campaignName": "Summer Promo 2025", "campaignSlug": "summer-promo", "expired": false, "message": "Code status is REDEEMED" }}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
valid | boolean | Whether the code can be redeemed right now |
status | string | Code status: ACTIVE, REDEEMED, EXPIRED, or REVOKED |
pointsValue | integer | Points the code is worth (0 if not found) |
campaignName | string | Campaign name (empty if not found) |
campaignSlug | string | Campaign slug (empty if not found) |
expired | boolean | Whether the campaign has ended |
message | string | Human-readable explanation |
Possible Messages
Section titled “Possible Messages”| Message | Meaning |
|---|---|
Code is valid and redeemable | Ready to redeem |
Code not found | Code doesn’t exist or belongs to another partner |
Code status is REDEEMED | Already redeemed |
Code status is EXPIRED | Code has expired |
Code status is REVOKED | Code was revoked by partner |
Campaign is not active | Campaign is paused or ended |
Campaign has ended | Campaign end date has passed |