1. Find ApplicationID
+
As it was mentioned above, Webhook Subscription always belong to some application. Hence, you should start from
+finding out the ID of the target Application in order to link the new Webhook Subscription to it. For this purpose
+you should use List Applications endpoint. This endpoint returns
+a list of all available Applications in your account, so you could identify the needed one by name
, developerEmail
+or clientId
in the Application resource body:
+
GET https://ankorstore.com/api/v1/applications
+
{
+ "data": {
+ "id": "43efbfbd-bfbd-1eef-1e6a-6200efbfbdef",
+ "type": "application",
+ "attributes": {
+ "name": "My Application",
+ "developerEmail": "dev@acme.com",
+ "clientId": "k322k7frs87e8w7hri3jkke7ry7",
+ "clientSecret": null
+ }
+ }
+}
+
+
NOTE: The client secret in the response is always null
due to security reasons. The actual client secret
+can be seen only via UI and only once - during the creation of the application.
+
2. Find valid webhook events to subscribe to
+
Next step should be to find the valid names of the webhook events which you could use in the create webhook request
+payload:
+
GET https://ankorstore.com/api/v1/webhook-subscriptions/events
+
{
+ "data": [
+ {
+ "type": "webhook-subscriptions/events",
+ "id": "order.brand_created"
+ },
+ {
+ "type": "webhook-subscriptions/events",
+ "id": "order.brand_accepted"
+ }
+ ]
+}
+
+
You can find detailed description of each event in the dedicated section of the docs.
+
3. Create webhook subscription
+
Now you are all set for creating actual webhook subscription. The prerequisites for this step are:
+
+- The Application ID from step 1 (
43efbfbd-bfbd-1eef-1e6a-6200efbfbdef
in this example)
+- The chosen events from step 2 (e.g.
order.brand_created
and order.brand_accepted
)
+With this setup the final request should look like:
+
+
POST https://ankorstore.com/api/v1/webhook-subscriptions
+
{
+ "data": {
+ "type": "webhook-subscription",
+ "attributes": {
+ "url": "https://my-app.com/webhook-listener",
+ "events": [
+ "order.brand_created",
+ "order.brand_accepted"
+ ]
+ }
+ },
+ "relationships": {
+ "applications": {
+ "data": {
+ "type": "application",
+ "id": "43efbfbd-bfbd-1eef-1e6a-6200efbfbdef"
+ }
+ }
+ }
+}
+
+
After this request is succeeded, you will start receiving notification about chosen events on the chosen URL.
+