Quickstart
In 15 minutes you will send an event to the test environment and see how it changed a user’s progress.
-
Get your test mode keys. For now we connect clients by hand: ask your A-App manager, and they will give you three values:
What Looks like Used for API key aapp_test_…the Authorizationheader of every requestEvent signing secret whsec_…signing POST /v1/eventsWebhook secret whsec_…verifying the signature of our webhooks Keep them on your server only. They never go to a browser, a mobile app or a repository.
-
Sign and send an event. Every event is signed with the Standard Webhooks scheme: HMAC-SHA256 of the string
{webhook-id}.{webhook-timestamp}.{body}. The HMAC key is the part of the secret afterwhsec_, decoded from base64. Sign exactly the bytes you send as the body.// app/lib/aapp.ts: only on the server, never in a client componentimport { createHmac } from 'node:crypto';const API = 'https://test-api.dnk.az';export async function sendEvent(event: Record<string, unknown> & { event_id: string }) {const body = JSON.stringify(event);const timestamp = Math.floor(Date.now() / 1000).toString();const key = Buffer.from(process.env.AAPP_SIGNING_SECRET!.slice('whsec_'.length), 'base64');const signature = createHmac('sha256', key).update(`${event.event_id}.${timestamp}.${body}`).digest('base64');const res = await fetch(`${API}/v1/events`, {method: 'POST',headers: {Authorization: `Bearer ${process.env.AAPP_API_KEY}`,'Content-Type': 'application/json','webhook-id': event.event_id,'webhook-timestamp': timestamp,'webhook-signature': `v1,${signature}`,},body,signal: AbortSignal.timeout(10_000),});return { status: res.status, body: await res.json() };}await sendEvent({event_id: 'evt_90114',type: 'order.paid',user_ref: '4f9a',order_id: 'ord_78123',occurred_at: new Date().toISOString(),amount: 25.0,currency: 'AZN',items: [{ sku: 'game-123', category: 'rpg', price: 25.0, qty: 1 }],});import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.nio.charset.StandardCharsets;import java.time.Duration;import java.time.Instant;import java.util.Base64;import javax.crypto.Mac;import javax.crypto.spec.SecretKeySpec;public class AappEvents {static final String API = "https://test-api.dnk.az";public static void main(String[] args) throws Exception {String id = "evt_90114";String body = """{"event_id":"evt_90114","type":"order.paid","user_ref":"4f9a","order_id":"ord_78123",\"occurred_at":"%s","amount":25.00,"currency":"AZN"}""".formatted(Instant.now());String timestamp = Long.toString(Instant.now().getEpochSecond());String secret = System.getenv("AAPP_SIGNING_SECRET"); // whsec_…byte[] key = Base64.getDecoder().decode(secret.substring("whsec_".length()));Mac mac = Mac.getInstance("HmacSHA256");mac.init(new SecretKeySpec(key, "HmacSHA256"));String signature = Base64.getEncoder().encodeToString(mac.doFinal((id + "." + timestamp + "." + body).getBytes(StandardCharsets.UTF_8)));HttpRequest request = HttpRequest.newBuilder(URI.create(API + "/v1/events")).timeout(Duration.ofSeconds(10)).header("Authorization", "Bearer " + System.getenv("AAPP_API_KEY")).header("Content-Type", "application/json").header("webhook-id", id).header("webhook-timestamp", timestamp).header("webhook-signature", "v1," + signature).POST(HttpRequest.BodyPublishers.ofString(body, StandardCharsets.UTF_8)).build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.statusCode() + " " + response.body());}}package mainimport ("bytes""crypto/hmac""crypto/sha256""encoding/base64""encoding/json""fmt""io""net/http""os""strconv""strings""time")const api = "https://test-api.dnk.az"func main() {event := map[string]any{"event_id": "evt_90114","type": "order.paid","user_ref": "4f9a","order_id": "ord_78123","occurred_at": time.Now().UTC().Format(time.RFC3339),"amount": 25.00,"currency": "AZN",}body, _ := json.Marshal(event)id := "evt_90114"timestamp := strconv.FormatInt(time.Now().Unix(), 10)key, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(os.Getenv("AAPP_SIGNING_SECRET"), "whsec_"))if err != nil {panic(err)}mac := hmac.New(sha256.New, key)mac.Write([]byte(id + "." + timestamp + "." + string(body)))signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))req, _ := http.NewRequest(http.MethodPost, api+"/v1/events", bytes.NewReader(body))req.Header.Set("Authorization", "Bearer "+os.Getenv("AAPP_API_KEY"))req.Header.Set("Content-Type", "application/json")req.Header.Set("webhook-id", id)req.Header.Set("webhook-timestamp", timestamp)req.Header.Set("webhook-signature", "v1,"+signature)client := &http.Client{Timeout: 10 * time.Second}res, err := client.Do(req)if err != nil {panic(err)}defer res.Body.Close()out, _ := io.ReadAll(res.Body)fmt.Println(res.StatusCode, string(out))}Окно терминала API=https://test-api.dnk.azBODY='{"event_id":"evt_90114","type":"order.paid","user_ref":"4f9a","order_id":"ord_78123","occurred_at":"2026-11-29T10:00:00Z","amount":25.00,"currency":"AZN"}'ID=evt_90114TS=$(date +%s)KEY_HEX=$(printf %s "${AAPP_SIGNING_SECRET#whsec_}" | base64 -d | od -An -tx1 | tr -d ' \n')SIG=$(printf %s "$ID.$TS.$BODY" | openssl dgst -sha256 -mac HMAC -macopt hexkey:$KEY_HEX -binary | base64)curl -sS "$API/v1/events" \-H "Authorization: Bearer $AAPP_API_KEY" \-H 'Content-Type: application/json' \-H "webhook-id: $ID" \-H "webhook-timestamp: $TS" \-H "webhook-signature: v1,$SIG" \-d "$BODY"A 202 response means the event is accepted. Repeating the request with the same
event_idand body is safe: the duplicate changes nothing. -
Check what happened to the event. We count it in the background, usually within seconds.
Окно терминала curl -sS "$API/v1/events/evt_90114" -H "Authorization: Bearer $AAPP_API_KEY"The
statusfield shows whether the event was counted:acceptedmeans it is still queued,processedmeans it was counted andchangeslists what changed,ignoredmeans it counted nowhere andreasonexplains why, for example the event type is not described in your dictionary yet. -
Get the user’s status.
Окно терминала curl -sS "$API/v1/users/4f9a/status" -H "Authorization: Bearer $AAPP_API_KEY"The response holds the user’s group (
participantorcontrol), badges, progress in each scenario and rewards. A new user without events also gets 200: the available scenarios with statusnot_started. -
Receive a webhook. When a reward becomes available, we send
reward.availableto your URL. How to receive it and verify the signature is in the Receiving webhooks guide.
What next
Section titled “What next”- API reference: every field, error code and example.
- Postman collection for the test environment.