Strategy

This document focuses on the strategy API within the recommendation module. The products recommended by the strategy API depend on the configured strategy, allowing customers to adjust the recommendation capabilities directly in the admin without coding.

To use the strategy API capability, you must first create a rule here and get the strategy ID. And then you can just edit the strategy in the admin. AfterShip Personalization Strategies page with the Create rule button and Strategy 18's ID 00018 highlighted in the table

After getting the ID, we copy it and use it as a parameter named strategy_id

In the sample request outlined below, we’ve initiated a request to the AfterShip Personalization API to fetch recommendations using the STRATEGY type. The request includes the following parameters:

  • type: Specifies the type of recommendations, which in this case is set to STRATEGY.

  • session_id: Represents the unique identifier for the user session.

  • strategy_id: The rule id we’ve created

  • limit: Determines the maximum number of products to be returned in the response. In this example, the limit is set to 5.

Sample Request

curl 'https://api.aftership.com/personalization/2025-04/discoveries/recommend' \ --header 'Content-Type: application/json' \ --header 'as-store-id: your commerce store id' \ --header 'as-api-key: your API key' \ --data '{ "type": "STRATEGY", "session_id": "47be3249-c1f4-446d-b652-8749be6ed577", "strategy_id": "00018" "limit": 5 }'

By providing these parameters in the request, the API will generate a curated list of the products based on rule

Sample Response

{ "meta": { "code": 200, "type": "OK", "message": "Everything worked as expected." }, "data": { "products": [ { "id": "51e2fb9bc14847c5a82f049558019b12", "source_id": "a5ffb83f38fb4a6f94d33616dea0e6a0", "variants": [ { "source_id": "893576488aca4967a677194598d7fc95" } ] }, { "id": "d8192616ec3c41b3805070d653d37aad", "source_id": "4dcaa564aa85426480d2c4b01df8db56", "variants": [ { "source_id": "311381827b1243a18a2bdd44ebad1a41" } ] }, { "id": "b1d821b2e47c430c885ce7ea42073dcb", "source_id": "afc4ee14858b45349c74c66a25ddf54f", "variants": [ { "source_id": "1ec8af67ca7d417bb056e77858611857" } ] }, { "id": "7dfd6d5466004ebaac811c37045f67c4", "source_id": "793544852ad942ffaee1c15dcf8383f8", "variants": [ { "source_id": "eacce30b115e436296b6e1cbba6c8508" } ] }, { "id": "1e09a77a0138425a831266a11727cee1", "source_id": "00093d19495447a2a082bfe44d75658a", "variants": [ { "source_id": "00b0a1e329cf4ecc861136ed0ab94fc2" } ] } ] } }