Control sources from your app
Send, replace, check and delete the sources your own app feeds to Trail — by REST, by the TypeScript SDK or from an AI agent over MCP. You use your own ids; you never need to know how Trail turns a source into answers.
Your app owns documents and pages that should be answerable through Trail. This page is all you need to keep them in sync: send a source, replace it when it changes, check that the change has gone through, and delete it when it is gone.
You refer to a source by your own id — a file id, a URL, a slug. The same id again always means the same source, new edition. Two different keys can use the same id without ever meeting.
1. Get a key
A partner key is issued by Trail's owner for one brain — ask for one (a self-service screen under Settings → API keys is planned but does not exist yet). When asking, decide two things:
- Publish by itself? If yes, a change is in effect as soon as it has been processed.
If no, what you send waits for a person at Trail to approve it, and the status reads
awaiting-reviewuntil then. New partners start with no. - May it delete? Off by default.
A partner key can only do the four things on this page, only in its own brain, only on sources it sent itself. It cannot search, read other sources or create keys. Keep it on your server; never ship it in a browser or a mobile app.
All calls go to https://engine.trailmem.com with the header Authorization: Bearer trail_….
2. The four actions
Send or replace — PUT /api/v1/partner/sources/{id}
Text (a web page, a generated document):
curl -X PUT "https://engine.trailmem.com/api/v1/partner/sources/opening-hours" \
-H "Authorization: Bearer $TRAIL_PARTNER_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"Opening hours","text":"We are open Monday to Friday, 8–16.","url":"https://example.com/opening-hours"}'A file (PDF, Word, markdown … up to 100 MB):
curl -X PUT "https://engine.trailmem.com/api/v1/partner/sources/price-list-2027" \
-H "Authorization: Bearer $TRAIL_PARTNER_KEY" \
-F "file=@./price-list.pdf"Answer, HTTP 202:
{ "externalId": "opening-hours", "status": "queued", "replaced": false, "version": 1 }Sending the exact same content again does nothing and says so ("unchanged": true).
Has it gone through? — GET /api/v1/partner/sources/{id}
{ "externalId": "opening-hours", "filename": "opening-hours.md", "status": "live", "version": 1, "updatedAt": "2026-12-02T15:08:41.156Z" }| status | means |
|---|---|
queued / processing |
being read and prepared — usually 20–60 seconds for a page, a few minutes for a long PDF |
live |
the change is in effect — your AI front-end now answers from it |
awaiting-review |
processed, waiting for a person at Trail to approve (keys that do not publish by themselves) |
failed |
could not be processed; error says why. Send again when fixed |
Poll every few seconds until live. Everything you list or fetch is only your own; an id
you never sent, or that belongs to another key, answers 404 — the same for both.
List yours — GET /api/v1/partner/sources
{ "sources": [ { "externalId": "opening-hours", "status": "live", "version": 2, "…": "…" } ] }Delete — DELETE /api/v1/partner/sources/{id}
curl -X DELETE "https://engine.trailmem.com/api/v1/partner/sources/opening-hours" \
-H "Authorization: Bearer $TRAIL_PARTNER_KEY"
# {"externalId":"opening-hours","removed":true}The source stops answering at once, together with what Trail only knew because of it.
What also rests on another source stays. Repeating the call is safe. The key needs the
delete grant, otherwise you get 403.
3. What happens when you replace
Replacing never leaves your AI front-end without an answer:
- You send the new edition. While it is being processed, status stays
liveand the answer carries"replacing": true— the previous edition is still the one in effect. - When the new edition is in, what only the old one said is retired. The change is in
effect when status is
livewithoutreplacing. - If the new edition fails, the old one is left exactly as it was; status becomes
failedwith the reason, and you can simply send again.
One honest limit: a sentence the new edition no longer contains, but which also sits in a page that other text keeps alive, can linger until that page is rewritten.
4. TypeScript SDK
import { TrailClient } from '@trailmem/sdk';
const trail = new TrailClient({ baseUrl: 'https://engine.trailmem.com', apiKey: process.env.TRAIL_PARTNER_KEY! });
await trail.sources.upsert('opening-hours', { text: 'Open Monday to Friday, 8–16.', title: 'Opening hours' });
await trail.sources.upsert('price-list', { file: new Blob([pdfBytes]), filename: 'price-list.pdf' });
const s = await trail.sources.get('opening-hours'); // { status, version, replacing?, error? … }
const mine = await trail.sources.list();
await trail.sources.delete('opening-hours');Errors are thrown as TrailApiError with status (404, 403, 400 …) and the message.
5. From an AI agent — MCP
Point an MCP client at https://engine.trailmem.com/mcp with the same key as a bearer
token. Four tools: upsert_source, get_source_status, list_sources, delete_source
(the last is marked destructive). Example for Claude Code:
claude mcp add --transport http trail-sources https://engine.trailmem.com/mcp \
--header "Authorization: Bearer $TRAIL_PARTNER_KEY"Files go as content_base64 + filename (up to 8 MB); use REST for bigger files. The same
limits and refusals apply as over REST — an agent can never do what your key cannot.
Limits at a glance
- File types: the same list as programmatic upload; up to 100 MB (REST) / 8 MB (MCP); text up to 10 MB.
- An id is 1–512 characters, no control characters.
- Delete is a soft archive: Trail's owner can bring it back. Removing the file itself for good (for example a data-protection request) is a separate, deliberate step at Trail.[^soft]
[^soft]: What Trail derives from a source is archived together with it, not erased; that is why a delete can be undone by Trail's owner.