Frontend teams building Next.js portals, mobile apps, or external storefronts often end up duplicating Perfex CRM articles and product imagery inside separate headless SaaS platforms. That split doubles content entry and breaks synchronization whenever assets or SEO metadata change.
The PolyCMS REST API solves this by exposing published pages, posts, taxonomies, and the centralized Media Database directly from Perfex CRM over clean, token-secured JSON endpoints.
Want to test endpoints interactively before writing client code? Launch the API Explorer Plugin Interactive REST API Sandbox.
| API Endpoint Group | Auth & Method | Payload Capabilities |
|---|---|---|
| Pages & Slugs | Bearer Token / GET | Returns rendered HTML, MTBuilder JSON blocks, and SEO tags |
| Posts & Archives | Bearer Token / GET | Supports pagination, category filters, search, and author info |
| Media Database | Bearer Token / GET, POST | Lists folders, file IDs, dimensions, alt text, and WebP URLs |
| Taxonomies & Menus | Bearer Token / GET | Delivers hierarchical categories, flat tags, and navigation trees |
| Publish Webhooks | HMAC Signed / POST | Triggers instant Next.js ISR or edge CDN cache revalidation |
Step 1: Configure Scoped API Tokens and CORS Rules
Before consuming JSON payloads from an external app, create least-privilege API credentials inside Perfex CRM and restrict origin headers strictly to your frontend domains. Keeping read-only public delivery tokens separate from media upload tokens protects editorial workflows from accidental mutations.
- Open PolyCMS > Settings > API Access in Perfex CRM and generate a dedicated Bearer token per client application.
- Add exact frontend origins (protocol, domain, and port) to the CORS allowlist instead of relying on wildcard access.
- Validate endpoint headers and response schemas live inside the PolyCMS API Explorer Plugin before writing TypeScript interfaces.
- Enforce HTTPS on every API consumer so bearer credentials never traverse unencrypted networks.
Step 2: Query Content, Media Database Assets, and Storefront Feeds
Every PolyCMS response separates structured metadata from rendered layout payloads, letting React or Vue clients render either custom components or pre-built sections. Teams combining editorial content with catalog items can align schema markup using PolyStore variant URLs, sitemaps, and schema, or structure reusable UI sections via custom MTBuilder blocks.
- Fetch /api/v1/pages?slug=pricing to retrieve canonical URLs, Open Graph tags, and structured block arrays in one round-trip.
- Query the Media Database endpoints by folder ID, MIME type, or search term to fetch intrinsic width, height, alt text, and optimized WebP URLs.
- Use page and per_page query parameters alongside ETag or Last-Modified headers for efficient incremental static builds.
- Subscribe your frontend revalidation endpoint to PolyCMS publish and media-update webhooks so edits appear within seconds.
Common Pitfalls & Quick Fixes
- HTTP 401 or 403 on Valid Bearer Token: Confirm Apache or Nginx passes the Authorization header to PHP (CGIPassAuth On) rather than stripping it before Perfex CRM runs.
- Media Database Returns Localhost Asset URLs: Check Perfex CRM base URL configuration and PolyCMS Media CDN prefix settings so API payloads emit public HTTPS URLs.
- CORS Preflight Fails on Browser Fetch: Whitelist your exact frontend origin in PolyCMS API Settings and ensure OPTIONS preflight requests return 200 without auth redirects.
Frequently Asked Questions
Does the PolyCMS REST API expose private Perfex CRM customer or invoice data?
No. The PolyCMS REST API is strictly scoped to CMS entities such as published pages, blog posts, categories, navigation menus, and Media Database assets. Internal Perfex CRM tables including invoices, contracts, expenses, and staff messages remain completely isolated from headless CMS API routes.
What image metadata does the Media Database endpoint include?
Media Database API responses return each file ID, original filename, MIME type, folder assignment, intrinsic pixel width and height, alt text, caption, and generated thumbnail or WebP URLs. Passing explicit width and height attributes to your frontend prevents Cumulative Layout Shift issues.
Can external apps fetch both raw MTBuilder blocks and rendered HTML?
Yes. Page and post payloads provide both pre-rendered HTML output for rapid server-side injection and structured JSON block data so decoupled Next.js, Nuxt, or mobile apps can map specific MTBuilder sections onto native UI components without parsing raw HTML strings.
How should headless frontends cache PolyCMS API responses safely?
Cache read responses at your Next.js data layer or edge CDN using short stale-while-revalidate policies, then wire signed PolyCMS publish and update webhooks to trigger targeted path revalidation. This approach preserves sub-second page delivery while reflecting editorial content updates across your storefront almost immediately.

Leave a Reply