Create Dispatch Strategy
POST {{BASE_HABITAT_URL}}/api/v3/strategies
Required scope: strategies:write
Strategies allow you to configure ranked preferences for which DSPs should receive an order, based on several parameters. Our algorithm determines the strategy based on this order:
- Which Merchant the order is for
- Which Territory the order is in (If no merchant-specific Strategy is set)
- Ranked by either cheapest price or fastest delivery time
- Banned DSPs filtered out
- Preferred DSPs bumped to top
We then use this ranked list to request the delivery from the top down (i_.e in the case that the ‘top’ DSP rejects the order, we move to the next one)_
Creating a Strategy is currently not available via API - go to your Dispatch Settings to configure DSP routing strategies on a per-territory and per-merchant basis
Request body
Section titled “Request body”{ "strategy": { "tie_breaker": "cheapest", "name": "Cheapest test", "default": true }, "strategy_providers": [ { "name": "relay", "type": "ban", "index": 0 } ]}Examples
Section titled “Examples”curl --request POST '${BASE_HABITAT_URL}/api/v3/strategies' \ --data '{ "strategy": { "tie_breaker": "cheapest", "name": "Cheapest test", "default": true }, "strategy_providers": [ { "name": "relay", "type": "ban", "index": 0 } ]}'const response = await fetch("${BASE_HABITAT_URL}/api/v3/strategies", { "method": "POST", "headers": {}, "body": "{\n \"strategy\": {\n \"tie_breaker\": \"cheapest\",\n \"name\": \"Cheapest test\",\n \"default\": true\n },\n \"strategy_providers\": [\n {\n \"name\": \"relay\",\n \"type\": \"ban\",\n \"index\": 0\n }\n ]\n}"})const data = await response.json()import requests
response = requests.request( "POST", "${BASE_HABITAT_URL}/api/v3/strategies", headers={}, data="{\n \"strategy\": {\n \"tie_breaker\": \"cheapest\",\n \"name\": \"Cheapest test\",\n \"default\": true\n },\n \"strategy_providers\": [\n {\n \"name\": \"relay\",\n \"type\": \"ban\",\n \"index\": 0\n }\n ]\n}",)response.raise_for_status()Saved responses
Section titled “Saved responses”{ "type": "success", "data": { "strategies": [ { "id": "3390e635-d510-4f51-b809-513db03d2e76", "operator_id": 1, "default": true, "tie_breaker": "cheapest", "name": "Default (Cheapest)" } ], "strategy_providers": [], "providers": [ "doordash", "uber", "ally", "relay", "cutcats", "quickness" ] }}
