Skip to main content
POST
/
api
/
public
/
strategy
/
evaluate
Evaluate Strategy
curl --request POST \
  --url https://start.aftersell.app/api/public/strategy/evaluate \
  --header 'Content-Type: application/json' \
  --header 'X-Strategy-Api-Key: <api-key>' \
  --data '
{
  "shopDomain": "<string>",
  "strategyId": "<string>",
  "context": {
    "products": [
      {
        "productId": "<string>",
        "variantId": "<string>",
        "quantity": 1,
        "price": 1,
        "handle": "<string>",
        "title": "<string>",
        "vendor": "<string>",
        "productType": "<string>",
        "tags": [
          "<string>"
        ],
        "collections": [
          "<string>"
        ],
        "metafields": [
          {
            "namespace": "<string>",
            "key": "<string>",
            "value": "<string>"
          }
        ]
      }
    ],
    "cartToken": "<string>",
    "checkoutToken": "<string>",
    "sessionId": "<string>",
    "cart": {
      "subtotal": 1,
      "itemCount": 1,
      "lineCount": 1,
      "attributes": {},
      "notes": "<string>"
    },
    "customer": {
      "customerId": "<string>",
      "tags": [
        "<string>"
      ],
      "countryCode": "<string>",
      "provinceCode": "<string>",
      "locale": "<string>",
      "orderCount": 1,
      "totalSpent": 1,
      "acceptsMarketing": true
    },
    "session": {
      "utmSource": "<string>",
      "utmMedium": "<string>",
      "utmCampaign": "<string>",
      "utmContent": "<string>",
      "utmTerm": "<string>",
      "currencyCode": "<string>",
      "shippingCountryCode": "<string>",
      "shippingProvinceCode": "<string>",
      "shippingMethod": "<string>"
    }
  }
}
'
import requests

url = "https://start.aftersell.app/api/public/strategy/evaluate"

payload = {
    "shopDomain": "<string>",
    "strategyId": "<string>",
    "context": {
        "products": [
            {
                "productId": "<string>",
                "variantId": "<string>",
                "quantity": 1,
                "price": 1,
                "handle": "<string>",
                "title": "<string>",
                "vendor": "<string>",
                "productType": "<string>",
                "tags": ["<string>"],
                "collections": ["<string>"],
                "metafields": [
                    {
                        "namespace": "<string>",
                        "key": "<string>",
                        "value": "<string>"
                    }
                ]
            }
        ],
        "cartToken": "<string>",
        "checkoutToken": "<string>",
        "sessionId": "<string>",
        "cart": {
            "subtotal": 1,
            "itemCount": 1,
            "lineCount": 1,
            "attributes": {},
            "notes": "<string>"
        },
        "customer": {
            "customerId": "<string>",
            "tags": ["<string>"],
            "countryCode": "<string>",
            "provinceCode": "<string>",
            "locale": "<string>",
            "orderCount": 1,
            "totalSpent": 1,
            "acceptsMarketing": True
        },
        "session": {
            "utmSource": "<string>",
            "utmMedium": "<string>",
            "utmCampaign": "<string>",
            "utmContent": "<string>",
            "utmTerm": "<string>",
            "currencyCode": "<string>",
            "shippingCountryCode": "<string>",
            "shippingProvinceCode": "<string>",
            "shippingMethod": "<string>"
        }
    }
}
headers = {
    "X-Strategy-Api-Key": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {'X-Strategy-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    shopDomain: '<string>',
    strategyId: '<string>',
    context: {
      products: [
        {
          productId: '<string>',
          variantId: '<string>',
          quantity: 1,
          price: 1,
          handle: '<string>',
          title: '<string>',
          vendor: '<string>',
          productType: '<string>',
          tags: ['<string>'],
          collections: ['<string>'],
          metafields: [{namespace: '<string>', key: '<string>', value: '<string>'}]
        }
      ],
      cartToken: '<string>',
      checkoutToken: '<string>',
      sessionId: '<string>',
      cart: {subtotal: 1, itemCount: 1, lineCount: 1, attributes: {}, notes: '<string>'},
      customer: {
        customerId: '<string>',
        tags: ['<string>'],
        countryCode: '<string>',
        provinceCode: '<string>',
        locale: '<string>',
        orderCount: 1,
        totalSpent: 1,
        acceptsMarketing: true
      },
      session: {
        utmSource: '<string>',
        utmMedium: '<string>',
        utmCampaign: '<string>',
        utmContent: '<string>',
        utmTerm: '<string>',
        currencyCode: '<string>',
        shippingCountryCode: '<string>',
        shippingProvinceCode: '<string>',
        shippingMethod: '<string>'
      }
    }
  })
};

fetch('https://start.aftersell.app/api/public/strategy/evaluate', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://start.aftersell.app/api/public/strategy/evaluate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'shopDomain' => '<string>',
    'strategyId' => '<string>',
    'context' => [
        'products' => [
                [
                                'productId' => '<string>',
                                'variantId' => '<string>',
                                'quantity' => 1,
                                'price' => 1,
                                'handle' => '<string>',
                                'title' => '<string>',
                                'vendor' => '<string>',
                                'productType' => '<string>',
                                'tags' => [
                                                                '<string>'
                                ],
                                'collections' => [
                                                                '<string>'
                                ],
                                'metafields' => [
                                                                [
                                                                                                                                'namespace' => '<string>',
                                                                                                                                'key' => '<string>',
                                                                                                                                'value' => '<string>'
                                                                ]
                                ]
                ]
        ],
        'cartToken' => '<string>',
        'checkoutToken' => '<string>',
        'sessionId' => '<string>',
        'cart' => [
                'subtotal' => 1,
                'itemCount' => 1,
                'lineCount' => 1,
                'attributes' => [
                                
                ],
                'notes' => '<string>'
        ],
        'customer' => [
                'customerId' => '<string>',
                'tags' => [
                                '<string>'
                ],
                'countryCode' => '<string>',
                'provinceCode' => '<string>',
                'locale' => '<string>',
                'orderCount' => 1,
                'totalSpent' => 1,
                'acceptsMarketing' => true
        ],
        'session' => [
                'utmSource' => '<string>',
                'utmMedium' => '<string>',
                'utmCampaign' => '<string>',
                'utmContent' => '<string>',
                'utmTerm' => '<string>',
                'currencyCode' => '<string>',
                'shippingCountryCode' => '<string>',
                'shippingProvinceCode' => '<string>',
                'shippingMethod' => '<string>'
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "X-Strategy-Api-Key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://start.aftersell.app/api/public/strategy/evaluate"

	payload := strings.NewReader("{\n  \"shopDomain\": \"<string>\",\n  \"strategyId\": \"<string>\",\n  \"context\": {\n    \"products\": [\n      {\n        \"productId\": \"<string>\",\n        \"variantId\": \"<string>\",\n        \"quantity\": 1,\n        \"price\": 1,\n        \"handle\": \"<string>\",\n        \"title\": \"<string>\",\n        \"vendor\": \"<string>\",\n        \"productType\": \"<string>\",\n        \"tags\": [\n          \"<string>\"\n        ],\n        \"collections\": [\n          \"<string>\"\n        ],\n        \"metafields\": [\n          {\n            \"namespace\": \"<string>\",\n            \"key\": \"<string>\",\n            \"value\": \"<string>\"\n          }\n        ]\n      }\n    ],\n    \"cartToken\": \"<string>\",\n    \"checkoutToken\": \"<string>\",\n    \"sessionId\": \"<string>\",\n    \"cart\": {\n      \"subtotal\": 1,\n      \"itemCount\": 1,\n      \"lineCount\": 1,\n      \"attributes\": {},\n      \"notes\": \"<string>\"\n    },\n    \"customer\": {\n      \"customerId\": \"<string>\",\n      \"tags\": [\n        \"<string>\"\n      ],\n      \"countryCode\": \"<string>\",\n      \"provinceCode\": \"<string>\",\n      \"locale\": \"<string>\",\n      \"orderCount\": 1,\n      \"totalSpent\": 1,\n      \"acceptsMarketing\": true\n    },\n    \"session\": {\n      \"utmSource\": \"<string>\",\n      \"utmMedium\": \"<string>\",\n      \"utmCampaign\": \"<string>\",\n      \"utmContent\": \"<string>\",\n      \"utmTerm\": \"<string>\",\n      \"currencyCode\": \"<string>\",\n      \"shippingCountryCode\": \"<string>\",\n      \"shippingProvinceCode\": \"<string>\",\n      \"shippingMethod\": \"<string>\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Strategy-Api-Key", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://start.aftersell.app/api/public/strategy/evaluate")
  .header("X-Strategy-Api-Key", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"shopDomain\": \"<string>\",\n  \"strategyId\": \"<string>\",\n  \"context\": {\n    \"products\": [\n      {\n        \"productId\": \"<string>\",\n        \"variantId\": \"<string>\",\n        \"quantity\": 1,\n        \"price\": 1,\n        \"handle\": \"<string>\",\n        \"title\": \"<string>\",\n        \"vendor\": \"<string>\",\n        \"productType\": \"<string>\",\n        \"tags\": [\n          \"<string>\"\n        ],\n        \"collections\": [\n          \"<string>\"\n        ],\n        \"metafields\": [\n          {\n            \"namespace\": \"<string>\",\n            \"key\": \"<string>\",\n            \"value\": \"<string>\"\n          }\n        ]\n      }\n    ],\n    \"cartToken\": \"<string>\",\n    \"checkoutToken\": \"<string>\",\n    \"sessionId\": \"<string>\",\n    \"cart\": {\n      \"subtotal\": 1,\n      \"itemCount\": 1,\n      \"lineCount\": 1,\n      \"attributes\": {},\n      \"notes\": \"<string>\"\n    },\n    \"customer\": {\n      \"customerId\": \"<string>\",\n      \"tags\": [\n        \"<string>\"\n      ],\n      \"countryCode\": \"<string>\",\n      \"provinceCode\": \"<string>\",\n      \"locale\": \"<string>\",\n      \"orderCount\": 1,\n      \"totalSpent\": 1,\n      \"acceptsMarketing\": true\n    },\n    \"session\": {\n      \"utmSource\": \"<string>\",\n      \"utmMedium\": \"<string>\",\n      \"utmCampaign\": \"<string>\",\n      \"utmContent\": \"<string>\",\n      \"utmTerm\": \"<string>\",\n      \"currencyCode\": \"<string>\",\n      \"shippingCountryCode\": \"<string>\",\n      \"shippingProvinceCode\": \"<string>\",\n      \"shippingMethod\": \"<string>\"\n    }\n  }\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://start.aftersell.app/api/public/strategy/evaluate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Strategy-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"shopDomain\": \"<string>\",\n  \"strategyId\": \"<string>\",\n  \"context\": {\n    \"products\": [\n      {\n        \"productId\": \"<string>\",\n        \"variantId\": \"<string>\",\n        \"quantity\": 1,\n        \"price\": 1,\n        \"handle\": \"<string>\",\n        \"title\": \"<string>\",\n        \"vendor\": \"<string>\",\n        \"productType\": \"<string>\",\n        \"tags\": [\n          \"<string>\"\n        ],\n        \"collections\": [\n          \"<string>\"\n        ],\n        \"metafields\": [\n          {\n            \"namespace\": \"<string>\",\n            \"key\": \"<string>\",\n            \"value\": \"<string>\"\n          }\n        ]\n      }\n    ],\n    \"cartToken\": \"<string>\",\n    \"checkoutToken\": \"<string>\",\n    \"sessionId\": \"<string>\",\n    \"cart\": {\n      \"subtotal\": 1,\n      \"itemCount\": 1,\n      \"lineCount\": 1,\n      \"attributes\": {},\n      \"notes\": \"<string>\"\n    },\n    \"customer\": {\n      \"customerId\": \"<string>\",\n      \"tags\": [\n        \"<string>\"\n      ],\n      \"countryCode\": \"<string>\",\n      \"provinceCode\": \"<string>\",\n      \"locale\": \"<string>\",\n      \"orderCount\": 1,\n      \"totalSpent\": 1,\n      \"acceptsMarketing\": true\n    },\n    \"session\": {\n      \"utmSource\": \"<string>\",\n      \"utmMedium\": \"<string>\",\n      \"utmCampaign\": \"<string>\",\n      \"utmContent\": \"<string>\",\n      \"utmTerm\": \"<string>\",\n      \"currencyCode\": \"<string>\",\n      \"shippingCountryCode\": \"<string>\",\n      \"shippingProvinceCode\": \"<string>\",\n      \"shippingMethod\": \"<string>\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
{ "success": true, "products": [ { "productId": "<string>", "handle": "<string>", "title": "<string>", "vendor": "<string>", "productType": "<string>", "price": "<string>", "compareAtPrice": "<string>", "availableForSale": true, "description": "<string>", "url": "<string>", "tags": [ "<string>" ], "collectionIds": [ "<string>" ], "images": [ { "src": "<string>", "altText": "<string>", "position": 123 } ], "variants": [ { "variantId": "<string>", "title": "<string>", "price": "<string>", "compareAtPrice": "<string>", "availableForSale": true, "sku": "<string>", "selectedOptions": [ { "name": "<string>", "value": "<string>" } ] } ] } ], "evaluationId": "<string>", "resolution": { "strategyId": "<string>", "matchedRuleIds": [ "<string>" ], "selectionMethod": "<string>", "fallbackUsed": true }, "meta": { "servedFromCache": true, "processingTimeMs": 123, "data": {}, "explanation": "<string>" }, "errors": [ { "code": "<string>", "message": "<string>" } ] }

Authorizations

X-Strategy-Api-Key
string
header
required

Body

application/json
shopDomain
string
required

Your store's permanent domain

strategyId
string
required

The strategy ID to evaluate (a single 24-char hex MongoDB ObjectId)

context
object
required

Response

Evaluation successful

success
boolean

Whether the evaluation succeeded

products
object[]

Fully enriched recommended products

evaluationId
string

Unique identifier for this evaluation. Echo it back as a line item property (e.g. __as_offer_id) when a shopper adds a recommended product, so the resulting order attributes back to this specific evaluation in AfterSell reporting. Present on successful evaluations; absent on error responses that short-circuit before evaluation.

resolution
object
meta
object
errors
object[]

Present only when errors occur