Skip to main content

Quickstart

Submit a contract for review and retrieve the results in under 5 minutes.

Prerequisites

  • A Drafted account with at least one MegaAgent team configured
  • An API key with missions:write scope (create one here)

Step 1 — Get your team ID

You need a team ID to submit a mission. Fetch your available teams:

curl https://app.drafted.li/api/external/v1/teams \
-H "Authorization: Bearer dk_live_YOUR_KEY"
{
"teams": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "NDA Review Team",
"missionTypes": ["redline", "analysis"]
}
]
}

Copy the id of the team you want to use.

Step 2 — Submit a mission

Encode your document as base64 and submit:

# Encode your document
BASE64=$(base64 -i contract.docx)

curl -X POST https://app.drafted.li/api/external/v1/missions \
-H "Authorization: Bearer dk_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d "{
\"teamId\": \"550e8400-e29b-41d4-a716-446655440000\",
\"missionType\": \"redline\",
\"document\": {
\"base64\": \"$BASE64\",
\"filename\": \"contract.docx\",
\"mimeType\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"
},
\"context\": {
\"counterparty\": \"Acme Corp\",
\"agreementType\": \"NDA\"
}
}"

The API returns 202 Accepted immediately:

{
"success": true,
"mission": {
"id": "7f3a9c12-1234-5678-abcd-ef0123456789",
"name": "Contract Review — Acme Corp",
"missionType": "redline",
"status": "pending",
"stage": "incoming"
},
"jobId": "abc123...",
"pollUrl": "/api/external/v1/missions/7f3a9c12-1234-5678-abcd-ef0123456789"
}

Step 3 — Poll for results

Poll the pollUrl until status is "completed":

curl https://app.drafted.li/api/external/v1/missions/7f3a9c12-1234-5678-abcd-ef0123456789 \
-H "Authorization: Bearer dk_live_YOUR_KEY"

While processing, results is null:

{
"mission": { "id": "...", "status": "active", "stage": "reviewing" },
"results": null
}

When complete:

{
"mission": { "id": "...", "status": "completed", "stage": "done" },
"results": {
"findingsCount": 8,
"riskLevel": "high",
"summary": "Found 8 issues across 5 clauses...",
"findings": [
{
"clause": "Section 4.2 — Limitation of Liability",
"severity": "critical",
"issue": "Liability cap is uncapped for IP infringement claims",
"recommendation": "Add a mutual cap of 12 months fees"
}
],
"redlinedDocumentUrl": "https://storage.googleapis.com/..."
}
}

JavaScript example

const API_KEY = process.env.DRAFTED_API_KEY;
const BASE_URL = 'https://app.drafted.li/api/external/v1';

async function reviewContract(docBuffer, filename) {
const base64 = docBuffer.toString('base64');

// Submit
const createRes = await fetch(`${BASE_URL}/missions`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
teamId: '550e8400-e29b-41d4-a716-446655440000',
missionType: 'redline',
document: {
base64,
filename,
mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
},
}),
});

const { mission } = await createRes.json();

// Poll
while (true) {
await new Promise(r => setTimeout(r, 5000));

const pollRes = await fetch(`${BASE_URL}/missions/${mission.id}`, {
headers: { 'Authorization': `Bearer ${API_KEY}` },
});
const data = await pollRes.json();

if (data.mission.status === 'completed') return data.results;
if (data.mission.status === 'failed') throw new Error('Mission failed');
}
}

Next steps