Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.chamelio.ai/llms.txt

Use this file to discover all available pages before exploring further.

Endpoint

POST /core/contracts/{document_id}

Authentication

This endpoint requires authentication via API key. Include your API key in the X-API-Key header:
X-API-Key: ca_your_api_key_here

Path Parameters

ParameterTypeRequiredDescription
document_idintegerYesUnique identifier for the document

Request Body

FieldTypeRequiredDefaultDescription
include_summarybooleanNofalseInclude the AI-generated document summary in the response
include_attributesbooleanNofalseInclude document attributes (category, visibility, active status, exhibits, etc.)
include_extracted_fieldsbooleanNotrueInclude the extracted document fields in the response

Request Example

curl -X POST "https://platform.chamelio.ai/core/contracts/42" \
  -H "X-API-Key: ca_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "include_summary": true,
    "include_attributes": true,
    "include_extracted_fields": true
  }'

Response

Success Response

Status Code: 200 OK
{
  "document_id": 42,
  "org_id": 1,
  "version": 3,
  "file_name": "Acme_MSA_2025.pdf",
  "document_title": "Master Service Agreement - Acme Corp",
  "document_type": "MSA",
  "category": "contract",
  "visibility": "visible",
  "active": {
    "value": "active",
    "is_verified": true
  },
  "summary": "Master service agreement between Acme Corp and our organization, covering SaaS platform licensing and support services.",
  "exhibits": ["Exhibit A - Pricing", "Exhibit B - SLA"],
  "attachments_ids": [101, 102],
  "previous_versions": [38, 35],
  "fields": [
    {
      "field_name": "Counterparty",
      "field_value_type": "text",
      "org_field_id": 1,
      "is_verified": true,
      "is_unclear": false,
      "reasoning": "Extracted from the first page header",
      "source_text": ["This agreement is entered into by Acme Corporation"],
      "chunk_ids": [1],
      "text_value": "Acme Corporation"
    },
    {
      "field_name": "Contract Value",
      "field_value_type": "number",
      "org_field_id": 2,
      "is_verified": false,
      "is_unclear": false,
      "reasoning": "Found in Section 4 - Pricing",
      "source_text": ["The total contract value shall not exceed $150,000"],
      "chunk_ids": [4],
      "number_value": 150000.0
    },
    {
      "field_name": "Auto-Renewal",
      "field_value_type": "boolean",
      "org_field_id": 3,
      "is_verified": false,
      "is_unclear": false,
      "reasoning": "Found in Section 8 - Term",
      "source_text": ["This agreement shall automatically renew"],
      "chunk_ids": [8],
      "boolean_value": true
    },
    {
      "field_name": "Effective Date",
      "field_value_type": "date",
      "org_field_id": 4,
      "is_verified": true,
      "is_unclear": false,
      "reasoning": "Found on the signature page",
      "source_text": ["Effective as of January 15, 2025"],
      "chunk_ids": [12],
      "date_value": "2025-01-15"
    },
    {
      "field_name": "Contract Type",
      "field_value_type": "enum",
      "org_field_id": 5,
      "is_verified": false,
      "is_unclear": false,
      "reasoning": "Determined from the document title and content",
      "source_text": null,
      "chunk_ids": null,
      "enum_value": "Master Service Agreement"
    },
    {
      "field_name": "Unclear Field Example",
      "field_value_type": "text",
      "org_field_id": 6,
      "is_verified": false,
      "is_unclear": true,
      "reasoning": "Multiple conflicting values found in the document",
      "source_text": ["Amount: $50,000", "Total: $75,000"],
      "chunk_ids": [3, 7],
      "text_value": null
    }
  ],
  "mapped_fields": {
    "text": {
      "vendor_name": "Acme Corporation"
    },
    "number": {
      "total_value": 150000.0
    },
    "boolean": {
      "auto_renew": true
    },
    "date": {
      "effective_date": "2025-01-15T00:00:00Z"
    },
    "link": {}
  },
  "workflow_metadata": {
    "workflow_state_id": "ws_abc123",
    "workflow_id": "vendor_contract_review",
    "org_id": 1,
    "user_id": 10,
    "workflow_version": 2,
    "task_id": 5001
  },
  "related_template": {
    "template_id": 7,
    "template_version": 1
  },
  "document_created_at": "2025-01-15T10:30:00Z",
  "source": "external_api",
  "uploaded_by_user_id": 10
}

Response Fields

FieldTypeDescription
document_idintegerUnique identifier for the document
org_idintegerOrganization identifier
versionintegerDocument schema version
file_namestringOriginal file name
document_titlestring or nullHuman-readable document title
document_typestringType of document (e.g., “MSA”, “NDA”, “SOW”)
categorystringDocument category: contract, policy, template, archive
visibilitystringVisibility level: none, visible, admin_only, archive
activeobjectActive status with verification flag (see below)
summarystring or nullAI-generated summary of the document
exhibitsarray of stringsList of exhibit names found in the document
attachments_idsarray of integersIDs of attached documents
previous_versionsarray of integersDocument IDs of previous versions
fieldsarrayExtracted document fields (see below)
mapped_fieldsobjectKey-value pairs grouped by type (see below)
workflow_metadataobject or nullWorkflow context if the document is part of a workflow
related_templateobject or nullAssociated template information
document_created_atstring or nullISO 8601 timestamp of the original document date
sourcestring or nullHow the document was ingested: drive, sharepoint, local, email, workflow, integration, external_api, docusign, salesforce
uploaded_by_user_idinteger or nullID of the user who uploaded the document

Active Object

FieldTypeDescription
valuestringActive status: active, inactive, unknown
is_verifiedbooleanWhether the active status has been verified by a user

Field Object

Each field in the fields array represents an extracted data point from the document. The value field varies by type.

Common Fields

FieldTypeDescription
field_namestringDisplay name of the field
field_value_typestringType discriminator: text, clause, enum, number, boolean, date, bullet_list, business, user_party
org_field_idintegerOrganization-level field definition ID
is_verifiedbooleanWhether the value has been verified by a user
is_unclearbooleanWhether the AI could not determine a clear value
reasoningstring or nullAI reasoning for the extracted value
source_textarray of strings or nullRelevant text excerpts from the document
chunk_idsarray of integers or nullDocument chunk IDs where the value was found

Value Fields by Type

field_value_typeValue FieldTypeDescription
texttext_valuestring or nullPlain text value
clausetext_valuestring or nullContract clause text
enumenum_valuestring or nullSelected option from a predefined list
businessenum_valuestring or nullBusiness entity name
businessbusiness_idinteger or nullBusiness entity ID
user_partyenum_valuestring or nullUser party value
numbernumber_valuenumber or nullNumeric value
booleanboolean_valueboolean or nullTrue/false value
datedate_valuestring or nullISO 8601 date
bullet_listjson_valueobject/array or nullStructured list data
When is_unclear is true, the value field will be null — this means the AI found conflicting or ambiguous information in the document.

Mapped Fields Object

Pre-mapped key-value pairs organized by data type. These are populated from workflow metadata.
FieldTypeDescription
textobjectString key-value pairs
numberobjectNumeric key-value pairs
booleanobjectBoolean key-value pairs
dateobjectDate key-value pairs (ISO 8601 values)
linkobjectURL key-value pairs

Workflow Metadata Object

Present when the document is associated with a workflow.
FieldTypeDescription
workflow_state_idstringWorkflow state identifier
workflow_idstringWorkflow definition identifier
org_idintegerOrganization ID
user_idintegerUser who initiated the workflow
workflow_versioninteger or nullWorkflow version number
task_idinteger or nullAssociated task ID
Present when the document was created from a template.
FieldTypeDescription
template_idintegerTemplate identifier
template_versionintegerTemplate version number

Error Responses

401 Unauthorized

Returned when authentication fails. See the authentication errors section for details.
{
  "detail": "Invalid API key"
}

404 Not Found

Returned when the document doesn’t exist or you don’t have access to it.
{
  "detail": "Document not found"
}

500 Internal Server Error

Returned when the request fails due to a server error.
{
  "detail": "Failed to get contract data"
}

Use Cases

  • Contract review - Retrieve all extracted fields and metadata for a contract
  • Data synchronization - Pull contract data into external systems (CRM, ERP)
  • Reporting - Build dashboards from extracted contract fields
  • Compliance checks - Verify key contract terms like renewal dates and values
  • Workflow integration - Access document data as part of automated workflows