Working with the Events Store

The /webhooks/subscriptions/{subscriptionId}/events endpoint returns information about the events that have been generated for a given webhooks subscription. For example:

{
   "id": "28da8068-61cc-4af3-8d5e-ae49a02dd47b",
   "createdAt": "2020-01-27T16:53:50.815936Z",
   "updatedAt": "2020-01-27T16:53:51.554764Z",
   "state": "success",
   "attempts": 1,
    "request": {
       "endpoint": "https://webhook.site/46ff3c5e-ae95-43df-b32d-d07bb84746b4",
      "headers": {
           "Accept": "*/*",
           "Content-Length": "1293",
           "Content-Type": "application/secevent+jwt",
           "Host": "webhook.site",
           "User-Agent": "Akamai Identity Cloud Webhooks/v3.0.0"
       },
       "payload": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjFkYzEyMDczNjk5YzY4YzFkYWVlNmM5YTEwMGUyYjQzZmViZGNkOTIifQ
.eyJhdWQiOlsiaHR0cHM6Ly93ZWJob29rLnNpdGUvNDZmZjNjNWUtYWU5NS00M2RmLWIzMmQtZDA3Y
mI4NDc0NmI0Il0sImV2ZW50cyI6eyJlbnRpdHlVcGRhdGVkIjp7ImF0dHJpYnV0ZXMiOlsiZmFtaWx5TmFtZSJ
dLCJjYXB0dXJlQXBwbGljYXRpb25JZCI6IjN2YWRiYTN2aHFwa2RndHNycWQ0c3Q3Nm0zIiwiY2FwdHVyZ
UNsaWVudElkIjoiM2ZwNHp0OXQyNTZqcWs0dHgzNXd1ajRhcDJlNTNocTkiLCJlbnRpdHlUeXBlIjoidXNlciIs
Imdsb2JhbFN1YiI6ImNhcHR1cmUtdjE6Ly9hcHAuY2FwdHVyZS5tdWx0aS5kZXYub3IuamFucmFpbi5jb20v
M3ZhZGJhM3ZocXBrZGd0c3JxZDRzdDc2bTMvdXNlci9lNDk5YWMyNC00NmJkLTRkODUtOTFlZS1iZGVhZ
GQ0NDZjMWUiLCJzdWIiOiJlNDk5YWMyNC00NmJkLTRkODUtOTFlZS1iZGVhZGQ0NDZjMWUifX0sImlhdC
I6MTU4MDE0NDAzMCwiaXNzIjoiaHR0cHM6Ly9hcGkubXVsdGkuZGV2Lm9yLmphbnJhaW4uY29tLzAwMD
AwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMC93ZWJob29rcyIsImp0aSI6IjFlNTY5Y
mI1LWMyMWQtNGU5Yy1hMWFhLTdlYzNiODMxYmRhMiIsInRvZSI6MTU4MDE0NDAzMDczOSwidHhuIjoiM
DAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIn0.D4PsqQiwvXmd3bons9Jcq
HEf69Tw46I2C4Zg713gw8Y11QPLywKXMveFzgmRRVS3OyG38LVSz6wJfmn02Du4hlMpi44Rnna_k9rv1W
TxC7CFOFqVXzJyQ-TvSdYLEU5hfCpfodlyeE4v-SPZoOfZkQdUa8vPm4wiOOnr0QfZlY3uTRcPczY3jy2Gv6eL
RSjk2q4LY0rYHHaojHofYJARahGjah9JrkmbTaMkvuv3CwBnUrKkp2nomOzl2Z858xaRUrgHfgXEuOYrhasRrbc
An-MyuQfY7hlPjSl8Lka25JgeIOmCLpK2-fFZ0rDW1k1MzHak6q2rftE7vSvObcw"
   },
   "response": {
       "statusCode": 200,
       "headers": {
           "Cache-Control": "no-cache, private",
           "Content-Type": "text/plain; charset=UTF-8",
           "Date": "Mon, 27 Jan 2020 16:53:51 GMT",
           "Server": "nginx/1.14.2",
           "Set-Cookie": "laravel_session=0WvS2SrKRs0In3XSBAdlLykpCCTTnJmzLnCYljfw; expires=Mon, 27-Jan-2020 18:53:51 GMT;    Max-Age=7200; path=/; httponly",
           "Vary": "Accept-Encoding",
           "X-Ratelimit-Limit": "100",
           "X-Ratelimit-Remaining": "97",
           "X-Request-Id": "11d339a3-17bd-457d-abde-64c5810e5244",
           "X-Token-Id": "46ff3c5e-ae95-43df-b32d-d07bb84746b4"
       }
   },
   "_links": {
       "self": {
           "href": "/00000000-0000-0000-0000-000000000000/webhooks/subscriptions/e5269842-024f-49bf-8a39-67aec8048b42/events/28da8068-61cc-4af3-8d5e-ae49a02dd47b"
       },
       "redeliver": {
           "href": "/00000000-0000-0000-0000-000000000000/webhooks/subscriptions/e5269842-024f-49bf-8a39-67aec8048b42/events/28da8068-61cc-4af3-8d5e-ae49a02dd47b/redeliver"
       },
       "history": {
           "href": "/00000000-0000-0000-0000-000000000000/webhooks/subscriptions/e5269842-024f-49bf-8a39-67aec8048b42/events/28da8068-61cc-4af3-8d5e-ae49a02dd47b/history"
       }
   },
   "eventType": "entityUpdated"
}

To be honest, the actual data returned here doesn’t matter; what matters is that the /subscriptions/{subscriptionId}/events endpoints are connected to the Identity Cloud events store; they are not connected to the database of received webhook notifications maintained by your organization. Among other things, that explains why the payload value for each event looks similar to this:

Y4YzFkYWVlNmM5YTEwMGUyYjQzZmViZGNkOTIifQ.eyJpc3MiOiJBa2FtYWkgSWRlbnRpdHkgQ2xvdWQ
iLCJpYXQiOjE1NjM0ODg2MzEsImp0aSI6ImI3MDA0NmJkLTQ0YzctNDU3NS1iMWEyLTliODU1NmQxZjA0M
CIsImF1ZCI6Imh0dHBzOi8vZXhhbXBsZS5jb20vcGF0aC90by9lbmRwb2ludCIsInR4biI6IjAwMDAwMDAwL
TAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMCIsInRvZSI6MTU1OTM3MjQwMCwiZXZlbnRzIjp
7InVzZXJDcmVkZW50aWFsVXBkYXRlZCI6eyJjYXB0dXJlQXBwbGljYXRpb25JZCI6Inp6eW45Z3k5cjh4ZHk
1emtydTR5NTRzeWs2IiwiY2FwdHVyZUNsaWVudElkIjoiZWxycm5pdXg1MWEzbnJoZnd6a2x2ejN0NDZsY
jVuMm0iLCJlbnRpdHlUeXBlIjoidXNlciIsImdsb2JhbFN1YiI6ImNhcHR1cmUtdjE6Ly91cy5qYW5yYWluY2Fwd
HVyZS5jb20venp5bjlneTlyOHhkeTV6a3J1NHk1NHN5azYvdXNlci82YjAwNGJjNS0xNzljLTQ1YzItODE1ZC0z
MWIwNjE2OTM3MWQiLCJzdWIiOiI2YjAwNGJjNS0xNzljLTQ1YzItODE1ZC0zMWIwNjE2OTM3MWQiLCJjcm
VkZW50aWFsVHlwZSI6InBhc3N3b3JkIiwiaWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wM
DAwMDAwMDAwMDAifX19.IvkrGFE3GsK3eTLO_QvdFKqg4ktJ2sDToHNghMfGUlWNzRLMIpmgsWZXzLv0
QMiyatLva7mEshTlfyOje-S_Y-nUniM9hgHgNg-R0Az9hs2mu_ORcXEFo9AHayhjvW1bKHcmTI7dlw2fqFl-2V
BS594LQspDYfZ4WJ7hexq7OwACB8qp0oVskx_fc8mHQfy4YnW5GF4XlTcl6CnjYU81qY4hejcnkkg8olbq_eP
UnpTpW8-YO5cPW9nW8KlivRJGWJbEXnffSAd5

That’s because security event tokens are not decoded before being added to the events store. Instead, events are written to the database as-is.

Does it really matter that the APIs are connected to the event store rather than to your organization’s internal database? As a matter of fact, it does. Your organization’s internal database shows the event notifications that have been delivered. By comparison, the event store shows every event that has been generated for your organization. (Or, to be a little more precise, it shows every event that has been generated in the past 7 days; events more than 7 days old are automatically deleted from the events store.)

So why does that matter? That matters because it gives you a way to check how well the webhooks delivery service is working. If you thumb through the event store and see one or two failed deliveries (among thousands of events), that’s probably no cause for alarm. If you see hundreds of failed events, that could be a different story.

In Webhooks v3, the system makes 6 attempts to deliver an event. And what if delivery fails all 6 times? Well, in that case, the event state changes to failure, and no more delivery attempts are made. However, the event is not discarded, at least not right away. Instead, failed events are maintained in the events store for 7 days.