Skip to main content
GET
/
api
/
documents
/
{document_id}
/
versions
curl -X POST https://api.raptordata.dev/api/documents/doc-001/reprocess \
  -H "Authorization: Bearer rd_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "chunk_size": 1024,
    "strategy": "semantic",
    "calculate_quality": true
  }'
{
  "versions": [
    {
      "id": "version-001",
      "document_id": "doc-001",
      "version_number": 2,
      "parent_version_id": "version-000",
      "filename": "contract_v2.pdf",
      "mime_type": "application/pdf",
      "file_size_bytes": 1048576,
      "content_hash": "sha256-abc123...",
      "created_at": "2024-01-20T10:00:00Z",
      "variants": [
        {
          "id": "variant-001",
          "version_id": "version-001",
          "config_hash": "abc123",
          "config": {
            "chunk_size": 512,
            "strategy": "semantic"
          },
          "status": "completed",
          "chunks_count": 47,
          "total_tokens": 23450,
          "is_primary": true,
          "created_at": "2024-01-20T10:00:00Z",
          "processed_at": "2024-01-20T10:05:00Z"
        }
      ]
    }
  ],
  "total_count": 2
}

Version Control API

Manage document versions, variants, and version operations.

List Versions

List all versions of a document with their processing variants.

Path Parameters

document_id
string
required
Document ID

Response

versions
array
Array of version objects with their variants
total_count
integer
Total number of versions
{
  "versions": [
    {
      "id": "version-001",
      "document_id": "doc-001",
      "version_number": 2,
      "parent_version_id": "version-000",
      "filename": "contract_v2.pdf",
      "mime_type": "application/pdf",
      "file_size_bytes": 1048576,
      "content_hash": "sha256-abc123...",
      "created_at": "2024-01-20T10:00:00Z",
      "variants": [
        {
          "id": "variant-001",
          "version_id": "version-001",
          "config_hash": "abc123",
          "config": {
            "chunk_size": 512,
            "strategy": "semantic"
          },
          "status": "completed",
          "chunks_count": 47,
          "total_tokens": 23450,
          "is_primary": true,
          "created_at": "2024-01-20T10:00:00Z",
          "processed_at": "2024-01-20T10:05:00Z"
        }
      ]
    }
  ],
  "total_count": 2
}

Get Specific Version

Get a specific version with all its variants.

Path Parameters

document_id
string
required
Document ID
version_number
integer
required
Version number (1, 2, 3, etc.)

Response

Returns a version object with all its variants.
{
  "id": "version-001",
  "document_id": "doc-001",
  "version_number": 2,
  "parent_version_id": "version-000",
  "filename": "contract_v2.pdf",
  "mime_type": "application/pdf",
  "file_size_bytes": 1048576,
  "content_hash": "sha256-abc123...",
  "created_at": "2024-01-20T10:00:00Z",
  "variants": [...]
}

Reprocess Document

Reprocess document with different configuration (creates new variant).

Path Parameters

document_id
string
required
Document ID to reprocess

Request Body

chunk_size
integer
default:"512"
Chunk size in tokens (128-2048)
chunk_overlap
integer
default:"50"
Chunk overlap in tokens (0-512)
strategy
string
default:"semantic"
Chunking strategy: semantic or recursive
process_images
boolean
default:"false"
Process images and figures
extract_section_numbers
boolean
default:"false"
Extract section numbers
calculate_quality
boolean
default:"true"
Calculate quality scores
table_extraction
boolean
default:"true"
Extract tables
table_context_generation
boolean
default:"false"
Generate table context

Response

Returns upload response for the new variant.
{
  "variant_id": "variant-002",
  "document_id": "doc-001",
  "version_id": "version-001",
  "version_number": 2,
  "is_new_document": false,
  "is_new_version": false,
  "is_new_variant": true,
  "status": "pending",
  "task_id": "task-123",
  "estimated_pages": 15
}
curl -X POST https://api.raptordata.dev/api/documents/doc-001/reprocess \
  -H "Authorization: Bearer rd_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "chunk_size": 1024,
    "strategy": "semantic",
    "calculate_quality": true
  }'

Delete Version

Delete a specific version with auto-promotion.

Path Parameters

document_id
string
required
Document ID
version_number
integer
required
Version number to delete

Response

id
string
Deleted version ID
type
string
Resource type (version)
status
string
Deletion status (deleted)
promoted
object
Auto-promoted version info (if latest was deleted)
cascaded
object
Cascade deletion info (if last version)
{
  "id": "version-002",
  "type": "version",
  "status": "deleted",
  "promoted": {
    "type": "version",
    "id": "version-001",
    "version_number": 1,
    "is_now_default": true
  },
  "deleted_at": "2024-01-20T15:00:00Z"
}

Revert to Version

Revert document to a previous version (creates new version).

Path Parameters

document_id
string
required
Document ID
version_number
integer
required
Version number to revert to

Response

reverted
boolean
Whether revert was successful
document_id
string
Document ID
reverted_from_version
integer
Version number reverted from
new_version_number
integer
New version number created
new_version_id
string
New version ID
{
  "reverted": true,
  "document_id": "doc-001",
  "reverted_from_version": 1,
  "new_version_number": 4,
  "new_version_id": "version-004"
}

Set Default Version

Set which version is returned by default.

Path Parameters

document_id
string
required
Document ID

Request Body

version_number
integer
required
Version number to set as default

Response

updated
boolean
Whether update was successful
document_id
string
Document ID
default_version_number
integer
New default version number
latest_version_id
string
Latest version ID
{
  "updated": true,
  "document_id": "doc-001",
  "default_version_number": 2,
  "latest_version_id": "version-002"
}

Update Version Label

Update the human-readable version label.

Path Parameters

document_id
string
required
Document ID

Request Body

version_label
string
required
New version label (e.g., “v2.0”, “Final Draft”)

Response

updated
boolean
Whether update was successful
document_id
string
Document ID
version_label
string
New version label
{
  "updated": true,
  "document_id": "doc-001",
  "version_label": "v2.0 - Final"
}

Get Variant

Get specific processing variant information.

Path Parameters

variant_id
string
required
Variant ID

Response

id
string
Variant ID
version_id
string
Parent version ID
config_hash
string
Configuration hash for deduplication
config
object
Processing configuration (sensitive fields filtered)
status
string
Processing status: pending, processing, completed, failed
error
string
Error message if failed
chunks_count
integer
Number of chunks
total_tokens
integer
Total token count
page_count
integer
Number of pages
credits_charged
number
Credits charged for processing
is_primary
boolean
Whether this is the primary variant for its version
dedup_stats
object
Deduplication statistics
retry_count
integer
Number of retry attempts
is_retrying
boolean
Whether variant is currently retrying
in_dlq
boolean
Whether variant is in dead letter queue
{
  "id": "variant-001",
  "version_id": "version-001",
  "config_hash": "abc123",
  "config": {
    "chunk_size": 512,
    "chunk_overlap": 50,
    "strategy": "semantic"
  },
  "status": "completed",
  "error": null,
  "chunks_count": 47,
  "total_tokens": 23450,
  "page_count": 15,
  "credits_charged": 15.0,
  "is_primary": true,
  "dedup_stats": {
    "chunks_reused": 35,
    "chunks_created": 12,
    "savings_percent": 74.5
  },
  "retry_count": 0,
  "is_retrying": false,
  "in_dlq": false,
  "created_at": "2024-01-20T10:00:00Z",
  "processed_at": "2024-01-20T10:05:00Z"
}

Cancel Variant Processing

Cancel processing for a variant (if still pending/processing).

Path Parameters

variant_id
string
required
Variant ID to cancel

Response

variant_id
string
Cancelled variant ID
status
string
New status (cancelled)
message
string
Success message
credits_refunded
boolean
Whether credits were refunded
{
  "variant_id": "variant-001",
  "status": "cancelled",
  "message": "Processing cancelled successfully",
  "credits_refunded": true
}

Delete Variant

Delete a processing variant with auto-promotion.

Path Parameters

variant_id
string
required
Variant ID to delete

Response

id
string
Deleted variant ID
type
string
Resource type (variant)
status
string
Deletion status (deleted)
promoted
object
Auto-promoted variant info (if default was deleted)
cascaded
object
Cascade info (if last variant)
{
  "id": "variant-002",
  "type": "variant",
  "status": "deleted",
  "promoted": {
    "type": "variant",
    "id": "variant-001",
    "is_now_default": true
  },
  "deleted_at": "2024-01-20T15:00:00Z"
}