Create an event subscription
To add event notifications to your integration, use our API to create an event subscription and handle the notification that we send by webhook when an event occurs.
Important: To receive notifications, your server must be able to handle POST requests.
To create an event subscription, send the following information in your request:
- Event type - The event that you want to subscribe to. You can subscribe to more than one event within the same request.
- URI - The endpoint that we send notifications to. The endpoint must be publicly available.
- Secret - A secret that we return in the header of webhook requests to verify that it is a genuine request.
- Event status - The status of the event subscription.
- Email address - An email address that we contact if we can’t communicate with the endpoint that you provided.
Note: For a complete list of events that you can subscribe to, go to Events list.
Integration steps
Step 1. Create an event subscription
Step 2. Send a 200 response code
Step 3. Handle the notification content
Before you begin
Bearer tokens
Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps:
- Include your API key in the x-api-key parameter in the header of a POST request.
- Send your request to https://identity.payroc.com/authorize.
Note: You need to generate a new Bearer token before the previous Bearer token expires.
Example request
Example response
If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.
Headers
To create the header of each POST request, you must include the following parameters:
- Content-Type: Include application/json as the value for this parameter.
- Authorization: Include your Bearer token in this parameter.
- Idempotency-Key: Include a UUID v4 to make the request idempotent.
Errors
If your request is unsuccessful, we return an error. For more information about errors, see Errors.
Step 1. Create an event subscription
To create an event subscription, send a POST request to our event subscriptions endpoint.
Request parameters
To create the body of your request, use the following parameters:
Request
Example request
Response fields
If your request is successful, we send you the ID of the subscription. You can use the ID to update, retrieve, or delete the event subscription.
The response contains the following fields:
Response
Example response
Step 2. Send a 200 response code
We send notifications by webhook request to the URI endpoint that you provided when you created the subscription.
You must return a 200 status code when you receive the request.
If we do not receive a 200 response, we retry the request five times. After the fifth attempt, we send an email to the support email address that you provided when you created the subscription.
Note: We send an email only when a single instance of an event notification fails to deliver. If the event occurs again, we send another notification.
Step 3. Handle the notification content
Each notification follows the CloudEvents standard, and we use the data object to communicate information about the event that occurred, for example:
You can view our event notifications on the Events page.