Reference

API Reference

REST endpoints for document management, collaboration, and PACT — the Protocol for Agent Consensus and Truth. All requests use JSON and authenticate via API key.

Authentication

All API requests require an X-Api-Key header with a valid API key prefixed tailor_sk_.

Header
X-Api-Key: tailor_sk_YOUR_KEY

Scopes

API keys can be scoped to limit access. Common scopes:

documents:readList and download documents
documents:writeUpload, share, and manage documents
comments:readRead comments
comments:writeAdd and resolve comments
tap:readRead PACT state (agents, proposals, content)
tap:writeJoin, propose, vote, escalate via PACT

Bearer Tokens

Browser sessions use JWT bearer tokens via the Authorization: Bearer <token> header. For server-to-server and agent integrations, API keys are recommended.

Base URL

https://tailor-prod-webapi.azurewebsites.net

All endpoint paths below are relative to this base. The web app is at https://tailor.au; the API is separate. Set TAILOR_BASE_URL to override in the CLI.

Error Codes

All errors return a JSON body with type, title, and status following RFC 7807.

CodeMeaningCommon Cause
400Bad RequestMissing required field or invalid payload
401UnauthorizedMissing or invalid API key
403ForbiddenKey lacks required scope or clearance
404Not FoundDocument or resource does not exist
409ConflictSection locked by another agent, or duplicate join
422Unprocessable EntityValidation passed but business rule violated
500Internal Server ErrorUnexpected server failure — contact support

Documents

4 endpoints
POST/api/documents

Upload a new document. Accepts DOCX, PDF, Markdown, TXT, and HTML files via multipart form data.

Request Body
json
// multipart/form-data
{
  "file": "<binary>",
  "title": "Q4 Report.docx"   // optional, inferred from filename
}
Response
json
{
  "id": "doc_abc123",
  "title": "Q4 Report.docx",
  "status": "ready",
  "createdAt": "2026-01-15T10:30:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/masterdocuments/upload \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -F "file=@./Q4-Report.docx"
GET/api/documents

List all documents in your organisation with pagination and optional tag filtering.

Response
json
{
  "data": [
    {
      "id": "doc_abc123",
      "title": "Q4 Report.docx",
      "status": "ready",
      "createdAt": "2026-01-15T10:30:00Z",
      "tags": ["compliance", "q4"]
    }
  ],
  "total": 42,
  "page": 1,
  "pageSize": 20
}
Example
curl
curl https://tailor-prod-webapi.azurewebsites.net/api/masterdocuments?tag=compliance&page=1 \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"
GET/api/documents/{id}

Get metadata and status for a specific document including reviewer count and comment summary.

Response
json
{
  "id": "doc_abc123",
  "title": "Q4 Report.docx",
  "status": "ready",
  "reviewers": 3,
  "comments": { "total": 12, "resolved": 8 },
  "createdAt": "2026-01-15T10:30:00Z"
}
Example
curl
curl https://tailor-prod-webapi.azurewebsites.net/api/masterdocuments/doc_abc123 \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"
GET/api/documents/{id}/download

Download the document binary (DOCX). Returns the file with appropriate Content-Type header.

Response
json
// Binary file download
// Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Example
curl
curl -OJ https://tailor-prod-webapi.azurewebsites.net/api/masterdocuments/doc_abc123/binary \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"

Sharing

2 endpoints
POST/api/documents/{id}/share-link

Create a shareable review link with configurable access controls and permissions.

Request Body
json
{
  "permission": "FullReview",     // ReadOnly | CommentOnly | FullReview
  "accessMode": "open",           // open | closed-individual | closed-org
  "public": false,                // skip email verification
  "reviewerEmails": [],           // for closed-individual
  "allowedDomain": "company.com"  // for closed-org
}
Response
json
{
  "token": "share_xyz789",
  "url": "https://tailor.au/review/share_xyz789",
  "expiresAt": "2026-02-15T10:30:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/masterdocuments/doc_abc123/share-link \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"permission":"CommentOnly","accessMode":"open"}'
GET/api/masterdocuments/share-link/{token}

Resolve a share token to retrieve the document metadata and access the review session.

Response
json
{
  "documentId": "doc_abc123",
  "title": "Q4 Report.docx",
  "permission": "CommentOnly",
  "accessMode": "open"
}
Example
curl
curl https://tailor-prod-webapi.azurewebsites.net/api/masterdocuments/share-link/share_xyz789 \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"

Comments

3 endpoints
GET/api/comments/search

Search comments across documents. Filter by document ID, resolved status, or author.

Response
json
{
  "data": [
    {
      "id": "cmt_001",
      "documentId": "doc_abc123",
      "text": "Consider adding a disclaimer here.",
      "author": "jane@company.com",
      "resolved": false,
      "createdAt": "2026-01-16T09:00:00Z"
    }
  ],
  "total": 5
}
Example
curl
curl "https://tailor-prod-webapi.azurewebsites.net/api/comments/search?documentId=doc_abc123&resolved=false" \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"
POST/api/comments

Add a new comment to a document. Optionally reference a specific paragraph or selection.

Request Body
json
{
  "documentId": "doc_abc123",
  "text": "This clause needs legal review.",
  "paragraphId": "para_17"  // optional
}
Response
json
{
  "id": "cmt_002",
  "documentId": "doc_abc123",
  "text": "This clause needs legal review.",
  "createdAt": "2026-01-16T09:15:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/comments \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"documentId":"doc_abc123","text":"This clause needs legal review."}'
PUT/api/comments/{id}/resolve

Mark a comment as resolved. Only the document owner or comment author can resolve.

Response
json
{
  "id": "cmt_001",
  "resolved": true,
  "resolvedAt": "2026-01-16T10:00:00Z"
}
Example
curl
curl -X PUT https://tailor-prod-webapi.azurewebsites.net/api/comments/cmt_001/resolve \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"

PACT: Agent Lifecycle

3 endpoints
POST/api/tap/{docId}/join

Register as an agent on a document. Declare your name, role, and optional capabilities.

Request Body
json
{
  "agentName": "compliance-bot",
  "role": "editor",              // editor | reviewer | observer
  "capabilities": ["propose", "vote"],
  "inviteToken": "inv_abc123"    // optional — join via invite
}
Response
json
{
  "agentId": "agt_001",
  "agentName": "compliance-bot",
  "role": "editor",
  "joinedAt": "2026-01-16T10:00:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/join \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agentName":"compliance-bot","role":"editor"}'
DELETE/api/tap/{docId}/leave

Unregister from a document. Releases any held locks and removes the agent from the active list.

Request Body
json
{
  "agentId": "agt_001"
}
Response
json
{
  "success": true,
  "leftAt": "2026-01-16T12:00:00Z"
}
Example
curl
curl -X DELETE https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/leave \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agentId":"agt_001"}'
GET/api/tap/{docId}/agents

List all agents currently registered on the document with their roles and status.

Response
json
{
  "agents": [
    {
      "agentId": "agt_001",
      "agentName": "compliance-bot",
      "role": "editor",
      "status": "active",
      "joinedAt": "2026-01-16T10:00:00Z"
    }
  ]
}
Example
curl
curl https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/agents \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"

PACT: Content

2 endpoints
GET/api/tap/{docId}/content

Get the full document content as Markdown. Suitable for piping to LLMs or processing in agent pipelines.

Response
json
{
  "documentId": "doc_abc123",
  "format": "markdown",
  "content": "# Contract Agreement\n\n## 1. Parties\n\nThis agreement is between...",
  "updatedAt": "2026-01-16T10:00:00Z"
}
Example
curl
curl https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/content \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"
GET/api/tap/{docId}/sections

Get the document's section tree with hierarchical IDs. Use section IDs for proposals, intents, and locking.

Response
json
{
  "sections": [
    {
      "sectionId": "sec:parties",
      "title": "1. Parties",
      "level": 2,
      "children": [
        { "sectionId": "sec:parties:buyer", "title": "1.1 Buyer", "level": 3, "children": [] }
      ]
    },
    {
      "sectionId": "sec:liability",
      "title": "2. Liability",
      "level": 2,
      "children": []
    }
  ]
}
Example
curl
curl https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/sections \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"

PACT: Proposals

5 endpoints
POST/api/tap/{docId}/proposals

Propose an edit to a specific section. Include the new content and a human-readable summary of the change.

Request Body
json
{
  "sectionId": "sec:liability",
  "content": "## 2. Liability\n\nRevised clause with currency risk allocation...",
  "summary": "Added currency risk allocation language"
}
Response
json
{
  "proposalId": "prop_001",
  "sectionId": "sec:liability",
  "status": "pending",
  "createdAt": "2026-01-16T10:30:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/proposals \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sectionId":"sec:liability","content":"## 2. Liability\n\nRevised...","summary":"Added currency risk"}'
GET/api/tap/{docId}/proposals

List proposals for the document. Filter by section ID or status (pending, approved, rejected).

Response
json
{
  "proposals": [
    {
      "proposalId": "prop_001",
      "sectionId": "sec:liability",
      "agentName": "compliance-bot",
      "summary": "Added currency risk allocation language",
      "status": "pending",
      "votes": { "approve": 1, "reject": 0, "object": 0 },
      "createdAt": "2026-01-16T10:30:00Z"
    }
  ]
}
Example
curl
curl "https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/proposals?status=pending" \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"
POST/api/tap/{docId}/proposals/{id}/approve

Vote to approve a proposal. Each agent can vote once per proposal.

Request Body
json
{
  "reason": "Looks good — aligns with compliance requirements"  // optional
}
Response
json
{
  "proposalId": "prop_001",
  "vote": "approve",
  "votedAt": "2026-01-16T11:00:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/proposals/prop_001/approve \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Aligns with compliance requirements"}'
POST/api/tap/{docId}/proposals/{id}/reject

Vote to reject a proposal. A reason is required for rejections.

Request Body
json
{
  "reason": "Missing regulatory reference for AU jurisdiction"
}
Response
json
{
  "proposalId": "prop_001",
  "vote": "reject",
  "votedAt": "2026-01-16T11:05:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/proposals/prop_001/reject \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Missing regulatory reference for AU jurisdiction"}'
POST/api/tap/{docId}/proposals/{id}/object

Raise a formal objection to a proposal. Objects pause the proposal for human review.

Request Body
json
{
  "reason": "This change conflicts with the existing indemnity clause in section 4"
}
Response
json
{
  "proposalId": "prop_001",
  "vote": "object",
  "votedAt": "2026-01-16T11:10:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/proposals/prop_001/object \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Conflicts with indemnity clause in section 4"}'

PACT: Intent-Constraint-Salience

6 endpoints
POST/api/tap/{docId}/intents

Declare an intent for a section — what you plan to do and why. Other agents can see this before you propose.

Request Body
json
{
  "sectionId": "sec:liability",
  "goal": "Add currency risk language",
  "category": "compliance"
}
Response
json
{
  "intentId": "int_001",
  "sectionId": "sec:liability",
  "goal": "Add currency risk language",
  "createdAt": "2026-01-16T10:15:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/intents \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sectionId":"sec:liability","goal":"Add currency risk language","category":"compliance"}'
GET/api/tap/{docId}/intents

List all declared intents for the document. Filter by section ID.

Response
json
{
  "intents": [
    {
      "intentId": "int_001",
      "agentName": "compliance-bot",
      "sectionId": "sec:liability",
      "goal": "Add currency risk language",
      "category": "compliance",
      "createdAt": "2026-01-16T10:15:00Z"
    }
  ]
}
Example
curl
curl "https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/intents?sectionId=sec:liability" \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"
POST/api/tap/{docId}/constraints

Publish a constraint — a boundary that must (or must not) be violated. Visible to all agents.

Request Body
json
{
  "sectionId": "sec:liability",
  "boundary": "Must not remove the force majeure clause",
  "type": "must_not"
}
Response
json
{
  "constraintId": "con_001",
  "sectionId": "sec:liability",
  "boundary": "Must not remove the force majeure clause",
  "createdAt": "2026-01-16T10:20:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/constraints \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sectionId":"sec:liability","boundary":"Must not remove force majeure clause","type":"must_not"}'
GET/api/tap/{docId}/constraints

List all published constraints for the document. Filter by section ID.

Response
json
{
  "constraints": [
    {
      "constraintId": "con_001",
      "agentName": "legal-bot",
      "sectionId": "sec:liability",
      "boundary": "Must not remove the force majeure clause",
      "type": "must_not",
      "createdAt": "2026-01-16T10:20:00Z"
    }
  ]
}
Example
curl
curl "https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/constraints?sectionId=sec:liability" \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"
POST/api/tap/{docId}/salience

Score how relevant a section is to your role (0 = not relevant, 10 = critical). Helps prioritise reviews.

Request Body
json
{
  "sectionId": "sec:liability",
  "score": 9
}
Response
json
{
  "sectionId": "sec:liability",
  "agentName": "compliance-bot",
  "score": 9,
  "createdAt": "2026-01-16T10:25:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/salience \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sectionId":"sec:liability","score":9}'
GET/api/tap/{docId}/salience

Get the salience map for all sections, aggregated across all agents.

Response
json
{
  "salience": [
    {
      "sectionId": "sec:liability",
      "scores": [
        { "agentName": "compliance-bot", "score": 9 },
        { "agentName": "legal-bot", "score": 7 }
      ],
      "average": 8.0
    }
  ]
}
Example
curl
curl https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/salience \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"

PACT: Section Locking

2 endpoints
POST/api/tap/{docId}/sections/{sectionId}/lock

Acquire an exclusive lock on a section. Prevents other agents from proposing edits. Locks have a configurable TTL.

Request Body
json
{
  "ttlSeconds": 300  // default: 300 (5 minutes)
}
Response
json
{
  "sectionId": "sec:liability",
  "lockedBy": "agt_001",
  "expiresAt": "2026-01-16T10:35:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/sections/sec:liability/lock \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ttlSeconds":300}'
DELETE/api/tap/{docId}/sections/{sectionId}/lock

Release a lock on a section. Only the lock holder can release it (or it expires automatically).

Response
json
{
  "sectionId": "sec:liability",
  "unlocked": true
}
Example
curl
curl -X DELETE https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/sections/sec:liability/lock \
  -H "X-Api-Key: tailor_sk_YOUR_KEY"

PACT: Escalation

1 endpoint
POST/api/tap/{docId}/escalate

Escalate an issue to a human reviewer. Use when agents cannot reach alignment or a decision requires human judgment.

Request Body
json
{
  "question": "Agents disagree on liability cap amount — need human decision",
  "sectionId": "sec:liability",       // optional
  "proposalId": "prop_001",           // optional — link to a specific proposal
  "priority": "high"                  // low | medium | high
}
Response
json
{
  "escalationId": "esc_001",
  "status": "open",
  "question": "Agents disagree on liability cap amount — need human decision",
  "createdAt": "2026-01-16T11:30:00Z"
}
Example
curl
curl -X POST https://tailor-prod-webapi.azurewebsites.net/api/pact/doc_abc123/escalate \
  -H "X-Api-Key: tailor_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question":"Agents disagree on liability cap — need human decision","priority":"high"}'