Getting Started
- 1Create a live or test key on the Integration page of the brand panel. The secret is shown once, at creation.
- 2Send every request with the key ID, timestamp and HMAC-SHA256 signature headers.
- 3Try the key with GET /v1/partner/ping: the response returns your brand and the key's mode.
Authentication
X-Daha-KeyKey ID: starts with dk_live_ or dk_test_.X-Daha-TimestampRequest time as unix seconds.X-Daha-Signaturev1= followed by the HMAC-SHA256 of the signed string with your secret (lowercase hex).
Signed String
<timestamp>.<METHOD>.<path?query>.<raw body>1763130000.POST./v1/partner/codes/verify.{"code":"ABC"}- The timestamp may differ from server time by at most 5 minutes.
- The same signature is not accepted twice within 10 minutes.
- Every authentication failure returns 401 AUTH_FAILED; the detailed reason is in the request log in the brand panel.
Node Example
import { createHmac } from "node:crypto";
const KEY_ID = process.env.DAHA_IYI_KEY_ID; // dk_live_... | dk_test_...
const SECRET = process.env.DAHA_IYI_SECRET; // dks_...
export async function dahaIyi(method, path, body) {
const raw = body === undefined ? "" : JSON.stringify(body);
const timestamp = String(Math.floor(Date.now() / 1000));
const canonical = `${timestamp}.${method.toUpperCase()}.${path}.${raw}`;
const signature = "v1=" + createHmac("sha256", SECRET).update(canonical).digest("hex");
const res = await fetch("https://hangisidahaiyi.com" + path, {
method,
headers: {
"X-Daha-Key": KEY_ID,
"X-Daha-Timestamp": timestamp,
"X-Daha-Signature": signature,
...(raw && { "Content-Type": "application/json" }),
},
body: raw || undefined,
});
return { status: res.status, body: await res.json() };
}
await dahaIyi("GET", "/v1/partner/ping");Endpoints
Test the Key
/v1/partner/pingReturns the key's brand and mode when the signature is valid. The first step of an integration.
Response (200, data)
okbooleanValues: truemodestringValues: live, testkeyIdstringbrandobjectbrand.idstring (uuid)brand.slugstringbrand.namestring
Error Responses
- 401
AUTH_FAILED - 403
MODE_NOT_ALLOWED - 429
RATE_LIMITEDTOO_MANY_FAILURES
Verify a Code
/v1/partner/codes/verifyChecks that a code entered at checkout belongs to this brand and can be used now. Does not use the code.
Request Body
codestringrequiredThe code entered by the customer; converted to upper case.1-64 characterscampaignIdstring (uuid)Selects the campaign when the code exists in more than one.
Response (200, data)
validbooleanValues: true, falseclaimobjectclaim.idstring (uuid)claim.expiresAtstring (date-time) | nullclaim.graceUntilstring (date-time) | nullcampaignobject | nullcampaign.idstring (uuid)campaign.slugstringcampaign.titleobjectreasonstringValues: NOT_FOUND, AMBIGUOUS, CANCELLED, EXPIRED, ALREADY_REDEEMED
Error Responses
- 400
INVALID_JSON - 401
AUTH_FAILED - 403
MODE_NOT_ALLOWED - 413
BODY_TOO_LARGE - 415
JSON_REQUIRED - 429
RATE_LIMITEDTOO_MANY_FAILURESTOO_MANY_CODE_FAILURES - 503
SERVICE_UNAVAILABLE
Report a Redemption
/v1/partner/redemptionsReports that a code was used in an order. externalRef is the idempotency key within brand and mode: the same body again returns 200 with Idempotent-Replayed: true, a different body returns 409 IDEMPOTENCY_CONFLICT.
Request Body
codestringrequiredThe code entered by the customer; converted to upper case.1-64 characterscampaignIdstring (uuid)Selects the campaign when the code exists in more than one.externalRefstringrequiredYour order number; it makes retries safe. The cashier: prefix is reserved.Pattern: ^[A-Za-z0-9._:-]{1,128}$orderAmountintegerrequiredOrder amount in kuruş.Between 1 and 2147483647discountAmountintegerrequiredDiscount applied in kuruş; cannot exceed the order amount.Between 0 and 2147483647currencystringrequiredCurrency.Values: TRYredeemedAtstring (date-time)Time of use; defaults to the request time. At most 48 hours back.
Response (201, data)
idstring (uuid)modestringValues: live, testsourcestringValues: webhook, cashierexternalRefstring | nullstatusstringValues: verified, reversedorderAmountintegerdiscountAmountintegercurrencystringredeemedAtstring (date-time)reversedAtstring (date-time) | nullreasonstring | nullclaimobjectclaim.idstring (uuid)claim.codestringcampaignobject | nullcampaign.idstring (uuid)campaign.slugstringcampaign.titleobject
Error Responses
- 400
REDEEMED_AT_INVALIDDISCOUNT_TOO_HIGHMIN_BASKET_NOT_METINVALID_JSON - 401
AUTH_FAILED - 403
MODE_NOT_ALLOWED - 404
CODE_NOT_FOUND - 409
ALREADY_REDEEMEDCODE_EXPIREDCODE_CANCELLEDCAMPAIGN_NOT_STARTEDCODE_AMBIGUOUSIDEMPOTENCY_CONFLICT - 413
BODY_TOO_LARGE - 415
JSON_REQUIRED - 429
RATE_LIMITEDTOO_MANY_FAILURESTOO_MANY_CODE_FAILURES - 503
SERVICE_UNAVAILABLE
Reverse a Redemption
/v1/partner/redemptions/{externalRef}/reverseFully reverses a redemption when the order is refunded. Repeating the request returns the same result.
Path Parameter
externalRefstringrequiredYour order number; it makes retries safe. The cashier: prefix is reserved.Pattern: ^[A-Za-z0-9._:-]{1,128}$
Request Body
reasonstringReason for the reversal.1-200 characters
Response (200, data)
idstring (uuid)modestringValues: live, testsourcestringValues: webhook, cashierexternalRefstring | nullstatusstringValues: verified, reversedorderAmountintegerdiscountAmountintegercurrencystringredeemedAtstring (date-time)reversedAtstring (date-time) | nullreasonstring | nullclaimobjectclaim.idstring (uuid)claim.codestringcampaignobject | nullcampaign.idstring (uuid)campaign.slugstringcampaign.titleobject
Error Responses
- 400
INVALID_JSON - 401
AUTH_FAILED - 403
MODE_NOT_ALLOWED - 404
REDEMPTION_NOT_FOUND - 413
BODY_TOO_LARGE - 415
JSON_REQUIRED - 429
RATE_LIMITEDTOO_MANY_FAILURES
List Redemptions
/v1/partner/redemptionsRedemptions in the key's brand and mode, newest first. Redemptions at the cashier come with source: cashier. No personal data is returned.
Query Parameters
fromstring (date-time)From this time (inclusive).tostring (date-time)Until this time (exclusive).statusstringFilter by status.Values: verified, reversedlimitintegerPage size.Between 1 and 100 · Default: 50cursorstring (uuid)The nextCursor value of the previous response.
Response (200, data.items item)
idstring (uuid)externalRefstring | nullstatusstringValues: verified, reversedsourcestringValues: webhook, cashiercampaignIdstring (uuid) | nullorderAmountintegerdiscountAmountintegercurrencystringredeemedAtstring (date-time)reversedAtstring (date-time) | null
Error Responses
- 400Validation error: message and issues
- 401
AUTH_FAILED - 403
MODE_NOT_ALLOWED - 429
RATE_LIMITEDTOO_MANY_FAILURES
List Campaigns
/v1/partner/campaignsThe brand's campaigns, drafts included. Claimed and redeemed counts follow the key's mode: a test key only counts test codes.
Query Parameters
statusstringFilter by status.Values: draft, pending_review, active, exhausted, endedlimitintegerPage size.Between 1 and 100 · Default: 50cursorstring (uuid)The nextCursor value of the previous response.
Response (200, data.items item)
idstring (uuid)slugstringtitleobjecttitle.trstringtitle.enstringstatusstringValues: draft, pending_review, active, exhausted, endedstartsAtstring (date-time) | nullendsAtstring (date-time) | nullquotaobjectquota.totalinteger | nullquota.remaininginteger | nullquota.claimedintegerquota.redeemedinteger
Error Responses
- 400Validation error: message and issues
- 401
AUTH_FAILED - 403
MODE_NOT_ALLOWED - 429
RATE_LIMITEDTOO_MANY_FAILURES
Rate Limits
- 600 requests per minute per key; above that 429 RATE_LIMITED with the retry delay in the body (retryAfter, seconds).
- 60 failed authentications per minute per IP; above that 429 TOO_MANY_FAILURES.
- The body must be JSON and at most 100 KB.
Error Codes
Error responses have the form { "code": "..." }; some codes carry extra fields (for example retryAfter).
DISCOUNT_TOO_HIGH400INVALID_JSON400MIN_BASKET_NOT_MET400REDEEMED_AT_INVALID400AUTH_FAILED401MODE_NOT_ALLOWED403CODE_NOT_FOUND404REDEMPTION_NOT_FOUND404ALREADY_REDEEMED409CAMPAIGN_NOT_STARTED409CODE_AMBIGUOUS409CODE_CANCELLED409CODE_EXPIRED409IDEMPOTENCY_CONFLICT409BODY_TOO_LARGE413JSON_REQUIRED415RATE_LIMITED429TOO_MANY_CODE_FAILURES429TOO_MANY_FAILURES429SERVICE_UNAVAILABLE503
