Contents
On this page

Import FAQs - Plugixa FAQ

POST /plugixa-faq/v1/faqs/import

Create FAQs from a JSON or CSV file, sent Base64-encoded in the body.

Administrators only: the user needs the plugixa_faq_settings capability or WordPress’s manage_options.

Note. Import always creates new FAQs: it never updates existing ones, even when a row carries an id. Importing an export back into the same site duplicates every FAQ (their slugs get -1, -2, …). A row with no valid status is imported as published, unlike Create FAQ, which defaults to draft.

Request

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

Request body

Content type: application/json

Field Type Required Description
content string Yes The whole file, Base64-encoded.
format string No csv, or json (the default; any other value is read as JSON).
create_categories boolean No Defaults to true: a category_name with no matching category creates one. With false the FAQ is imported without a category.

A JSON file is either the export format (an object with a faqs list) or a plain list of FAQ objects. A CSV file needs a header row with at least question and answer columns; header names are matched without regard to case.

Columns read from each row: question and answer (required, a row missing either is skipped), category_name (matched to an existing category by name, ignoring case), slug, status, menu_order, visibility, author_alias, language_code and translation_group (with WPML or Polylang active), and id with parent_id, used only to rebuild nesting between rows of the same file. image_url is ignored.

{
  "format": "csv",
  "content": "cXVlc3Rpb24sYW5zd2VyLGNhdGVnb3J5X25hbWUK",
  "create_categories": true
}

Responses

200 OK. The counts of what happened.

{
  "success": true,
  "message": "Imported 2 FAQs successfully",
  "data": {
    "imported": 2,
    "skipped": 1,
    "errors": [
      "Row 3: Missing question or answer"
    ],
    "created_categories": [
      "Returns"
    ]
  }
}
Field Type Meaning
data.imported integer FAQs created
data.skipped integer Rows not imported
data.errors string[] One message per skipped row, numbered from 1 (the CSV header is not counted)
data.created_categories string[] Names of categories the import created

Errors

Status Code When
400 rest_error “No import data provided” (content empty), “Invalid file content”, or “No FAQs found in import data”.
400 invalid_csv The CSV has no header row or no data row.
400 missing_columns The CSV header has no question or no answer column.
400 invalid_json The file is not valid JSON.
400 invalid_format The JSON is neither an object with a faqs list nor a list of objects.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-faq/v1/faqs/import" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"format":"csv","content":"cXVlc3Rpb24sYW5zd2VyLGNhdGVnb3J5X25hbWUK","create_categories":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-faq/v1/faqs/import');
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([
        'format'            => 'csv',
        'content'           => 'cXVlc3Rpb24sYW5zd2VyLGNhdGVnb3J5X25hbWUK',
        'create_categories' => true,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-faq/v1/faqs/import', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ format: 'csv', content: 'cXVlc3Rpb24sYW5zd2VyLGNhdGVnb3J5X25hbWUK', create_categories: true }),
});
const { data } = await response.json();

Quick Links

Share