Test your integration
Try every path with a test key, read the test flag on records and webhooks, check your retries, and confirm the list before you go live.
Test with a test key before you ask for a live one. A test key writes sandbox records, kept apart from your live evidence, so you can try every path freely.
Read the test flag#
Everything written with a test key says so.
- Records. Every record the API returns carries
test. - Webhooks. Every delivery has
testat the top level. It istruewhen the event is about a record written with a test key. - The console. A sandbox record has a Test badge in Records. The list starts on Live records only. More filters also offers Live and test records and Test records only.
{
"id": "5d7e0a5c-1c1b-4f55-9a57-0d0f7f0e2a11",
"type": "consent.granted",
"test": true,
"data": {
"consentId": "cns_3f9a1c0e5b7d4a2c9e8f6b1d0a7c5e42",
"status": "GRANTED",
"test": true
}
}A daily job deletes every sandbox record that has not changed for 30 days, with its events. Keep nothing you need in a test record.
Test your server calls#
- Record consent with the test key, and check that the answer carries
"test": true. - In the console, open Records, choose More filters and pick Test records only. The record has a Test badge.
- Send the same write again with the same
Idempotency-Key. The answer is the first one, with the headerIdempotent-Replayed: true. - Find the test person, withdraw them, then erase them.
- In your webhook receiver, check that each event arrived with
"test": true. - Decide what your receiver does with test events, and add that rule after the signature check.
const event = JSON.parse(req.body.toString('utf8'));
if (event.test) {
return res.sendStatus(200);
}The same idempotency key with a different body gets 422 IDEMPOTENCY_KEY_REUSED. A key is remembered for 24 hours. Conventions has the full rules.
Test in a browser on localhost#
A test key answers http://localhost, http://127.0.0.1 and http://[::1] on any port, without listing them. Two things do not count as localhost:
- A page opened from disk. A
file://page has no origin and gets401. Serve the folder instead, such as withpython3 -m http.server 8080. - Another machine or a phone on your network. An address such as
http://192.168.1.20:8080is an ordinary origin. List it when you create the key.
To be asked again after you answer, run await PiedapConsent.reset() in the browser console.
Try the form for a place#
Which form a visitor gets depends on where they are. Ask the API what a place would get:
curl "https://console.dpconsent.com/consent/sdk/v1/form?key=pk_…&country=US&subdivision=CA"The answer names the form, the consentModel and the law. "form": null means no rule covers that place, so nothing is asked there. In the console, the Try the runtime panel in Install shows the same answer.
On a page, add data-piedap-country="US" and data-piedap-subdivision="CA" to the loader tag.
Remove the override before you go live
The override works with live keys too. A page that ships with data-piedap-country shows every visitor the form for that one place.
Check before you request go-live#
Then ask for the key to go live. When it is live, run PiedapConsent.reset() once in the browsers you tested with, so their next answer is a live one.