Contents
On this page

Add Recipe to Collection - Plugixa Recipe

POST /plugixa-recipe/v1/collections/{id}/recipes

Add a recipe at the end of a collection; in a meal plan, on a given day and meal.

Needs the plugixa_recipe_edit capability, or WordPress’s edit_posts (Contributor and up). Needs Plugixa Recipe Pro with the Collections app on.

Note. Nothing stops the same recipe being added twice unless both day_number and meal_type are set: the duplicate check never fires in a plain collection or cookbook, nor in a meal plan entry without a day and a meal. Check List Collection Recipes first.

Request

POST https://your-site.example/wp-json/plugixa-recipe/v1/collections/4/recipes

Path parameters

Name Type Description
id integer The collection’s id

Request body

Content type: application/json

Field Type Required Description
recipe_id integer Yes An existing recipe, in any status.
day_number integer No Meal plans only: the day.
meal_type string No Meal plans only: the meal, such as breakfast.

On other collection types day_number and meal_type are ignored.

{
  "recipe_id": 12,
  "day_number": 1,
  "meal_type": "breakfast"
}

Responses

200 OK. data is the entry that was added.

{
  "success": true,
  "message": "Recipe added to collection.",
  "data": {
    "collection_id": 4,
    "recipe_id": 12,
    "display_order": 2,
    "added_at": "2026-11-12 09:40:00",
    "day_number": 1,
    "meal_type": "breakfast"
  }
}
Field Type Meaning
data.display_order integer Its position: one after the last entry
data.day_number, data.meal_type integer, string Only present for a meal plan when sent

Errors

Status Code When
400 rest_error recipe_id is missing.
404 rest_error No collection with that id.
404 rest_error No recipe with that id.
400 rest_error The entry already exists (same recipe, day and meal) or could not be written.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-recipe/v1/collections/4/recipes" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"recipe_id":12}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-recipe/v1/collections/4/recipes');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'recipe_id' => 12,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-recipe/v1/collections/4/recipes', {
  method: 'POST',
  headers: {
    'Authorization': auth,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"recipe_id": 12}),
});
const { data } = await response.json();

Quick Links

Share