Skip to main content

Search

This workflow shows how to search across all clauses in your workspace using tag-based filtering, and how to retrieve the full text of a specific clause by ID.

Overview

1. Search for clauses → POST /clauses/search
2. Fetch a clause → GET /clauses/{id}

All requests require x-api-key, x-workspace-id, and x-app-name headers. See Authentication.


Step 1 — Search for clauses

Search returns clauses across all documents in your workspace, filtered by tag. This is the primary way to find relevant provisions without knowing which document they live in.

API Reference: POST /clauses/search

POST /clauses/search
Content-Type: application/json

Request body:

{
"filter": {
"tagIds": ["tag_001", "tag_002"],
"tagCategoryId": 5
}
}
FieldRequiredDescription
filter.tagIdsYesOne or more tag IDs to filter by
filter.tagCategoryIdNoNarrow results to a specific tag category
curl -X POST https://api.your-domain.com/clauses/search \
-H "x-api-key: YOUR_API_KEY" \
-H "x-workspace-id: YOUR_WORKSPACE_ID" \
-H "x-app-name: my-app" \
-H "Content-Type: application/json" \
-d '{
"filter": {
"tagIds": ["tag_001", "tag_002"]
}
}'

Response (200):

{
"count": 8,
"clauses": [
{
"clauseId": "98001",
"documentId": "10567",
"title": "Payment Terms",
"text": "Payment shall be made within 30 days of the invoice date...",
"depth": 2,
"tagIds": ["tag_001"],
"textBlockId": "70318",
"similarity": 0.92,
"endorsed": false,
"date": "2024-03-01",
"dateLastModified": "2024-04-10"
}
]
}

Key fields:

FieldDescription
clauseIdUnique clause identifier — use this to fetch the full clause
documentIdWhich document this clause belongs to
titleClause heading
textClause text as extracted
depthNesting depth (1 = top-level section)
similarityRelevance score
tagIdsTags applied to this clause

Step 2 — Fetch a clause by ID

Once you have a clauseId from search results, fetch the full clause object directly.

API Reference: GET /clauses/{id}

GET /clauses/{id}
curl https://api.your-domain.com/clauses/12345 \
-H "x-api-key: YOUR_API_KEY" \
-H "x-workspace-id: YOUR_WORKSPACE_ID" \
-H "x-app-name: my-app"

Replace 12345 with the numeric clauseId returned from Step 1.

Response (200):

{
"clause": {
"clauseId": "98001",
"documentId": "10567",
"title": "Payment Terms",
"text": "Payment shall be made within 30 days of the invoice date...",
"depth": 2,
"tagIds": ["tag_001"],
"textBlockId": "70318",
"endorsed": false,
"date": "2024-03-01",
"dateLastModified": "2024-04-10",
"comments": []
}
}