Guide

Print Engine REST API

Custom REST routes for PDF generation, PDF status, and element screenshots.

Base path: /wp-json/prc-print-engine/v1

Auth summary

AccessRoutes
edit_post for target postPOST /posts/{id}/generate-pdf, GET /posts/{id}/pdf
edit_postsPOST /screenshot

POST /posts/{id}/generate-pdf

Force-schedules PDF generation for the resolved PDF owner post.

Permission: current_user_can( 'edit_post', $id ) (and for the resolved owner).

Request POST /wp-json/prc-print-engine/v1/posts/123/generate-pdf
HeadersKey: value
Accept application/json
Response 200 OK
BodyJSON
{
  "scheduled": true,
  "postId": 123,
  "attachmentId": 0,
  "url": "",
  "generatedAt": "",
  "configured": true,
  "pending": true
}

Errors

CodeStatusMeaning
not_found404Post missing
forbidden403Cannot edit owner post
ineligible400Not published/public or type lacks print support
service_not_configured503Firebase render endpoints missing
action_scheduler_unavailable503Action Scheduler not loaded

GET /posts/{id}/pdf

Returns stored PDF status for the post (resolves report owner when applicable).

Reference

Response fields

Typed options, defaults, and constraints in one scannable reference.
5 fields
attachmentId number required
Media attachment ID for the PDF.
url url required
Public PDF URL when available.
generatedAt string required
Generation timestamp meta.
configured boolean required
Whether the render service is configured.
pending boolean required
Whether an Action Scheduler job is pending.

POST /screenshot

Proxies an element screenshot request to Firebase.

Permission: current_user_can( 'edit_posts' ). Attaching to a post also requires edit_post on attachToPostId.

Reference

Request body

Typed options, defaults, and constraints in one scannable reference.
4 fields
url url required
Page URL to render.
selector string required
CSS selector for the element.
waitMs number
Wait before capture.
attachToPostId number
Optional post to sideload the PNG onto.

Success payload includes pngBase64, mimeType, and optionally attachmentId / url when attached.

Was this helpful?