Webhooks
You can configure a single webhook URL to be notified about events from Pier. All events go to the same URL and are distinguished by an event type and code. If you configure the webhook multiple times, the URL will be overwritten and all events will only be delivered to the most recently configured endpoint URL. In addition, deleting the webhook URL will clear it and no events will be delivered, even if the webhook was configured multiple times.
Setup webhook endpoint
Delete webhook endpoint
Webhook Authentication (optional, recommended)
Webhooks include a JWT in the pier-webhook-verification
header. The JWT payload contains a sha256
signature for the webhook body in the request_body_sha256
field.
To ensure the payload is sourced from Pier:
- The JWT should be verified using a library for your stack and the Pier public key (see
/configuration/webhook-verification
). You should replace\n
with newlines in the public key before using it (e.g..replace(/\\n/g, "\n")
). - Extract the payload from the JWT.
- Extract the SHA256 signature from the JWT payload
request_body_sha256
field. - Compute the SHA256 signature of the webhook payload.
- Ensure that the computed SHA256 and the SHA256 from the JWT match.
Take care not to process the webhook body prior to computing the signature, otherwise you may get a false negative when comparing signatures.
Webhook Object
type
: High-level webhook event type.code
: Detailed event type.env
: The Pier environment from which the event was sent (see above).url
: The url the webhook was sent to.timestamp
: The time at which the event occurred.identifiers
: Event-specific identity of the object acted upon in the event.details
: Event-specific supplemental details about the event.
More details about identifiers
and details
for each event can be found in the detailed documentation for each event type/code below.
Generic webhook object example
Note that the type, code, identifiers, and details fields depicted here are generic and don’t reflect actual values you will see. Concrete examples for each event type are shown below.
Webhook event types
At a high level, Pier events fall into four types as shown:
In addition to an event type, each event has a more detailed code as summarized in the list below. More detailed descriptions of each event code and the data returned are included in the following section.
Webhook codes
The following webhook codes provide more detail about the nature of the event. Additional info about each code is provided in the detailed webhook examples below:
transaction_succeeded
transaction_failed
transaction_initiated
statement_ready
autopay_scheduled
payment_due
payment_late_5_days
payment_late_10_days
payment_late_15_days
payment_late_30_days
payment_late_45_days
kyc_approved
kyc_declined
Identifiers
Certain event types also include identifiers for relevant Pier entities when appropriate:
Detailed webhook examples
Disbursements
Disbursements (and payments) have three events in their lifecycle that trigger webhooks:
transaction_initiated
- indicates that the disbursement has been sent to the ACH network
transaction_succeeded
- indicates that the disbursement has successfully settled.
transaction_failed
- indicates that the disbursement has failed, and likely has a return code.
Disbursement webhook examples
transaction_initiated
transaction_succeeded
transaction_failed
Payments
Payments have the same events as disbursements. The only difference in these cases are the type
field which will be payment
instead of disbursement
in the examples above.
In addition, payments also have a number of autopay and past due events:
autopay_scheduled
- indicates that an autopay has been scheduled for the next payment due. Implies
payment_due
event will not be sent.
- indicates that an autopay has been scheduled for the next payment due. Implies
payment_due
- indicates that a payment is due. Implies
autopay_scheduled
event will not be sent.
- indicates that a payment is due. Implies
payment_late_5_days
payment_late_10_days
payment_late_15_days
payment_late_30_days
payment_late_45_days
- indicates that a payment is late by the number of days specified in the event code.
Payment webhook examples
autopay_scheduled
payment_due
payment_late_5_days
payment_late_10_days
payment_late_15_days
payment_late_30_days
payment_late_45_days
Statements
When a statement is ready, a statement_ready
webhook is sent. The statement_id
and facility_id
are included in the identifiers
field.
KYC Inquiries
KYC inquiry webhook examples are shown below. They only vary in the result indicated in the codes kyc_approved
for a successful KYC check and kyc_declined
for a KYC check that resulted in a failure. Both always include the consumer_id
of the borrower for whom the KYC check was performed in the identifiers
field.
- Approved
- Declined
See the KYC Guide for more information about this feature.
Webhook retries
If the webhook endpoint does not respond with a 2xx status code, Pier will retry sending the webhook up to 5 times with an exponential backoff. The first retry will be around 10 seconds later, the second after around 2 minutes, the third after around 15-20 minutes, the fourth after 2-3 hours, and the fifth after approximately 1 day. If the webhook still fails after 5 retries, the webhook will be marked as failed and no further retries will be attempted.