Contents
On this page

Create View - Plugixa FAQ

POST /plugixa-faq/v1/views

Save a new view.

Any signed-in user with the plugixa_faq_edit capability or WordPress’s edit_posts (Contributors and up, by default).

Request

POST https://your-site.example/wp-json/plugixa-faq/v1/views

Request body

Content type: application/json

Field Type Required Description
name string Yes At least 2 characters.
slug string No Made from the name when empty, and then made unique. A slug you send must not be taken already.
description string No Plain text.
config object No The design, in the shape Get View returns. Merged over the defaults, so you can send only the sections you change. layout.style must be a layout available on the site: accordion and list, plus timeline and horizontal with Pro.
is_default boolean No true makes this the default view and clears the flag on the previous one. Defaults to false.
{
  "name": "Support centre",
  "description": "Accordion for the help pages.",
  "config": {
    "layout": {
      "style": "accordion"
    },
    "colors": {
      "accentColor": "#2271b1"
    }
  }
}

Responses

200 OK. data.id is the new view.

{
  "success": true,
  "message": "View created successfully",
  "data": {
    "id": 2
  }
}
Field Type Meaning
data.id integer The new view’s id
message string A human-readable confirmation, translated to the site language

Errors

Status Code When
400 rest_missing_callback_param name is missing.
400 invalid_layout config.layout.style is not available on this site.
400 rest_error “Validation failed”: the name is shorter than 2 characters, or the slug is taken. data.errors names the field.
500 rest_error The database refused the row.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-faq/v1/views" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Support centre","description":"Accordion for the help pages.","config":{"layout":{"style":"accordion"},"colors":{"accentColor":"#2271b1"}}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-faq/v1/views');
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([
        'name'        => 'Support centre',
        'description' => 'Accordion for the help pages.',
        'config'      => [
            'layout' => [
                'style' => 'accordion',
            ],
            'colors' => [
                'accentColor' => '#2271b1',
            ],
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-faq/v1/views', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Support centre', description: 'Accordion for the help pages.', config: { layout: { style: 'accordion' }, colors: { accentColor: '#2271b1' } } }),
});
const { data } = await response.json();

Quick Links

Share