OnCompletion Webhook
The OnCompletion webhook is sent once the user has earned enough to receive credit based on the terms of the promotion.
This allows your system to receive immediate, real-time feedback. The data sent over the webhook will match what is sent in the nightly report.
Prerequisites
- The endpoint being hit must be able to accept and close the request within 100ms
- A signed secret key must be established between your system and Rewarded Media
Available information to pass over
MID
The member ID is the unique identifier passed over during the initial request to the promotion link.
Signed Hash
The signed hash works similar to the signed hash used in order to authenticate the request to load the promotion link.
The shared secret key for webhooks must be different from what is used to sign the incoming request.
const memberId = 'abc123';
const sharedSecretKey = 'webhookSecretKeyThatShouldNotBeStoredInPlaintext';
const timestamp = Date.now()/1000;
const data = `${memberId}~${sharedSecretKey}~${timestamp}`;
Timestamp
A unix timestamp in seconds will be passed over that will match the timestamp used to sign the request.
Value Earned
The value in the denomination of currency set in the backend of Rewarded Media. All currencies will come in as whole numbers, so $0.01 earned would be passed over as 1, not 0.01.
HTTP Endpoint
The endpoint used for the webhook must be a secure endpoint (https) and respond back with response code 200, otherwise the request will be retried in one minute intervals for fifteen minutes.
Supported methods:
- GET
- POST
- PUT
Supported formats:
- URL/Query String params
- Form Data
- JSON Data
- XML Data
GET Request Example
METHOD: GET
URL: https://exampleendpoint.com/api/completion?partnerId=abc123&ts=__TIMESTAMP__&sig=__SIGNED_HASH__&mid=__UNIQUE_MEMBER_ID__&earnings=__EARNINGS__
POST JSON Request Example
METHOD: POST
HEADERS:
Content-Type: application/json
REQUEST BODY:
{
"MID": "__UNIQUE_MEMBER_ID__",
"TS": __TIMESTAMP__,
"Signature": "__SIGNED_HASH__",
"Earnings": "__EARNINGS__"
}
URL: https://exampleendpoint.com/api/completion?partnerId=abc123