Build a content provider
Content can use items that live in another system: a product catalogue, a digital asset library, a directory of people. A content provider is a service you host that supplies those items. An organization adds it to theirs by pasting your address into Hub, and an editor can then pick its items in a reference field, search them, and publish pages that show them.
A provider holds no ebitex credential, runs no code inside ebitex and is read-only: it supplies items and never receives any. It is told only what one call needs.
What a provider is
Section titled “What a provider is”Two endpoints under one HTTPS base address:
| Call | Purpose |
|---|---|
GET {base}/manifest |
Says who the provider is, its version, the settings a registration takes and whether it can search. |
POST {base}/content |
One of four actions, named in the body: describe, resolve, list or search. |
The address must be HTTPS and reachable from the public internet. ebitex follows no redirect and will not call a private address.
The manifest
Section titled “The manifest”{ "protocol": 1, "key": "acme-catalogue", "name": "Acme catalogue", "description": "Products from the Acme catalogue.", "version": "1.0.0", "types": { "content.provider": { "capabilities": ["search"], "settings": [ { "key": "catalogue", "label": "Catalogue", "kind": "text", "required": true, "help": "The short name in your Acme address.", "pattern": "^[a-z0-9-]{3,20}$", "patternMessage": "Use 3 to 20 lowercase letters, digits or dashes." }, { "key": "apiKey", "label": "API key", "kind": "secret", "required": true } ] } }}keyis lowercase letters, digits and hyphens, 3 to 64 characters. It does not change.versionismajor.minor.patch. A higher one is an upgrade the organization approves.- The manifest has exactly one type,
content.provider.settingsare asked for each time an editor registers the provider in a Content environment (text,urlorsecret; a secret is stored protected and never shown again). They are sent to you insettingson every call. Nothing is per mode, and there are no account-level settings. capabilitiesmay listsearch. Reading (describe,resolve,list) is always available. If you do not listsearch, the picker offers browsing only. Nothing else may be listed: entitlement, links, items API, blobs and taxonomy are not available to a hosted provider, and a manifest that names one is refused.- A provider asks for no permissions. There is no
permissionsmember, because nothing about a person is ever sent to you. A manifest that names one is refused. - Removing a setting, changing its kind, adding a required setting or dropping
searchis a change the organization reviews before it applies.
The call
Section titled “The call”Every action is a POST {base}/content with a JSON body. The members every call carries:
{ "protocol": 1, "action": "resolve", "organizationId": "08b27ef8-fb84-4800-99f1-40302e68830e", "settings": { "catalogue": "acme-eu", "apiKey": "…" }, "key": "mug"}action |
Extra members | Answer with |
|---|---|---|
describe |
none | { "contracts": [ … ] } |
resolve |
key |
{ "item": { … } }, or { "item": null } when there is no such key |
list |
contract (or none), cursor (or none), limit |
{ "items": [ … ], "nextCursor": "…" } |
search |
query, contract, cursor, limit |
the same page shape as list |
Answer with a 2xx and a JSON body.
describe says which content types you supply. Each becomes a read-only Contract in Content, so an editor can bind a reference to it. It must give the same answer twice when nothing changed, because a refresh compares it with the last one.
{ "contracts": [ { "externalId": "product", "name": "Product", "titleFieldPath": "title", "fields": [ { "externalId": "title", "name": "Title", "fieldTypeKey": "text", "isMandatory": true }, { "externalId": "price", "name": "Price", "fieldTypeKey": "text", "isMandatory": false } ] } ]}externalId (of a contract and of a field) is lowercase letters, digits and single hyphens, 3 to 64 characters. A field’s fieldTypeKey is one of text, number, boolean, date, link, richText, object, component or category. Plain text is text: it is a single line unless the field’s settings say { "multiline": true }. The older shortText and longText are deprecated and refused for a new field. Any other key, or an externalId that breaks the rule, makes ebitex refuse the whole describe, and the editor sees that the contracts could not be accepted. At most 100 contracts with 200 fields each.
An item, in resolve, list and search:
{ "key": "mug", "contract": "product", "name": "Enamel mug", "subtitle": "Cream, 350 ml", "thumbnailUrl": "https://cdn.example.com/mug.png", "document": { "title": "Enamel mug", "price": "12.00" } }key,contractandnameare required text of at most 200 characters, anddocumentis an object of at most 64 KB whose members match the fields you described.subtitleis optional and is clipped to 200.thumbnailUrlis optional and is used only if it is a plainhttpsaddress; anything else is dropped.- An item that breaks any of this refuses the whole answer. ebitex never keeps part of an item or part of a page, so a bad item takes the page with it. The editor sees that the provider failed, not a half-filled picker.
- Say “no such key” with
{ "item": null }. That is an answer: the reference is reported as not found. A404or an error is a failure instead, which Content treats as the provider being down. - Pages.
cursoris whatever you gave asnextCursorlast time; ebitex never reads it.limitis between 1 and 100. Return no more items thanlimit; extras are dropped. ReturnnextCursorasnullor leave it out on the last page (at most 500 characters).
What a provider is never sent
Section titled “What a provider is never sent”A call carries the organization, your own registration settings and what the action needs, and nothing else:
- never a visitor, their token, their consent choices or any entitlement or audience token;
- never the organization’s own settings for other plugins;
- never an editor’s identity.
That is also why a provider holds no copy of anything of ours to erase. Content flows from you into ebitex, and what ebitex keeps of it is cached for a limited time and removed when the organization is. Your registration settings can hold your own credentials, so do not log request bodies.
Speed matters
Section titled “Speed matters”Resolving an item happens while a visitor waits for a page, so a call to resolve has 5 seconds to answer; describe, list and search have 10. A slower answer, an unreachable address or any error is treated as your provider being down: the item is shown as unavailable and the page still loads. Answers are cached for the registration’s cache time, so your service is not asked for the same item on every view. An answer is at most 1 MB; a longer one is refused, never cut off.
Verify every call
Section titled “Verify every call”Each call carries an X-Ebitex-Signature header made exactly as the organization webhooks’ is: an HMAC-SHA256 of {timestamp}.{body} under the signing secret, which the organization is shown once when they add you. Verify it against the raw bytes you receive, compare in constant time and refuse a timestamp more than five minutes from now. Every call also carries an X-Ebitex-Delivery id; the calls are reads, so they are safe to repeat.
A complete example
Section titled “A complete example”A single file of Node, with no dependencies. It serves the manifest, verifies the signature, and answers all four actions for a small fixed catalogue.
// example:content-providerimport { createServer } from 'node:http'import { createHmac, timingSafeEqual } from 'node:crypto'
export const MANIFEST = { protocol: 1, key: 'example-catalogue', name: 'Example catalogue', description: 'A small fixed list of products.', version: '1.0.0', types: { 'content.provider': { capabilities: ['search'], settings: [{ key: 'catalogue', label: 'Catalogue', kind: 'text', required: true, pattern: '^[a-z0-9-]{3,20}$', patternMessage: 'Use 3 to 20 lowercase letters, digits or dashes.' }], }, },}
const PRODUCTS = [ { key: 'mug', name: 'Enamel mug', subtitle: 'Cream, 350 ml', price: '12.00' }, { key: 'notebook', name: 'Dotted notebook', subtitle: 'A5, 120 pages', price: '8.50' }, { key: 'pen', name: 'Brass pen', subtitle: 'Refillable', price: '24.00' },]
const item = (p) => ({ key: p.key, contract: 'product', name: p.name, subtitle: p.subtitle, document: { title: p.name, price: p.price } })
/** True when `header` (`v1,t=<unix seconds>[,k=<key id>],s=<hex>`) is a fresh, correct signature of `rawBody`. */export function verify(rawBody, header, secret, now = Date.now()) { const match = /^v1,t=(\d+)(?:,k=[A-Za-z0-9._-]{1,32})?,s=([0-9a-f]{64})$/.exec(header ?? '') if (!match) return false const [, t, s] = match if (Math.abs(now / 1000 - Number(t)) > 300) return false const expected = createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest() const given = Buffer.from(s, 'hex') return given.length === expected.length && timingSafeEqual(given, expected)}
function page(products, call) { const from = Number.isInteger(Number(call.cursor ?? 0)) && Number(call.cursor ?? 0) >= 0 ? Number(call.cursor ?? 0) : 0 const size = Math.min(Math.max(Number(call.limit) || 20, 1), 100) return { items: products.slice(from, from + size).map(item), nextCursor: from + size < products.length ? String(from + size) : null }}
export function createProvider(secret) { return createServer((request, response) => { const send = (status, body) => { response.writeHead(status, { 'Content-Type': 'application/json' }) response.end(JSON.stringify(body)) }
if (request.method === 'GET' && request.url?.endsWith('/manifest')) return send(200, MANIFEST)
const chunks = [] request.on('data', (chunk) => chunks.push(chunk)) request.on('end', () => { const raw = Buffer.concat(chunks) if (!verify(raw, request.headers['x-ebitex-signature'], secret)) return send(401, { error: 'bad_signature' })
const call = JSON.parse(raw.toString('utf8')) switch (call.action) { case 'describe': return send(200, { contracts: [{ externalId: 'product', name: 'Product', titleFieldPath: 'title', fields: [ { externalId: 'title', name: 'Title', fieldTypeKey: 'text', isMandatory: true }, { externalId: 'price', name: 'Price', fieldTypeKey: 'text', isMandatory: false }, ] }], }) case 'resolve': { const found = PRODUCTS.find((p) => p.key === call.key) return send(200, { item: found ? item(found) : null }) // null: no such key, which is an answer, not an error } case 'list': return send(200, page(PRODUCTS, call)) case 'search': { const q = String(call.query ?? '').toLowerCase() return send(200, page(PRODUCTS.filter((p) => `${p.name} ${p.subtitle}`.toLowerCase().includes(q)), call)) } default: return send(400, { error: 'unknown_action' }) } }) })}Add it, then try it
Section titled “Add it, then try it”In Hub, open Plugins and choose Add by address. Paste your base address, review the manifest and add it. Hub shows the signing secret once. Then use Send a test: it makes one signed describe call, the same a real registration makes, and reports whether it answered.
Then open Content’s Plugins page, choose Add plugin, pick yours and fill in its settings. Content describes your content types once to create the Contracts an editor binds to, and from then on the picker lists, searches and resolves through you. A provider you added is available in every Content environment of the organization, registered one environment at a time.
Open the provider in Hub to review a newer version, send a test, turn it off or remove it. A provider a Content registration uses cannot be removed until the registration is, and Hub names it. Turning it off stops calls: pages show its items as unavailable, nothing is deleted, and they return when it is turned back on.
Providers that ebitex hosts itself are added the same way, from an address on ebitex’s own plugin host. They follow the same protocol and are limited the same way; the only difference is that ebitex approves what they declare.
Limits and failures
Section titled “Limits and failures”resolvehas 5 seconds to answer; the others have 10. A slower answer is a failure.- An answer is at most 1 MB, a page at most 100 items, an item’s document at most 64 KB.
- If your address stops being reachable, items show as unavailable and the editor sees that the provider is down; they return once it answers again.
- The manifest is at most 16 KB. Keys, labels and descriptions have the lengths shown above; a manifest that breaks them is refused when it is added, with the reason.