REST and AJAX Endpoints
All REST routes are under the namespace tnc-flipbook-3d/v1.
File serving (token-secured, public)
GET /wp-json/tnc-flipbook-3d/v1/serve/{flipbook_id}?file=pdf&index=0&token=...&exp=...
Param
Description
file
pdf, image, video, media, audio
index
Zero-based file index
token
HMAC-SHA256 signature (see TNC_Flipbook_3D_Helpers::generate_token)
exp
Unix timestamp (must be ≥ now)
Streams binary with the appropriate Content-Type. Returns 403/404 on failure. Token TTL is 2 hours (TOKEN_TTL constant).
Filters: tncfb3d_serve_file_path (intercept the file path), tncfb3d_serve_headers (override response headers).
TTS (admin only — edit_posts)
POST /tts/generate { flipbook_id, provider, voice }
GET /tts/status/{flipbook_id}
POST /tts/set-default { flipbook_id, set_key }
POST /tts/delete-set { flipbook_id, set_key }
DELETE /tts/cache/{flipbook_id}
GET /tts/voices/{provider}
Providers: google, azure, amazon, elevenlabs, openai, browser.
The first batch processes inline in the generate response for immediate progress. Subsequent batches process inline during status polls — no reliance on WP-Cron firing.
WooCommerce access
GET /wp-json/tnc-flipbook-3d/v1/access/{flipbook_id}
→ { hasAccess: bool, message: string }
Returns whether the current user has purchased the linked product(s).
AJAX endpoints
Action
Capability
Purpose
tncfb3d_deactivation_feedback
manage_options
Send feedback when deactivating
tncfb3d_newsletter_subscribe
manage_options
Subscribe to Brevo newsletter
All AJAX handlers verify nonces via check_ajax_referer().
Capabilities used
TNC FlipBook 3D uses standard WordPress capabilities — no custom caps are registered.
Gate
Where
edit_post
Metabox save
manage_options
Global settings, license, welcome
edit_posts
TTS REST endpoints
Adding your own REST route
add_action( 'tncfb3d_rest_routes', function() {
register_rest_route( 'tnc-flipbook-3d/v1', '/my-endpoint', [
'methods' => 'GET',
'callback' => 'my_callback',
'permission_callback' => function() {
return current_user_can( 'edit_posts' );
},
] );
} );
Hook into tncfb3d_rest_routes so your routes register at the right point in the request lifecycle (after the plugin's own routes, before the response).