REST API
All routes are registered in includes/class-coverkit-rest.php on namespace coverkit/v1.
Base URL:
/wp-json/coverkit/v1Routes
Section titled “Routes”| Method | Route | Callback | Permission |
|---|---|---|---|
GET | /image/{context_type}[/{context_id}][.{extension}] | REST::get_image() | get_image_permission() (currently allows public access) |
GET | /template[/{template_id}] | REST::handle_template() | public |
POST | /clear-cache | REST::clear_cache() | edit_posts |
GET | /screenshot | REST::get_screenshot() | edit_posts |
POST | /preview | REST::generate_preview() | edit_post for given post_id |
GET | /autocompleters | REST::get_autocompleters() | public |
GET | /canvas/{filename} | REST::serve_canvas_image() | public |
GET | /opengraph/{template_id}/{post_id}.{extension} | REST::get_opengraph_image() | public |
GET | /use-cases | REST::get_use_cases() | edit_posts |
GET | /use-case/{use_case}/{template_id}/{post_id}.{extension} | REST::get_use_case_image() | edit_post when post_id > 0, else edit_posts |
POST | /use-case/preview | REST::generate_use_case_preview() | use_case_preview_permission() |
Image by context
Section titled “Image by context”GET /wp-json/coverkit/v1/image/{context_type}/{context_id}.png?width=1200&reload=1Resolves a template (directly when context_type is coverkit, otherwise via get_template_by_context()), generates via Renderer::generate_from_content(), copies to wp-content/cache/coverkit/, and streams bytes.
Template payload
Section titled “Template payload”GET /wp-json/coverkit/v1/template?context_type=post&context_id=123Returns template structure for the editor. Requires context_type; optional context_id and template_id route segment.
Preview (editor)
Section titled “Preview (editor)”POST /wp-json/coverkit/v1/previewBody params:
content(required) — inner blocks or shape contentpost_id(required)save_to_uploads(optional)format,width,quality(optional)meta(optional) — canvas attributes when previewing acoverkitpost
Calls Renderer::generate_from_content() with force => true. Response includes url and data (file path, dimensions, format).
Open Graph image
Section titled “Open Graph image”GET /wp-json/coverkit/v1/opengraph/{template_id}/{post_id}.pngPublic route used in og:image meta. Generation key is opengraph inside Renderer::generate().
Use case registry (editor)
Section titled “Use case registry (editor)”GET /wp-json/coverkit/v1/use-casesResponse envelope:
{ "use_cases": { "opengraph": { "slug": "opengraph", "label": "Open Graph image", "description": "...", "cardinality": "single", "supports": [], "settings_schema": {}, "recommended_settings": { "dimensions": { "width": 1200, "height": 630 } }, "output_profile": { "crop": false, "dimensions": { "width": 1200, "height": 630 } }, "mapping_sources": { "post_title": { "required": true } } } }}Use case image
Section titled “Use case image”GET /wp-json/coverkit/v1/use-case/sidebar_image/123/456.png?reload=1Streams generated bytes after Renderer::generate( $use_case, $template_id, $post_id, $options ).
Use case live preview
Section titled “Use case live preview”POST /wp-json/coverkit/v1/use-case/previewBody: use_case, template_id, content, assignment (required); optional post_id. Sanitizes assignment via Use_Case_Storage::sanitize_assignment() and generates from unsaved editor content.
Autocompleters
Section titled “Autocompleters”GET /wp-json/coverkit/v1/autocompletersReturns tag/label pairs for shape text tokens; extend with coverkit_autocompleter_options.
Canvas cache
Section titled “Canvas cache”GET /wp-json/coverkit/v1/canvas/{hash}.pngGET /wp-json/coverkit/v1/canvas/{hash}-600x315.pngServes files from _cache/generator/. Resized widths must be in get_coverkit_responsive_sizes() (default: 100, 300, 400, 600, 800, 1200, 1920). Cache-Control max-age from coverkit_canvas_image_cache_time (default one year).
Screenshot
Section titled “Screenshot”GET /wp-json/coverkit/v1/screenshot?url=https://example.com&width=1200&height=630Requires edit_posts. URL is validated to reduce SSRF risk. Note: route args are registered as width / height / viewport_width / viewport_height, but get_screenshot() reads screenshotWidth, screenshotHeight, viewportWidth, viewportHeight — pass those names until the route args are aligned.
Async generation
Section titled “Async generation”Action coverkit_generate_image processes queued URLs stored in option coverkit_generate_image (see REST::handle_generate_image()).