Setting Up Webhooks
When creating yourlink_session_token with the POST /link-session endpoint, you will pass your webhook URL with the webhook field
link_session_token with POST /link-session
Webhook Security
The webhook payload is signed and will include a moneykit-signature header that can be used to authenticate the webhook. MoneyKit offers a JSON Web Key Set (JWKS) you can fetch in order to verify the JWT in the header. The JWKS used to sign is rotated regularly, you can use this endpoint to fetch the latest key set.Note that only one key returned from the JWKS endpoint is meant to be used for
verification.
- The
kidin the webhook JWT header will match up with the key id of one of the keys returned from the JWKS endpoint. - Depending on the language, some JWT packages will handle this for you. You can pass in the Key Set with the token when decoding (instead of a single key).
- To verify the webhook, first extract the
moneykit-signaturefrom the webhook header, then fetch the latest key set with the above endpoint, and then validate themoneykit-signatureusing the key set with your preferred JWT library.
Link State Changed Webhook
- You will receive this webhook when the state of a link has changed
-
There are five different states for a link, outlined in the enum
LinkStateLinkState -
If the state is
ERROR, you will be provided an error type via theLinkErrorenumLinkError -
Here are two examples of the Link State Changed webhook response body
-
Any link_tags you provide when creating your
link_session_tokenwith the POST /link-session endpoint will be included in the Link State Changed webhook body:
Link Product Refresh Webhook
You will receive this webhook after aggregation for a product has been completed. There are three scenarios in which this will happen:-
After an end user completes linking their accounts, if prefetch for a product is set as
true. - After requesting a product refresh using the product refresh endpoint.
- After a scheduled, periodic aggregation.
Transaction Updates Available Webhook
You will receive this when transactions have been aggregated for a link. Here is the Transactions Updates Available webhook class in Python:true for the Transactions product when creating your link_session_token with the POST /link-session endpoint.
In order to aggregate the full transaction history for the link, mark extend_history as true for the Transactions product when creating your link_session_token with the POST /link-session endpoint.
has_history in the webhook body will return true.