Directus integration

Generate PDFs from Directus

Connect Quaterio to your Directus instance, bind collection items to block-based templates and render paginated PDFs on demand or in batch. Static Access Tokens with role-based scope keep the connector locked to the data you want it to see.

The problem

Directus puts a clean REST API in front of your database with a real admin UI. PDF output is not part of the story. Custom Express endpoints, off-the-shelf PDF libraries and themed CSS exports add up to ongoing maintenance every time the schema shifts.

How Quaterio handles it

Quaterio's Directus connector hits /items/{collection} with a Static Access Token in the Bearer header. Lists, single items, expanded relations and filtered queries all work straight from the URL. Your engineers stop maintaining a parallel PDF pipeline.

How it works

  1. 1

    Generate a Static Access Token in Directus

    User Directory → pick or create a service user → scroll to Token → Generate Token → Save. Copy the token. The user's role controls what the token can read.

  2. 2

    Pick the Directus preset in Connections

    Settings → Connections → New Connection → pick "Directus" from the type dropdown. Replace yoursite.com with your Directus host and articles with your collection name. Paste the token into the Token field.

  3. 3

    Hit Detect Fields to confirm the shape

    Quaterio fetches /items/{collection} and shows the JSON paths available. Default is data.0.content for the first item. Add ?fields=*.* on the URL if you need expanded relations to show up in Detect Fields.

  4. 4

    Generate the PDF via the editor or API

    Export from the editor for one-offs. For batch jobs hit POST /api/v1/generate/template with the template ID. The connector re-fetches at generation time so every PDF reflects the latest Directus data.

What the connector handles

  • Directus REST API /items/{collection} for lists, /items/{collection}/{id} for single records
  • Static Access Token authentication via Authorization Bearer header
  • Role-scoped tokens, Quaterio only sees what you grant the role
  • Field selection with ?fields= to scope the response payload
  • Relation expansion with ?fields=*.* (one level) or dot paths for deeper
  • Filter, sort, limit and offset parameters pass through on the URL
  • File URLs resolved relative to the Directus host at render time
  • Self-hosted and Directus Cloud both work with the same configuration
  • Detect Fields walks the response so you can pick paths in the editor
  • 15 second fetch timeout, cached on the block when the API is slow or unreachable

Generate via API

# 1. Create the connection via the dashboard (one-time setup). # 2. Bind a template's Remote Content block to it. # 3. Generate a PDF that pulls live Directus content: curl -X POST https://quaterio.com/api/v1/generate/template \ -H "Authorization: Bearer q_your_token" \ -H "Content-Type: application/json" \ -d '{ "templateId": "directus_item_export" }' # → { # "ok": true, # "data": { "downloadUrl": ".../item_en_a7f3b2c1.pdf" } # } # The connector hits /items/{collection} at generation time and # renders the bound item field into the template block.

Available on Business plan and above.

Directus and PDF: the real questions

The Directus preset queries /items/{collection} on your Directus instance with a Static Access Token in the Authorization header. Collections come back as { data: [...] } arrays, individual items as { data: {...} }. The sections below cover token generation, fields and filter parameters, relations and self-hosted deployment.

Generating a Static Access Token

In Directus admin, navigate to User Directory and pick the user who will own the token (or create a dedicated machine user for PDF generation). Scroll to the Token field, click Generate Token and copy the value. Save the user. The token is now valid until you regenerate it.

Token permissions follow the user's role. Most teams create a "Quaterio" role with read access to only the collections that feed PDFs. The token then cannot read anything outside that scope even if leaked. Standard least-privilege practice.

Response shape, list vs single

GET /items/{collection} returns { data: [...] }, the array contains every item the role can read. The default Response Field data.0.content picks the content field of the first item.

GET /items/{collection}/{id} returns { data: {...} }, a single item. For PDF templates that always render a specific record, change the URL to include the ID and change the Response Field to data.content (drop the .0 index). Cleaner and less brittle than relying on array order.

Selecting fields and limiting payload

By default Directus returns every field on the item, which can be wasteful for PDF templates that only bind two or three. Use ?fields=title,content,published_at on the URL to scope the response. Speeds up fetches and shrinks what Quaterio has to walk in Detect Fields.

Relations are returned as IDs by default. To expand a single level of relations (resolve author IDs to author objects, for example), use ?fields=*.*. For deeper expansion use the dot path explicitly: ?fields=*, author.first_name, author.last_name. The connector passes the whole URL through.

Filtering and sorting

Filter syntax is ?filter[field][operator]=value. Example: ?filter[status][_eq]=published&sort=-published_at&limit=10. The full operator list (_eq, _neq, _in, _contains, _gte, ...) is in the Directus docs.

For multi-condition filters use the _and / _or wrappers. The URL grows quickly; if you find yourself fighting the encoding, build the URL via the Directus SDK in a small helper and paste the final string into the connection.

Files and media

Directus files live in a separate files collection. An item field that references a file stores the file UUID. To get the file URL into a PDF, expand the field with ?fields=*.* and the URL becomes available as the file's relative path on your Directus instance.

For absolute URLs, the file path needs prefixing with your Directus host (e.g. https://yoursite.com/assets/{uuid}). Quaterio resolves relative paths against the connection URL host at PDF render time when binding to image blocks.

Self-hosted by definition, connectivity matters

Directus is self-hosted. Your instance needs to be reachable from the public internet at PDF generation time. Instances behind a VPN or private cloud cannot be read directly by the connector.

Common patterns: deploy Directus on Directus Cloud, Railway, Render, AWS or DigitalOcean with a public HTTPS endpoint and lock it down with role-based permissions on the static token. Or run a public proxy that fronts an internal install. The connector does not care which.

Directus Cloud vs self-hosted

Directus Cloud is the managed offering, Directus handles infrastructure, backups and upgrades. From the connector's side it is identical to self-hosted: same /items/{collection} endpoint, same token in the Bearer header. The host is the {project}.directus.app URL or a custom domain.

Self-hosted Directus is free under the Business Source License. Run it on your own infrastructure with your own scaling story. The REST API contract does not change between the two.

Pricing and plan tier

CMS connections are part of the Quaterio Business plan and above ($30/mo). Pro plans get the editor and basic templates but not the Remote Content block. Free and Pro users who try to add a Remote Content block see an upgrade prompt.

Directus is free to self-host. Directus Cloud starts at $99/mo for the Standard plan. The REST API is included on every Directus tier; there is no extra cost for reading from Directus into Quaterio.

Try the Directus connector free

Set up the connection in two minutes. No credit card required to start.