Events and Webhooks
An important part of running a financial company is keeping records. We have done a lot of work to do this for you. We record an event for almost every single operation that can be performed in our system.
Events
Events contain the ids of resources affected by the operation that created the event. These ids can be used to look up these resources via their API endpoints. They also contain the id of the token and user (if a user token was used to authenticate the operation) as well as when the event was performed and under which account or organization.
Events can be accessed by making the following request:
{
"method": "get",
"url": "https://api.exactpaysandbox.com/event",
"headers": {
"Authorization": ""
}
}
Note than organization users or applications can query events under sub-organizations as follows:
{
"method": "get",
"url": "https://api.exactpaysandbox.com/organization/{organizationId}/event",
"headers": {
"Authorization": ""
}
}
...and for querying events on accounts under an organization:
{
"method": "get",
"url": "https://api.exactpaysandbox.com/account/{accountId}/event",
"headers": {
"Authorization": ""
}
}
Available Events
A list of events will be added shortly...
Available Event Lifecycle Statuses
It's also important to know that we track the duration of events, and when they start and end. It is possible to specify what stage of the event you want the webhook to be fired upon.
Lifecycle Status event.start | Event has started. Will be fired even if the event does not succeed. event.finish | Event has completed. Fires regardless of wether the event was a success or failure. event.success | Event has completed and was successful. event.failure | Event has completed and failed.
Webhooks
In order to best use events it's most useful to setup one or more webhook subscriptions. Webhooks are precomfigured POST requests that our servers will issue to your own whenever an event you've subscribed to is produced. The body of the request payload will be the event itself.
To create a webhook subscription you can issue the following request:
{
"method": "post",
"url": "https://api.exactpaysandbox.com/organization/{organizationId}/webhook",
"headers": {
"Authorization": ""
},
"body": {
"event": "accounts.create",
"url": "https://myserver.io/exact-webhook/account-creation"
}
}
The above example shows the creation of a webhook that will be triggered against the endpoint https://myserver.io/exact-webhook/account-creation
whenever an accounts.create
event is fired under the given organization.