Skip to content

API Quickstart

This guide walks you through creating a container, adding a document with clauses, publishing it, and sending a signing request — all via the REST API.

  • A TheTerms account with an organisation
  • An API key (see Authentication)
  • curl or any HTTP client

Set your API key as an environment variable for the examples below:

Terminal window
export THETERMS_API_KEY="tt_your_api_key_here"
export THETERMS_URL="https://app.theterms.app/api/v1"
  1. Create a container

    Containers group related documents. Create one for your Terms of Service:

    Terminal window
    curl -X POST "$THETERMS_URL/containers" \
    -H "X-Api-Key: $THETERMS_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"name": "Website Agreements", "description": "All website legal documents"}'

    Response:

    {
    "data": {
    "id": "clx1abc...",
    "name": "Website Agreements",
    "description": "All website legal documents",
    "createdAt": "2026-02-21T10:00:00.000Z"
    }
    }

    Save the id — you will need it in the next step.

  2. Create a document

    Create a document inside the container. It starts as a draft (version 1):

    Terminal window
    curl -X POST "$THETERMS_URL/containers/{containerId}/documents" \
    -H "X-Api-Key: $THETERMS_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"title": "Terms of Service"}'

    Save the document id and activeVersionId from the response.

  3. Update the document version with clauses

    Add clauses to the draft version:

    Terminal window
    curl -X PUT "$THETERMS_URL/documents/{documentId}/versions/{versionId}" \
    -H "X-Api-Key: $THETERMS_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "clauses": [
    {
    "id": "clause-1",
    "title": "Acceptable Use",
    "content": {"type": "doc", "content": [{"type": "paragraph", "content": [{"type": "text", "text": "You agree to use the service only for lawful purposes."}]}]},
    "mandatory": true,
    "order": 0
    },
    {
    "id": "clause-2",
    "title": "Marketing Communications",
    "content": {"type": "doc", "content": [{"type": "paragraph", "content": [{"type": "text", "text": "We may send you promotional emails about new features."}]}]},
    "mandatory": false,
    "order": 1
    }
    ]
    }'
  4. Publish the version

    Publishing makes the document active and available for signing:

    Terminal window
    curl -X POST "$THETERMS_URL/documents/{documentId}/versions/{versionId}/publish" \
    -H "X-Api-Key: $THETERMS_API_KEY"
  5. Send a signing request

    Invite someone to sign the published document:

    Terminal window
    curl -X POST "$THETERMS_URL/documents/{documentId}/signing-requests" \
    -H "X-Api-Key: $THETERMS_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "signerName": "Jane Doe",
    "signerEmail": "jane@example.com"
    }'

    The signer receives an email with a unique link to review and sign the document. No account creation is required.

  6. Check signing status

    List signing requests for the document:

    Terminal window
    curl "$THETERMS_URL/documents/{documentId}/signing-requests" \
    -H "X-Api-Key: $THETERMS_API_KEY"

    Each request includes a status field (PENDING, VIEWED, COMPLETED, EXPIRED) and clause-level responses when completed.