Creating Redirect Links
Create and update shoppable redirect links for recipes. Send the ingredient lines as you would print them; we parse and match them and return a stable redirect link.
Create your first link
Send the recipe name, yields and ingredient lines exactly as you would print them. We parse the ingredients, match them to supermarket products and host the complete basket flow.
name- The recipe name, for example "Pasta with tomato sauce". Required.
yields- The servings text, for example "4 persons". Optional; leave it out for a plain product list.
ingredients- Array of 1 to 100 ingredient lines as you would print them, for example "400 g spaghetti".
locale- The language of the text you send:
nl,en,deorfr. Optional; defaults to your account language.
curl -X POST https://api.tobasket.com/api/v1/anyToBasket/redirectLinks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Pasta with tomato sauce",
"yields": "4 persons",
"ingredients": [
"400 g spaghetti",
"500 g tomatoes",
"1 onion",
"2 cloves garlic",
"2 tbsp olive oil"
],
"locale": "en"
}'The response contains the token and the redirect link (returned as <code>redirectUrl</code>) to place behind your buy button. The visitor is never forwarded during this API call.
{
"data": {
"token": "kJ8sP2qLm4Xz",
"redirectUrl": "https://any.tobasket.com/to/kJ8sP2qLm4Xz",
"supportedQueryParameters": {
"supermarket": {
"description": "Preselect a supermarket so the visitor skips the chooser.",
"values": ["albert-heijn", "jumbo", "rewe"]
},
"preferences": {
"description": "Pre-enable widget preferences: organic, premium (Albert Heijn only).",
"values": ["organic", "premium"]
},
"yields": { "description": "Scale the recipe to this number of servings.", "type": "number" }
},
"examples": [
"https://any.tobasket.com/to/kJ8sP2qLm4Xz?supermarket=jumbo",
"https://any.tobasket.com/to/kJ8sP2qLm4Xz?supermarket=jumbo&yields=6"
]
}
}Multiple languages
If your audience spans languages, every translatable field, the name, yields and each ingredient line, also accepts an object keyed by locale code (nl, en, de, fr) instead of a plain string. Send the languages you have and we serve each visitor the best match:
curl -X POST https://api.tobasket.com/api/v1/anyToBasket/redirectLinks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": { "nl": "Pasta met tomatensaus", "en": "Pasta with tomato sauce" },
"yields": { "nl": "4 personen", "en": "4 persons" },
"ingredients": [
{ "nl": "400 g spaghetti", "en": "400 g spaghetti" },
{ "nl": "500 g tomaten", "en": "500 g tomatoes" }
]
}'Once a link carries multiple languages, append a locale query parameter to its URL, for example ?locale=nl, to render a specific one (limited to the languages you sent). Without it we serve each visitor the best match.
Update a redirect link
Send a PATCH with the same payload shape to update the data behind a token, for example after correcting translations. Every field you provide is fully replaced: providing ingredients replaces all ingredient lines, providing name replaces all name translations. Fields you leave out stay untouched. The token and redirect link never change.
curl -X PATCH https://api.tobasket.com/api/v1/anyToBasket/redirectLinks/kJ8sP2qLm4Xz \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Pasta with fresh tomato sauce"
}'Creating is not idempotent: posting the same recipe twice creates two independent links. Store the token you receive and use PATCH for every correction.
Errors
Validation failed, for example an unknown locale code, more than 100 ingredient lines, or a missing name. The response body lists the failing fields.
{
"message": "The ingredients field is required.",
"errors": {
"ingredients": ["The ingredients field is required."]
}
}PATCH with a token that does not exist or does not belong to your account.
{
"message": "Redirect Link could not be found."
}