diff --git a/pull/38442/index.html b/pull/38442/index.html index 4582463..ebc329d 100644 --- a/pull/38442/index.html +++ b/pull/38442/index.html @@ -520,7 +520,7 @@ -
Rate Limiting
  • Testing - helper endpoints for testing and data generation.
  • Webhook Subscription

    Rate Limiting <li><code>external_order.shipped</code> - Order shipped from the warehouse</li> <li><code>external_order.arrived</code> - Order is arrived and completed</li> </ul> -<h3 id="note">NOTE:</h3> -<p>When External Order is created webhook <code>external_order.created</code> is fired and at same time fulfillment is requested which means <code>external_order.awaiting_fulfillment</code> is also fired. Due to async nature of webhook when you receive these webhooks most likely order status is <code>awaiting_fulfillment</code> for <code>external_order.created</code> webhook too.</p> +<p><strong>Note:</strong> When External Order is created webhook <code>external_order.created</code> is fired and at same time fulfillment is requested +which means <code>external_order.awaiting_fulfillment</code> is also fired. Due to async nature of webhook when you receive +these webhooks most likely order status is <code>awaiting_fulfillment</code> for <code>external_order.created</code> webhook too.</p> <h3 id="signature">Signature</h3> <p>Our webhooks provide a signature so you can verify the payload hasn&#39;t been tampered with. This signature can be found on the header <code>signature</code>.</p> @@ -1047,17 +1048,17 @@

    Rate Limiting

    <h3 id="retries">Retries</h3> <p>If the response status code is not a <code>2xx</code> then we will retry the webhook for 5 attempts with an exponential backoff.</p> ">

    ℹ️ Ankorstore provides a mechanism of webhook notifications to notify you of events that happen on the platform.

    -
    - -

    Please note, that webhook notifications are only available for Internal Orders. -The possibility to subscribe to the External Orders events will be added soon.

    -
    -

    Subscribing

    -

    To subscribe to events please go to the Applications section in your account area.

    +

    There are two ways to manage your webhook subscription on the platform:

    +
      +
    1. Via UI in your Ankorstore account. You can find this functionality in the Private Apps tab of the Integrations section.
    2. +
    3. Directly via API. Find more details in the dedicated Webhoooks section of API specification.
    4. +

    Format

    -

    The webhook payload sent is the same as the resource object provided by the API. For example, if an order.* webhook is fired the resource will be OrderResource.

    -

    The only difference is that within the top level meta object you will receive an event object with details of the webhook which will look like this:

    +

    The webhook payload sent is the same as the resource object provided by the API. For example, if an order.* webhook +is fired the resource will be OrderResource.

    +

    The only difference is that within the top level meta object you will receive an event object with details of the +webhook which will look like this:

    POST https://your-webhook-url.com/webhooks/handle

    {
       "meta": {
    @@ -1096,8 +1097,9 @@ 

    Events

  • external_order.shipped - Order shipped from the warehouse
  • external_order.arrived - Order is arrived and completed
  • -

    NOTE:

    -

    When External Order is created webhook external_order.created is fired and at same time fulfillment is requested which means external_order.awaiting_fulfillment is also fired. Due to async nature of webhook when you receive these webhooks most likely order status is awaiting_fulfillment for external_order.created webhook too.

    +

    Note: When External Order is created webhook external_order.created is fired and at same time fulfillment is requested +which means external_order.awaiting_fulfillment is also fired. Due to async nature of webhook when you receive +these webhooks most likely order status is awaiting_fulfillment for external_order.created webhook too.

    Signature

    Our webhooks provide a signature so you can verify the payload hasn't been tampered with. This signature can be found on the header signature.

    @@ -1160,8 +1162,8 @@

    Creating test data

    " class="sc-iKOmoZ sc-cCzLxZ WVNwY jaVotg">

    Staging Environment

    https://www.public.ankorstore-sandbox.com/api/v1/applications

    Production Environment

    -
    https://www.ankorstore.com/api/v1/applications

    Returns list of existing application for current authenticated user

    +
    https://www.ankorstore.com/api/v1/applications

    List existing application for the current authenticated user

    Authorizations:
    ProductionOAuth2ClientCredentials
    header Parameters
    Accept
    string

    application/vnd.api+json

    Responses

    Response samples

    Content type
    application/vnd.api+json
    {
    • "data": [
      • {
        • "type": "string",
        • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        • "attributes": {
          },
        • "relationships": {
          }
        }
      ],
    • "jsonapi": {
      • "version": "string",
      • "meta": { }
      },
    • "included": [
      • {
        • "type": "string",
        • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        • "attributes": {
          },
        • "relationships": {
          }
        }
      ]
    }

    Webhooks

    ℹ️ This section describes the API endpoints which can be used for managing webhook subscriptions.

    +

    💡 Overview

    In order to be able to manage Webhook Subscriptions via API you should understand the relationship model +around webhook notifications system. In general, a Webhook Subscription always contains a list of chosen events +and always belongs to an application. More on this later.

    +

    Application

    +

    Application is a representation of a single private integration. Whenever you create a new set of credentials for +accessing API in your account, under the hood you create an Application entity. Once created, the entity allows you +to attach as many Webhook Subscriptions as needed. It means, there's no way to manage Webhook Subscriptions outside of +Application context and this restriction is also reflected in the current API architecture.

    +

    Webhook Subscription

    +

    Webhook Subscription is an entity representing "an intent of receiving HTTP requests to the specified URL whenever +one of the chosen Webhook Subscription Events is triggered on the platform". For every new URL you should create a +separate Webhook Subscription.

    +

    Webhook Subscription Events

    +

    Webhook Subscription Event is a name of the corresponding event fired on certain conditions on the platform. There are +a list of only valid and supported events which can be used in the Webhook Subscription management. You can fetch this +list using a corresponding endpoint

    +

    💡 How to create a new webhook subscription?

    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.

    +

    💡 How to manage existing Webhook Subscriptions?

    For most of the operations with an existing Webhook Subscription you need to fetch its ID first. It can be achieved by +using List Applications endpoint and explicit including +the Webhook Subscription resource into the response.

    +

    GET /api/v1/applications?include=webhookSubscription

    +
    {
    +  "data": {
    +    "id": "",
    +    "type": "applications",
    +    "attributes": {},
    +    "relationships": {
    +      "webhookSubscriptions": {
    +        "data": [
    +          {
    +            "type": "webhook-subscriptions",
    +            "id": "a863e15d-3d20-4af2-b92b-d9590a4a9606"
    +          }
    +        ]
    +      }
    +    } 
    +  },
    +  "includes": [
    +    {
    +      "type": "webhook-subscriptions",
    +      "id": "a863e15d-3d20-4af2-b92b-d9590a4a9606",
    +      "attributes": {
    +        "url": "https://my-app.com/webhook-listener",
    +        "events": [
    +          "order.brand_created",
    +          "order.brand_accepted"
    +        ],
    +        "signingSecret": "LQxZs6kiSyNr45hjT32OsntYddzH4BvToLIQcgSL"
    +      }
    +    }
    +  ]
    +}
    +
    +

    The data in this response gives you an idea about the current Webhook Subscription state and also lets you update +or delete Webhook Subscriptions, whenever needed. For updating or deleting Webhook Subscription you need to use the +Webhook Subscription ID received in the response (a863e15d-3d20-4af2-b92b-d9590a4a9606 in this particular case). Please +refer to the Update webhook subscription +and Delete webhook subscription endpoints +for detailed information.

    List Applications

    Returns list of existing application for current authenticated user

    +
    https://www.ankorstore.com/api/v1/applications

    List existing application for the current authenticated user

    Authorizations:
    ProductionOAuth2ClientCredentials
    header Parameters
    Accept
    string

    application/vnd.api+json

    Responses

    Response samples

    Content type
    application/vnd.api+json
    {
    • "data": {
      • "id": "43efbfbd-bfbd-1eef-1e6a-6200efbfbdef",
      • "type": "application",
      • "attributes": {
        • "name": "My sandbox",
        • "developerEmail": "dev@my-app.com",
        • "clientId": "k322k7frs87e8w7hri3jkke7ry7",
        • "clientSecret": null
        }
      },
    • "included": [
      • {
        • "type": "string",
        • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        • "attributes": {}
        }
      ],
    • "jsonapi": {
      • "version": "string",
      • "meta": { }
      }
    }

    Add Webhook Subscription to Application

    List Webhook Subscription Events

    Returns a list of webhook events available in the system

    +
    Authorizations:
    ProductionOAuth2ClientCredentials

    Responses

    Response samples

    Content type
    application/vnd.api+json
    {
    • "data": [
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.brand_created"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.brand_accepted"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipping_labels_generated"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipped"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipment_received"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipment_refused"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.brand_paid"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.cancelled"
        }
      ]
    }

    Add Webhook Subscription to Application

    Request samples

    Content type
    application/vnd.api+json
    {
    • "data": {
      • "type": "webhook-subscription",
      • "attributes": {},
      • "relationships": {
        • "applications": {
          }
        }
      }
    }

    Response samples

    Content type
    application/json
    {
    • "data": [
      • {
        • "type": "string",
        • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        • "attributes": {}
        }
      ],
    • "jsonapi": {
      • "version": "string",
      • "meta": { }
      }
    }

    Update Application Webhook Subscription

    Update Application Webhook Subscription

    Request samples

    Content type
    application/vnd.api+json
    {}

    Response samples

    Content type
    application/json
    {
    • "data": [
      • {
        • "type": "string",
        • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        • "attributes": {}
        }
      ],
    • "jsonapi": {
      • "version": "string",
      • "meta": { }
      }
    }

    Delete Application Webhook Subscription

    Delete Application Webhook Subscription

    Response samples

    Content type
    application/vnd.api+json
    {
    • "jsonapi": {
      • "version": "1.0"
      },
    • "errors": [
      • {
        • "detail": "Unauthorized",
        • "status": "401"
        }
      ]
    }

    Get Webhook Subscription Events

    Returns a list of webhook events available in the system

    -
    Authorizations:
    ProductionOAuth2ClientCredentials

    Responses

    Response samples

    Content type
    application/vnd.api+json
    {
    • "data": [
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.brand_created"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.brand_accepted"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipping_labels_generated"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipped"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipment_received"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.shipment_refused"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.brand_paid"
        },
      • {
        • "type": "webhook-subscriptions/events",
        • "id": "order.cancelled"
        }
      ]
    }

    Testing

    Response samples

    Content type
    application/vnd.api+json
    {
    • "jsonapi": {
      • "version": "1.0"
      },
    • "errors": [
      • {
        • "detail": "Unauthorized",
        • "status": "401"
        }
      ]
    }

    Testing

    Pickup is not accepted " class="sc-iKOmoZ sc-cCzLxZ WVNwY VEBGS sc-ckdEwu LxEPk">

    Unprocessable Entity : Data provided are invalid

    Request samples

    Content type
    application/vnd.api+json
    Example
    {
    • "order": {
      • "trackingProvider": "ups",
      • "trackingNumber": "123456"
      }
    }

    Response samples

    Content type
    application/vnd.api+json
    {
    • "jsonapi": {
      • "version": "1.0"
      },
    • "data": {
      • "type": "order",
      • "id": "1ecb023e-7ec0-6d5c-a477-0242ac170007",
      • "attributes": {
        • "status": "brand_confirmed",
        • "reference": 3434273911,
        • "brandCurrency": "EUR",
        • "brandNetAmount": 10229,
        • "brandTotalAmount": 10940,
        • "brandTotalAmountVat": 602,
        • "brandTotalAmountWithVat": 11542,
        • "brandRejectReason": null,
        • "retailerRejectReason": null,
        • "retailerCancellationRequestReason": null,
        • "billingName": "Charles Attan",
        • "billingOrganisationName": "Jumbo",
        • "billingStreet": "Kortricklaan 101",
        • "billingPostalCode": "8121 GW",
        • "billingCity": "Arnhem",
        • "billingCountryCode": "NL",
        • "submittedAt": "2022-03-17T13:19:33+00:00",
        • "shippedAt": null,
        • "brandPaidAt": null,
        • "createdAt": "2022-02-01T14:37:10+00:00",
        • "updatedAt": "2022-03-31T15:10:07+00:00",
        • "shippingMethod": "custom",
        • "shippingOverview": {
          }
        }
      }
    }