Marketing Consent Webhooks
Aghanim's marketing consent webhooks notify your game about changes to a player's marketing consent, allowing you to keep your marketing lists in sync.
Webhook events
Use these webhook events to manage your marketing lists.
| Event | When it fires | What you should do |
|---|---|---|
player.marketing_consent.updated | A player's marketing consent state changes | Update your marketing lists accordingly |
Requirements
To use marketing consent webhooks from Aghanim, you should have the webhook server configured as follows:
- HTTPS endpoint, accepting POST webhook requests.
- Listen for events, generated and signed by Aghanim.
- Handle the
idempotency_keyincluded in the webhook payload to prevent processing duplicate webhooks. - Respond with 2xx status codes if the event was processed successfully, and 4xx or 5xx for errors.
Configuration
- Develop a function for marketing consent webhook processing.
- Make your endpoint available.
- Register your endpoint within Aghanim account → Game → Webhooks → Add webhook by choosing the marketing consent event types you want to handle.
Alternatively, you can register your endpoint within Aghanim using the Create Webhook API method.
Trigger values
| Value | Description |
|---|---|
hub.purchase | When a player opts in to marketing during checkout. |
s2s.player.marketing_consent.grant | When consent is granted via the Grant Email Marketing Consent S2S API. |
s2s.player.marketing_consent.revoke | When consent is revoked via the Revoke Email Marketing Consent S2S API. |
dashboard.player.marketing_consent.revoke | When consent is revoked through the Aghanim Dashboard. |
checkout_profile.player.marketing_consent.revoke | When consent is revoked from the checkout profile. |
test | When using the "Send test event" in the Dashboard. |
See the full events and triggers matrix for how player.marketing_consent.updated relates to other event types.
Request schema
Below is an example of an player.marketing_consent.updated webhook request:
- HTTP
- cURL
POST /your/webhook/uri HTTP/1.1
Content-Type: application/json
Host: your-webhook-endpoint.com
User-Agent: Aghanim/0.1.0
X-Aghanim-Signature: 2e45ed4dede5e09506717490655d2f78e96d4261040ef48cc623a780bda38812
X-Aghanim-Signature-Timestamp: 1725548450
{
"event_type": "player.marketing_consent.updated",
"event_data": {
"player_id": "2D2R-OP3C",
"email": {
"address": "[email protected]",
"granted_at": 1704067200,
"revoked_at": null
}
},
"event_time": 1725548450,
"event_id": "whevt_eCacGbJVbvToOgzjXUgOCitkQE",
"idempotency_key": null,
"request_id": "d1593e9c-c291-4004-8846-6679c2e5810b",
"sandbox": false,
"trigger": "hub.purchase",
"transaction_id": "whtx_eCacGbJVbvT",
"context": null,
"game_id": "gm_exTAyxPsVwh"
}
curl "https://your-webhook-endpoint.com/your/webhook/uri" \
-X POST \
-H "Content-Type: application/json" \
-H "User-Agent: Aghanim/0.1.0" \
-H "X-Aghanim-Signature: 2e45ed4dede5e09506717490655d2f78e96d4261040ef48cc623a780bda38812" \
-H "X-Aghanim-Signature-Timestamp: 1725548450" \
-d '{
"event_type": "player.marketing_consent.updated",
"event_data": {
"player_id": "2D2R-OP3C",
"email": {
"address": "[email protected]",
"granted_at": 1704067200,
"revoked_at": null
}
},
"event_time": 1725548450,
"event_id": "whevt_eCacGbJVbvToOgzjXUgOCitkQE",
"idempotency_key": null,
"request_id": "d1593e9c-c291-4004-8846-6679c2e5810b",
"sandbox": false,
"trigger": "hub.purchase",
"transaction_id": "whtx_eCacGbJVbvT",
"context": null,
"game_id": "gm_exTAyxPsVwh"
}'
The Event schema
| Key | Type | Description |
|---|---|---|
event_id | string | Unique Event ID generated by Aghanim. |
game_id | string | Your game ID in the Aghanim system. |
event_type | string | The type of the event, player.marketing_consent.updated in this case. |
event_time | number | Event date in Unix epoch time. |
event_data | EventData | Contains the event-specific data, with possible keys for inherited objects. |
idempotency_key | string|null | Ensures webhook actions are executed only once, even if retried. Can be null depending on event type. |
request_id | string|null | If the event was triggered by an API request, the request ID is included. |
sandbox | boolean | Indicates whether the event was sent from the sandbox game environment. |
trigger | string|null | The trigger that caused the event to be sent. |
transaction_id | string | The transaction ID generated by Aghanim. This ID may be the same for multiple events emitted within the same transaction. |
context | object|null | Contextual information about the event. |
The EventData schema
| Key | Type | Description |
|---|---|---|
player_id | string | The unique Player ID chosen for player authentication. |
email | EmailChannel|null | Email channel consent. Present when email consent changed. |
The EmailChannel schema
| Key | Type | Description |
|---|---|---|
address | string | The player's email address. |
granted_at | number | Unix timestamp when consent was granted. |
revoked_at | number|null | Unix timestamp when consent was revoked. null if consent has not been revoked. |
Need help?
Contact our integration team at [email protected]