Contents
On this page
Update Recipe Status - Plugixa Recipe
PATCH /plugixa-recipe/v1/recipes/{id}/status
Set only the status of a recipe.
Needs the plugixa_recipe_edit capability, or WordPress’s edit_posts (Contributor and up). When the request moves the recipe into or out of published, it also needs plugixa_recipe_publish or WordPress’s publish_posts (Author and up). Moving between draft, pending and archived does not.
Request
PATCH https://your-site.example/wp-json/plugixa-recipe/v1/recipes/12/status
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The recipe’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
status |
string |
Yes | draft, pending, published or archived, lower case exactly. |
Moving the recipe to published from another status sets published_at to now. No required-field check runs here.
{
"status": "archived"
}
Responses
200 OK. data echoes the new status.
{
"success": true,
"message": "Status updated.",
"data": {
"id": 12,
"status": "archived"
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The recipe’s id |
data.status |
string |
The status now stored |
Errors
| Status | Code | When |
|---|---|---|
400 |
rest_error |
status is missing or not one of the four values. |
404 |
rest_error |
No recipe with that id. |
403 |
rest_forbidden |
The change publishes the recipe or takes it down, and you lack the publish capability. |
Plus the errors every endpoint can return.
Examples
curl -s -X PATCH "https://your-site.example/wp-json/plugixa-recipe/v1/recipes/12/status" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"status":"archived"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-recipe/v1/recipes/12/status');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'status' => 'archived',
]),
]);
$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/recipes/12/status', {
method: 'PATCH',
headers: {
'Authorization': auth,
'Content-Type': 'application/json',
},
body: JSON.stringify({"status": "archived"}),
});
const { data } = await response.json();
Quick Links
Share