About Webhooks
Unlocking Real-Time Communication: A Comprehensive Guide to Webhooks
Webhooks offer a valuable solution for seamlessly receiving events from our system. For example, imagine you wish to notify a user when a Smart Charging Session starts. Without webhooks, your application would be required to frequently query our system's GET Sessions endpoint, constantly checking for any updates. Not only would this approach place additional strain on our system, but it would also add unnecessary complexity to your workflow. By implementing webhooks, you can streamline this process, ensuring real-time notifications with minimal overhead.
Registration
How to set up Webhooks:
- Create Endpoints: You will need to create endpoints within your systems where you would want to receive the notifications.
- Subscribe Endpoints: You need to tell our system where to send notifications by registering your endpoint to our system. To do this, you make a request to our system's
POST /webhooks/subscriptions
endpoint. In this request, you provide:- The
endpointUrl
of your endpoint where you want to receive notifications. - Your
apiKey
in the Authorization header for authentication as abasic
token
- The
- Test accessibility: We'll then try accessing your endpoint. If we can't, the registration fails, and you'll get a 400 Bad Request response.
Below is an example on how to Subscribe and a test response:
curl --request POST \
--url https://demo-smartcharging.jedlix.com/api/v1/webhooks/subscriptions \
--header 'accept: application/json' \
--header 'authorization: Bearer eyJhbGc...' \
--header 'content-type: application/json' \
--data '
{
"eventType": "userCreated",
"endpointUrl": "https://tempuri.org/jedlix-webhook-receiver",
"apiKey": "8pN5h77Pjf5pANLb9pePx5C492F5SjqT",
"isActive": true
}
'
curl --request POST \
--url https://tempuri.org/jedlix-webhook-receiver \
--header 'accept: application/json' \
--header 'authorization: Basic 8pN5h77Pjf5pANLb9pePx5C492F5SjqT' \
--header 'content-type: application/json' \
--data '
{
"eventType": "userCreated",
"id": "51640a48-7ec3-45ca-8594-b94f71ab4946",
"tenant": "test",
"timestamp": "2024-01-31T11:43:02.164Z",
"userId": "67f6ce94-096e-4ca0-9c16-e12805f22f0f",
"isTest": true
}
'
We'll send a test message during the registration process to ensure we can reach your endpoint. This test message will have the isTest
property set to true, so you'll know it's just for testing purposes and can be ignored. Each event type has its own message. For more details on our example implementation, visit our documentation here.
History
We maintain a 7-day history of events, which serves as a valuable resource for troubleshooting and event retrying. This means you can reprocess the information from the past week through your system if necessary. Additionally, it provides insights into any errors we've captured from your system.
Event Data
The data sent through webhooks differs from the data available on the Smart Charging API. These events include the information we have at the time of the event. If you require additional information, you can fetch it using the endpoints provided by the Smart Charging API.
Missing events
If you believe certain events are missing, please share your insights with us. Understanding your needs allows us to collaborate effectively and strive to provide the required events. Let us know your ideas, and we'll work together to ensure you have access to the events that best meet your needs.
Updated 8 months ago