Safely read and change a FreshStore affiliate site through its Site API, covering products, articles, redirects, click analytics and product feeds.
86%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Medium
Suggest reviewing before use
Scope for redirects: settings:read to list, settings:write to create or delete. The AI assistant key presets leave settings out, so ask the user for a key with it.
fsapi GET "/redirects?per_page=100&page=1"
fsapi GET "/redirects?per_page=100&hide_automatic=true" # hide ones the site made on slug changesThis list has no links.next. Page on until page * per_page reaches meta.total.
Each redirect has a status:
status | Meaning | Usual fix |
|---|---|---|
active | Working | Nothing |
waiting | The old page is still live, so the redirect does not fire | Re-create it with "switch_off_source": true (switches the old page off; confirm with the user) |
broken | The new address does not work | Point it at a live page |
Before you pick a new target, check the target answers: curl -sS -o /dev/null -w "%{http_code}" -A "FreshStoreAgentSkill/1.0" "$FRESHSTORE_SITE_URL/categories/new-home".
fsapi POST /redirects -d '{"from": "/products/old-thing", "to": "/products/new-thing"}'
# A waiting redirect: also switch the old page off (after a yes)
fsapi POST /redirects -d '{"from": "/products/old-thing", "to": "/products/new-thing", "switch_off_source": true}'from and to take a full URL, a path or a slug. A second redirect from the same address replaces the first. The homepage cannot be redirected.
Show the user the full list and get a yes first.
fsapi POST /redirects/bulk -d '{"redirects": [
{"from": "/products/a", "to": "/categories/new-home"},
{"from": "/products/b", "to": "/categories/new-home"}
]}'1 to 500 rows, each with from, to and optional switch_off_source. Each row is checked on its own; failures come back with their index and error, and the good rows still save. Over 50 rows the call is queued: it answers 202 with an id; read the outcome with GET /redirects/bulk/{id} until status is done or failed.
DELETE /redirects/{id} returns 204. Confirm first: the old URL will 404 again.
POST /api/store/retire-catalogue switches off a whole set of products, categories, articles and brands and redirects every old URL in one call. Nothing is deleted; everything can be switched back on. It needs a Full Access key (or the broad Write box with no per-resource boxes).
It is a dry run unless you send "dry_run": false. Always run the dry run first and show the user the counts and sample URLs.
# 1. Dry run
fsapi POST /store/retire-catalogue -d '{
"category_ids": [14, 15],
"redirect_to": "/categories/beach-gear",
"redirect_map": {"15": "/categories/sun-care"}
}'Send exactly one scope: category_ids, product_ids or created_before. include limits it to some of products, categories, articles, brands (default all). Check every target answers first, and is not inside the scope being retired. Each retired URL goes to its redirect_map entry (by category id or slug, or the nearest parent with one), else to redirect_to. A URL with no target gets no redirect (no_target in the counts).
# 2. Only after the user says yes to the dry run numbers
fsapi POST /store/retire-catalogue -d '{ ...same body..., "dry_run": false }'
# -> 202 {"data": {"id": "...", "status": "queued", ...}}
# 3. Follow it
fsapi GET /store/retire-catalogue/{id}status goes queued, running, then done, partial or failed. failed changed nothing. partial switched the catalog off and wrote redirects, then a later step stopped: run fsapi POST /store/clear-cache to refresh the site. Results are kept for a week.
The API refuses (422) a scope that would retire every product or every category with no redirect target, and a target that this same call retires.