REST Integrations
REST Integrations allow you to fetch data from external APIs — CRMs, inventory systems, booking platforms — and expose that data as a context root directly inside your block expressions. Responses are automatically cached to minimize latency.
Registering a REST Endpoint
Configure endpoints in Settings → Vector Expressions Pro → REST Endpoints.
Each endpoint requires:
- Key: The context root name you will use in expressions (e.g.,
crm). - URL: The full endpoint URL (supports
{post.id}and{user.id}interpolation). - Method:
GETorPOST. - Cache TTL: How long to cache the response in seconds (default: 60).
- Auth (optional): Bearer token, API key header, or Basic credentials stored in WordPress options.
Example: Exposing CRM Data
Configure endpoint:
- Key:
crm - URL:
https://api.mycrm.com/contacts/{user.id} - Cache TTL:
300(5 minutes)
Then use in expressions:
{{ crm.first_name ~ " " ~ crm.last_name }}
{{ crm.account_tier | match gold="is-gold" silver="is-silver" | default "is-standard" }}
{{ crm.subscription_end | date "F j, Y" }}
Response Caching
Responses are cached using WordPress Transients with the TTL you define. Cache keys are derived from the endpoint key + resolved URL (including interpolated values). This means a different user or post will generate a distinct cache entry, ensuring data accuracy without redundant API calls.
Authentication
Pro supports three authentication methods stored securely in WordPress options (never in the block data):
| Method | Config |
|---|---|
| Bearer Token | Authorization: Bearer {token} header |
| API Key Header | Any custom header (e.g., X-Api-Key) |
| Basic Auth | Username + password, base64-encoded |
Error Handling
If an API call fails (network error, non-200 response), the root returns an empty object. Combined with the default filter, you can handle failures gracefully:
{{ crm.account_tier | default "standard" }}