Contextual · For developers

Developer guide

Everything you can build on Contextual, one chapter at a time: the call, and what changes for the person, before and after.

First edition · November 2026 · Srini Rentala Venkata, trading as rentala-studios
const cx = new Contextual({ baseUrl, token });
const now = await cx.now();
// what needs the person, with its proof

Chapter 1: Make an app and its key

Everything starts with an app at app.contextual.exchange: a name, a sample mailbox, and a key that does only what you tick.

Sign in to the developer service, press New app, name it and choose Sample mail: made-up mail for Robin Vale, who is nobody real. Tick what the key may do and for how long, from one day to a year.

The key shows once. Keep it in your own secret store, never in code. The SDK takes it, with the address, and every call after that is checked against the ticks.

Fig. 1.1 The call, in TypeScript.
import { Contextual, ContextualError } from "@contextual/sdk";

const cx = new Contextual({
  baseUrl: "https://email.contextual.exchange",
  token: process.env.CONTEXTUAL_KEY,
});
try { await cx.now(); }
catch (e) { if (e instanceof ContextualError) console.log(e.needs); }
Before
Apps and keys
No apps yetMake one to get a key
New app
After
Apps and keys
Veg box trackerSample mail · key ends 9f2c · until 19 DecSample
What this key may doRead your mailWrite reply drafts for you to checkSend mail as you
Fig. 1.2 Before: no app. After: one app on the sample mailbox, its key and the two things it may do.

Chapter 2: Read what needs the person

Now is what a person owes: replies, approvals and dates, each with who asked, by when, and the words that prove it.

Contextual reads each email for what it asks. Your app reads the result, not the inbox: a short list, each item with its conversation, so you can build a reminder, a tracker or a daily note.

Open the conversation behind any item, with its topics pulled apart, and write reply drafts. A draft is only ever a draft: the person sends it, or doesn't.

Fig. 2.1 The call, in TypeScript.
const now = await cx.now();
for (const e of now.needsYou) console.log(e.title, e.due ?? "");
const thread = await cx.conversation(now.needsYou[0].conversationId);
const drafts = await cx.drafts("Robin");   // drafts only: nothing is sent
Before
Robin's inbox
Maya OseiLease renewal: can you sign by Friday?Mon 16 Nov
Veg Box CoYour box this weekMon 16 Nov
Book clubDecember pick?Tue 17 Nov
LoomwearWeekly dealsTue 17 Nov
After
cx.now()
Sign the lease renewalMaya · by Fri 20 NovReply
Choose December's bookBook club · asked 17 NovReply
Draft to MayaSaved as a draft · not sent
Fig. 2.2 Before: four emails, two of them noise. After: the two things Robin owes, and a draft that waits for Robin.

Chapter 3: Folders and line maps

Contextual makes folders from the people, domains and topics that recur. Every folder has a line map: one line through time.

List the folders, then ask for a folder's line: a notch for each email, sent on one side and received on the other, filtered by person, topic or mark, a page at a time.

Exchange lines have a line map too, with each file's way of sharing, each opening and each note.

Fig. 3.1 The call, in TypeScript.
const [claim] = await cx.folders();
const line = await cx.folderLine(claim.id, { person: "rachel@northgate.example", limit: 50 });
// An Exchange line's map, too
const map = await cx.exchange.lineMap(lineId);
Before
All mail
Maya OseiLease renewal16 Nov
YouRe: Lease renewal16 Nov
Maya OseiSigned copy attached18 Nov
After
Lease renewal · Line
16 Nov · Maya asks to sign by Friday Deadline16 Nov · You: I'll sign Thursday18 Nov · Maya: signed copy File
Fig. 3.2 Before: three emails in a list. After: the same three on one line, received on the left, sent on the right, with their marks.

Chapter 5: The Record: asked, offered, agreed

The Record keeps what was asked, offered, agreed and due, each with the quote and the message that prove it.

Read it to build a tracker, a report or a reminder. Each entry carries its proof: the words, who said them and when.

Read the notes a person marked on their mail, confirmed or disputed. Only the person adds or changes them, from Contextual itself.

Fig. 5.1 The call, in TypeScript.
const { entries } = await cx.record();
// Only what you confirmed counts: an agreement Contextual read stays "suggested" until you say so
const agreed = entries.filter((e) => e.kind === "agreed" && e.state === "confirmed");
for (const e of agreed) console.log(e.title, e.proof[0]?.quote);
const notes = await cx.pills(messageId);
Before
An email from Daniel

We are prepared to offer £42,000 in full and final settlement. Please reply by 27 November.

After
cx.record()
Offered£42,000, by Daniel16 Nov
DueReply to the offer27 Nov
AgreedCounter at £58,50017 Nov
Fig. 5.2 Before: the words in an email. After: entries in the Record, each beside the words that prove it.

Chapter 6: Bring mail in, and when

Choose what comes in from a mailbox, see how much first, then start it now, at a time, or only at night.

Count first: labels, dates, senders and size give an estimate before anything moves. Set the filter, then start the job, pause it or resume it. What has come in is filed and searchable straight away.

Connecting a mailbox and unsubscribing stay the person's own: a key can't do them.

Fig. 6.1 The call, in TypeScript.
const [gmail] = await cx.ways();
const size = await cx.countWay(gmail.id, { after: "2024-01-01", labels: ["Claims"] });
await cx.setWayFilter(gmail.id, { after: "2024-01-01", labels: ["Claims"] });
await cx.wayJob(gmail.id, { action: "start", nightly: { from: "22:00", to: "06:00", offset: 0 } });
Before
Gmail · robin@vale-home.example
Lease renewalBook clubVeg boxNewsletters
Nothing brought in yet
After
cx.wayJob()
About 1,204 emails, 212 MBLease renewal and Book club, after 1 Jan 2024
Only at night, 22:00 to 06:00640 in so far · filed and searchablePause
Fig. 6.2 Before: labels in Gmail. After: a counted choice, coming in at night, a little at a time.

Chapter 7: Exchange lines, both ways

A line is a private folder between a firm and one client: messages, asks, files and notes, each step with a sealed receipt.

Open a line, invite the client with a one-time link (they need only a first name), ask for a document or send one, leave notes, and read the receipts for every step.

Each file keeps the way its sender chose: view once, view, keep a copy, or share with one person. A firm's own screens open once it has Enterprise.

Fig. 7.1 The call, in TypeScript.
const line = await cx.exchange.createLine({ subject: "14 Elmstead Avenue" });
const invite = await cx.exchange.invite({ lineId: line.id, name: "Sam", days: 7 });
await cx.exchange.ask(line.id, "Proof of funds");
await cx.exchange.note(line.id, "Viewing on Saturday at 11:00");
const receipts = await cx.exchange.receipts(line.id);
Before
Hollybrook · Clients
No line for 14 Elmstead Avenue
After
14 Elmstead Avenue · Sam
Proof of fundsAsked by Tom · waiting for Sam
NoteViewing on Saturday at 11:00
Sealed3 steps · each with a receipt
Fig. 7.2 Before: no line. After: a line with Sam, an ask waiting, a note, and a receipt for each step.

Chapter 8: Files: every place a person keeps things

Search a person's computers, Google Drive and email attachments at once, see every version, and find what is kept twice.

The same magic words work across every place. Duplicates come back with where each copy lives and how much room the extras take.

Share a file on an Exchange line in the way the person picks. Pairing a computer needs the person: they check the same four words on both screens.

Fig. 8.1 The call, in TypeScript.
const found = await cx.filesApp.search("kind:pdf quote kitchen");
const twice = await cx.filesApp.duplicates();
const file = found.groups[0].hits[0].item;
await cx.filesApp.share(file.id, { lineId, how: "view-once" });
Before
Three places
Sam's iMacLease 2023 signed.pdf
Google DriveLease 2023 signed.pdf
Email attachmentsLease 2023 signed.pdf
After
cx.filesApp.duplicates()
Lease 2023 signed.pdfKept 3 times · 3 versions · 2.1 MB extra
Shared on a lineView once · with MayaSealed
Fig. 8.2 Before: one lease in three places. After: one file, its versions and copies found, shared once, sealed.

Chapter 9: Storage and export

See where a person's mail is kept and export kept mail in a file sealed with a one-time code.

A key reads where the mail lives and how much there is, and makes a sealed export. LiveLink exports contain list details and snippets, not full Gmail messages or attachments. Import restores mail and folder rules. Matching manual filing for made folders and kept personal notes without replies need Organise my mail on; conflicts are skipped and other pills and notes do not move. The second copy and import stay the person's own.

Fig. 9.1 The call, in TypeScript.
const where = await cx.storage();
const sealed = await cx.exportEverything();   // sealed; keep sealed.code apart from the file
Before
Where it's kept
This computer4,812 emails · 1.2 GB · sealed with Robin's key
After
cx.exportEverything()
contextual-export.sealedOne file · 1.2 GBSealed
Its codeShown once: keep it apart from the file
Fig. 9.2 Before: mail on one computer. After: one sealed file, and the code that opens it.

Chapter 10: The API, the one the app uses

Contextual's own screens use the same HTTP and JSON API as your app. The whole contract is one OpenAPI file.

Send the key as a bearer token. A refusal names the permission it needed, so your app can ask the person for it.

Fig. 10.1 The call, in Shell.
curl https://email.contextual.exchange/v1/now \
  -H "Authorization: Bearer $CONTEXTUAL_KEY"
# The whole contract: GET /v1/openapi.json
Before
Your terminal$ curl /v1/now
After
200
{ "needsYou": [ { "title": "Sign the lease renewal",
    "who": "Maya Osei", "due": "2026-11-20" } ],
  "waiting": [ … ] }
Fig. 10.2 Before: a call. After: the same Now the app shows, as JSON.

Chapter 11: An MCP server for AI agents

Give your own AI assistant Contextual's tools: what needs me, what was agreed, find conversations, file versions, drafts, due dates and my permissions.

Add the server to the assistant's settings with the key in its environment. Each tool needs its permission, every use leaves a receipt, and drafts are never sent.

Fig. 11.1 The call, in Your assistant's settings.
{ "mcpServers": { "contextual": { "command": "contextual-mcp",
  "args": ["--url", "https://app.contextual.exchange", "--read-only"] } } }
# Tools for every part: what_needs_me, search_mail, my_lines, open_line,
# files_search, ways_in, storage_info, my_permissions, …
Before
Your assistant
What do I still owe Rachel?I can't see your mail.
After
With Contextual's tools
What do I still owe Rachel?The signed claim form by Friday. Rachel asked on 16 Nov; here are her words.Used what_needs_me · receipted
Fig. 11.2 Before: an assistant that can't see. After: an answer from the person's own mail, with a receipt.

Chapter 12: The command line

Import mail files, list what needs you, export a case, or call the API, from a terminal.

Running a command is the permission to read the files you hand it, and the receipt says so. Over the API, the key comes from the environment and is never an argument.

Fig. 12.1 The call, in Shell.
contextual import claim.mbox --me robin@vale-home.example --store mail.db
contextual now --store mail.db --json
contextual export --store mail.db --out case.zip --name "Claim 4471"
contextual api lines        # over the API, with CONTEXTUAL_KEY
Before
A folder
claim.mbox312 messages · 48 MB
After
contextual export
case.zip86 messages, 12 files, fingerprints and the Record
Fig. 12.2 Before: a mailbox file. After: a case ZIP with kept messages, files and the Record.

Chapter 13: Signed hooks

Get told when something happens. Each delivery is signed with your hook's secret and the time.

Check the signature and that it is fresh, then act. Deliveries are tried again for up to a day, and only to apps allowed to know.

Two events are coming: new mail filed into a folder, and a file's new version.

Fig. 13.1 The call, in TypeScript, on your server.
import { createHmac, timingSafeEqual } from "node:crypto";
// x-contextual-signature: t=<unix time>,v1=<HMAC-SHA256(secret, t + "." + body)>
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const want = createHmac("sha256", secret).update(`${t}.${body}`).digest();
const ok = timingSafeEqual(Buffer.from(v1, "hex"), want) && Date.now() / 1000 - Number(t) < 300;
Before
Sam's line
Sam shares Proof of fundsView once · 09:30
After
example.com/hook
line.file.sharedSigned · checked · 09:30:02200
mail.filedNot sent yetComing
Fig. 13.2 Before: something happens on a line. After: your server is told, and can prove it came from Contextual.

Chapter 14: Extensions: connectors, readers, actions

An extension says what it asks for and why; the person grants it, and can take it back. Running an extension's own code (connectors, readers, actions) is coming.

The manifest says up front what it asks for, why and for how long. Its code is named by fingerprint in the manifest; an update never widens what it may do.

Fig. 14.1 The call, in manifest.json.
{ "id": "com.example.receipts", "name": "Tidy Receipts", "version": "1.0.0",
  "publisher": "Example Ltd", "summary": "Files your receipts by shop.",
  "kinds": ["reader"],
  "asks": [{ "capability": "mail.read", "why": "To find your receipts" }],
  "maxDays": 30,
  "code": { "url": "https://example.com/receipts-1.0.0.js", "sha256": "<its SHA-256>" } }
Before
manifest.json
Tidy Receipts 1.0.0Asks: mail.read · 30 days
After
Add Tidy Receipts?
It asks toRead your mail: to find your receipts
For 30 daysPinned by fingerprintAllow what I ticked
Fig. 14.2 Before: a manifest. After: the sheet the person sees, with exactly what it asks.

Chapter 16: Receipts and usage

Every grant, use, refusal and revoke is a receipt the person can read, and your app can read them too.

The developer service shows each app's calls and errors for the last day and month: status, method and route only, never what the mail says.

Usage is yours, not the app's: read it signed in to the developer service as yourself. The app's key can't.

Fig. 16.1 The call, in TypeScript.
const receipts = await cx.receipts();   // with the app's key

// Signed in to the developer service as yourself, not with the app's key:
const usage = await me.developerAppUsage(appId);
Before
A month of calls
8,412 calls
After
Usage
Granted: Read your mail09:14
Used: What needs you09:15
Refused: Send mail as you09:20
Fig. 16.2 Before: a number. After: what was granted, used and refused, and when.

Start building

  • Free for any developer to build
  • A sample mailbox from the first minute
  • The same calls on a real account, only as far as the person ticks