API ReferenceREST API

REST API

Reference documentation for the eBook Product Assistant REST API endpoints.

Overview

The eBook Product Assistant exposes several REST API endpoints under the ebook-assistant/v1 namespace. These endpoints power the admin interface but can also be consumed by custom integrations or headless applications.

All endpoints require authentication and verify that the user possesses the required capability (default: manage_woocommerce). Requests must include a valid WordPress nonce via the X-WP-Nonce header.


Endpoints

Analyze a Single PDF

POST /wp-json/ebook-assistant/v1/analyze-pdf

Extracts text from an uploaded PDF, summarizes it, and generates a product draft using the configured AI provider.

Parameters:

  • pdf (file, required): The PDF file upload.
  • targeting_notes (string, optional): Context notes to guide the AI generation.

Response: Returns a JSON object containing the extraction metrics, summary, WooCommerce context (pricing stats, similar products), and the generated draft data.


Create a Product Draft

POST /wp-json/ebook-assistant/v1/create-draft

Creates a WooCommerce draft product from validated payload data.

Parameters (JSON):

  • title (string, required): Product title (max 200 chars).
  • short_description (string, optional): Product short description.
  • long_description (string, optional): Product long description.
  • regular_price (string, optional): Product price.
  • category_ids (array of ints, optional): Array of WooCommerce category IDs.
  • tags (string, optional): Comma-separated list of existing tag names.
  • downloadable (boolean, optional): Whether the product is downloadable.
  • attach_pdf_download (boolean, optional): Whether to attach the source PDF.
  • source_file_token (string, optional): The opaque token returned from /analyze-pdf required to attach the file.
  • sample_pages (string, optional): Comma-separated page numbers for image generation.

Response: Returns the ID and edit URL of the created WooCommerce draft product.


Enqueue a Batch

POST /wp-json/ebook-assistant/v1/batch-analyze

Uploads multiple PDFs and stages them for batch processing.

Parameters:

  • pdfs[] (file array, required): Multiple PDF file uploads.
  • targeting_notes (string, optional): Context notes applied to all files.
  • batch_options (string, optional): JSON string containing options like force_reprocess.

Response: Returns the batch_id, the list of staged files, and the estimated AI cost.


Process Next Batch File

POST /wp-json/ebook-assistant/v1/batch-process/{batch_id}

Processes the next pending file in the specified batch. Used for manual polling when Action Scheduler is unavailable.

Response: Returns the processing result or indicates if the batch is complete.


Get Batch Status

GET /wp-json/ebook-assistant/v1/batch-status/{batch_id}

Retrieves the current progress, status, and file summaries for a specific batch.

Response: Returns the batch metadata, progress counts, and an array of file records.


Bulk Create Drafts

POST /wp-json/ebook-assistant/v1/bulk-create-drafts

Creates WooCommerce drafts for all successfully analyzed files in a batch.

Parameters (JSON):

  • batch_id (string, required): The ID of the batch.
  • downloadable (boolean, optional): Apply to all created drafts.
  • attach_pdf_download (boolean, optional): Apply to all created drafts.

Response: Returns an array of created product IDs and any errors encountered.


Get Global Queue

GET /wp-json/ebook-assistant/v1/batch-queue

Retrieves a list of batch items owned by the current user across all batches.

Parameters:

  • filter (string, optional): Filter by status (e.g., processing, failed).

Response: Returns an array of queue items and a boolean indicating if Action Scheduler is enabled.


Cancel Batch

POST /wp-json/ebook-assistant/v1/batch-cancel/{batch_id}

Cancels pending Action Scheduler jobs and clears the cron lock for a batch.

Response: Returns confirmation of cancellation.