Developer guide
Shorten and manage links from the REST API, an AI agent, or your scripts.
Quick start
p.turl.ca shares your pastebin.ca account — nothing new to sign up for. Mint an API key bound to this site, then shorten URLs from your scripts or an AI agent.
Audience-boundA
link:* key only works on p.turl.ca; it is rejected everywhere else.curl -sS https://p.turl.ca/api/v1/links \
-H 'Authorization: Bearer pbca_live_…' \
-H 'content-type: application/json' \
-d '{"url":"https://example.com/a/very/long/link"}'REST API
Send your API key as Authorization: Bearer <api-key>. Signed-in cookie sessions also work; API-key callers must hold the matching scope. The full spec is at /api/v1/openapi.json.
Scopes
link:read link:create link:delete
| Action | Method & path | Scope |
|---|---|---|
| Shorten a URL | POST /api/v1/links | link:create |
| Read one of your links | GET /api/v1/links/:code | link:read |
| Expand any code (public) | GET /api/v1/expand/:code | — |
| List your links | GET /api/v1/account/links | link:read |
| List capture versions | GET /api/v1/links/:code/captures | link:read |
| Request a new capture | POST /api/v1/links/:code/captures | link:create |
| Publish a completed capture | POST /api/v1/links/:code/captures/:capture/publish | link:create |
| Download a versioned visual | GET /api/v1/links/:code/captures/:capture/visual | link:read |
| Retire one of your links | DELETE /api/v1/links/:code | link:delete |
| Report abuse | POST /api/v1/abuse | — |
Trust tiersOnly clean family links in redirect mode go straight through. Clean high/open links and every citation link show a preview; pending links show a safety-check page. Anonymous browser creates require Turnstile and run a live safety check. Citation mode for arbitrary open-tier destinations still requires a signed-in account. Pointing a turl at another known URL shortener is unsupported and returns
400 {"error":"shortener_destination"} — submit the original destination instead.Creation outcomesCreate responses (including live SSE and MCP) report
resolves as redirect or preview, explain the assigned tier with trust_reason, and include expires_at. Owner read/list responses report current resolves behavior, including gone later in the lifecycle. Use these fields instead of inferring behavior from trust or scan_state.Citation capture is stagedCitation mode always remains preview-first. A configured account rollout may also admit an asynchronous source capture; the create response reports that admission separately. Capture history reports queue age, attempts, completion, partial, blocked, and failed states. Exact source HTML is download-only, public documents are forced attachments, and public replay is a newly serialized scriptless derivative on a separately configured content origin. No retention or durability SLA is implied.
Why links are immutableA short code keeps its original destination URL. To use a different destination, create a new link. The page at that destination can still change. Custom aliases and destination editing are not supported.
curl -sS https://p.turl.ca/api/v1/expand/abc1234curl -sS https://p.turl.ca/api/v1/account/links \
-H 'Authorization: Bearer pbca_live_…'MCP for AI agents
p.turl.ca runs a Model Context Protocol server at https://p.turl.ca/mcp, so Claude Desktop, Cursor, the MCP Inspector, and other agents can shorten and manage links directly.
Option B — API-key bearer (automation)
For headless use, send a minted key directly:
{
"mcpServers": {
"turl": {
"url": "https://p.turl.ca/mcp",
"headers": { "Authorization": "Bearer pbca_live_…" }
}
}
}pbca account api-key create \
--scopes link:read,link:create,link:delete \
--audience https://p.turl.caTools
| Tool | Scope | Purpose |
|---|---|---|
whoami | — | Echo account id, scopes, audience, and token kind. |
create_link | link:create | Shorten a URL; returns resolution, trust reason, safety state, and expiry. |
get_link | link:read | Fetch one link with its current resolution behavior. |
list_my_links | link:read | List links with current resolution behavior; cursor-paginated. |
delete_link | link:delete | Retire one of the caller's links. |
OAuth & DPoP
pastebin.ca is the OAuth authorization server; p.turl.ca is a protected resource and never mints tokens.
- OAuth tokens are audience-bound to
https://p.turl.ca/mcp(RFC 8707) and honored only on the MCP route. - If a key is DPoP-bound (RFC 9449), every MCP request must carry a matching ES256 proof; replays are rejected. Plain bearer keys work without DPoP.
- Revoke a key or connected app anytime from your pastebin.ca account.
Discovery
| Document | URL |
|---|---|
| OpenAPI 3.1 | /api/v1/openapi.json |
| Agent card | /.well-known/agent.json |
| MCP protected resource | /.well-known/oauth-protected-resource/mcp |
| LLM site map | /llms.txt |