Skip to main content
Upload a contract PDF to a project. The file is stored and queued for processing. You can optionally request specific extractions to run automatically after upload.
Only PDF files are supported. Maximum file size is 50 MB.

Upload Contract

Creates a new contract record and uploads the file. Supports two content types: multipart/form-data for direct file upload, and application/json for base64-encoded files.

Request

POST /v1/contracts

Query Parameters

ParameterTypeRequiredDefaultDescription
projectIdUUIDYesThe project to upload the contract to

Headers

HeaderRequiredDescription
AuthorizationYesBearer <token> — must be scoped to the requested project
Content-TypeYesmultipart/form-data or application/json
AcceptNoSet to text/event-stream for real-time upload progress via SSE

Option A: Multipart Form Data

Upload a file directly using multipart/form-data.
FieldTypeRequiredDescription
fileFileYesThe PDF file to upload
extractionsstringNoJSON array of extraction types to run

Example

curl -X POST "https://api.royaltyport.com/v1/contracts?projectId=a1b2c3d4-..." \
  -H "Authorization: Bearer rp_your_token_here" \
  -F "file=@contract.pdf" \
  -F 'extractions=["extract-royalties","extract-dates"]'

Option B: JSON Body

Upload a base64-encoded file using application/json.
FieldTypeRequiredDefaultDescription
filestringYesBase64-encoded file content
fileNamestringYesThe file name (e.g. contract.pdf)
fileTypestringNoapplication/pdfMIME type of the file
extractionsarrayNoArray of extraction types to run

Example

curl -X POST "https://api.royaltyport.com/v1/contracts?projectId=a1b2c3d4-..." \
  -H "Authorization: Bearer rp_your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "file": "JVBERi0xLjQK...",
    "fileName": "contract.pdf",
    "extractions": ["extract-royalties", "extract-dates"]
  }'

Extraction Types

Pass any combination of the following extraction types to automatically process the contract after upload:
ExtractionDescription
extract-accounting-periodAccounting period definitions
extract-assetsAsset references
extract-commitmentsCommitment clauses
extract-compensationsCompensation terms
extract-control-areasControl area definitions
extract-costsCost provisions
extract-creative-approvalsCreative approval clauses
extract-datesKey dates (effective, termination, etc.)
extract-royaltiesRoyalty terms
extract-signaturesSignature information
extract-splitsRevenue split information
extract-targetsTarget and threshold clauses
extract-balancesBalance provisions and terms

Response

FieldTypeDescription
staging_idintegerUnique identifier for tracking processing progress
staging_stagestringCurrent processing stage (queued, processing, completed, failed)
staging_donebooleanWhether staging (pre-processing) has completed
extractions_donebooleanWhether all extractions have completed
created_atstringUpload timestamp (ISO 8601)
{
  "data": {
    "staging_id": 456,
    "staging_stage": "queued",
    "staging_done": false,
    "extractions_done": false,
    "created_at": "2025-03-01T12:00:00Z"
  }
}

SSE Response

If the Accept header includes text/event-stream, the response is a server-sent event stream with upload progress:
event: progress
data: {"bytesUploaded":3145728,"bytesTotal":10485760,"percent":30}

event: progress
data: {"bytesUploaded":10485760,"bytesTotal":10485760,"percent":100}

event: complete
data: {"data":{"staging_id":456,"staging_stage":"queued","staging_done":false,"extractions_done":false,"created_at":"2025-03-01T12:00:00Z"}}

Errors

StatusDescription
400Missing file, invalid extractions, unsupported file type, or file exceeds 50 MB
403Token is not scoped to the requested project
429Rate limit exceeded
500File upload or database error