-
Obtain an OpenTrack API key.
-
For the OpenTrack API to be able to reach the webhook client example app running on your dev machine, you need to setup a tunnel from the Internet to your dev machine. To do so, this project uses ngrok.
-
From the root folder of the solution, call
docker compose up --build
. -
Open http://localhost:4040/ (ngrok's status page) and grab the link which looks like
https://a385293972ff.ngrok.io
. -
Register the webhook client example app by posting your OpenTrack API key and the app's public address (e.g.
https://a385293972ff.ngrok.io
) to https://api.opentrack.co/v1/webhooks. Be sure to use the same value for thesecret
in this request and in the .env file in the root of the solution.curl --location --request POST 'https://api.opentrack.co/v1/webhooks' \ --header 'Opentrack-API-Key: Your OpenTrack API key' \ --header 'Content-Type: application/json' \ --data-raw '{ "url": "https://a385293972ff.ngrok.io/webhook", "events": [ "container.status.updated", "container.itinerary.updated", "container.location.updated", "container.holds.updated", "container.demurrage.updated", "container.tracking.failed" ], "secret": "Very Secret Service", "name": "Your test webhook name" }'
-
The webhook client example app is ready to receive requests from the OpenTrack API.
- If not signed in, nrok's session and consequently the example app's link will only work for 2 hours. Sign in, grab your ngrok authtoken here, and then paste it into the .env file in the root of the solution.
- Every time the ngrok's container is restarted (e.g. after calling
docker compose up --build
), ngrok generates a new random public link. So for the webhook client example app to continue receiving requests from OpenTrack API after being restarted, you need to grab a newly generated public link from ngrok's status page and update your webhook by following the instruction here.