Skip to main content

Document Upload API

Centralized API for managing file uploads across all Mantis models. Supports uploading, retrieving, and deleting PDF documents and images for technical staff, vehicles, equipment, projects, and more.

Upload or Replace File

curl -X POST https://api.mantis.com/api/load_files/ \
  -F "model_type=technical" \
  -F "object_id=123" \
  -F "field_name=license_file" \
  -F "file=@/path/to/license.pdf"
Upload a new file or replace an existing one. If a file already exists in the field, it will be deleted and replaced with the new upload.

Form Data Parameters

model_type
string
required
Type of model to upload file for. Valid options:
  • technical - Technical staff member
  • vaccination_record - Vaccination record
  • pass_technical - Technical access pass
  • certification_vehicle - Vehicle certification
  • pass_vehicle - Vehicle pass
  • vehicle - Vehicle
  • custody_chain - Custody chain
  • sheet_project - Work sheet/project
  • shipping_guide - Shipping guide
  • resource_item - Equipment/resource item
object_id
integer
required
ID of the specific object to attach the file to
field_name
string
required
Name of the file field. Valid fields depend on model_type. See Model File Fields below.
file
file
required
The file to upload. Must be a valid PDF (for most fields) or image (for image fields).
invoice_reference
string
Invoice reference number (only used when uploading invoice_file to sheet_project)

Response

success
boolean
Indicates if the upload was successful
message
string
Human-readable message about the operation
data
object
Upload result details
model_type
string
Model type that was updated
object_id
integer
Object ID that was updated
field_name
string
Field name that received the file
file_name
string
Name of the uploaded file
file_url
string
URL to access the uploaded file
{
  "success": true,
  "message": "Archivo subido correctamente al campo \"license_file\".",
  "data": {
    "model_type": "technical",
    "object_id": 123,
    "field_name": "license_file",
    "file_name": "license.pdf",
    "file_url": "/media/technicals/licenses/license_123.pdf"
  }
}

Delete File

curl -X DELETE "https://api.mantis.com/api/load_files/?model_type=technical&object_id=123&field_name=license_file"
Delete a file from a model instance. The file is removed from storage and the field is set to null.

Query Parameters

model_type
string
required
Type of model (same as upload)
object_id
integer
required
ID of the object
field_name
string
required
Name of the file field to clear

Response

success
boolean
Indicates if deletion was successful
message
string
Human-readable message about the operation
data
object
Deletion confirmation
{
  "success": true,
  "message": "Archivo eliminado del campo \"license_file\".",
  "data": {
    "model_type": "technical",
    "object_id": 123,
    "field_name": "license_file"
  }
}

Get File Information

curl -X GET "https://api.mantis.com/api/load_files/?model_type=technical&object_id=123&field_name=license_file"
Retrieve information about a file attached to a model instance.

Query Parameters

model_type
string
required
Type of model
object_id
integer
required
ID of the object
field_name
string
required
Name of the file field

Response

success
boolean
Indicates if the query was successful
data
object
File information
model_type
string
Model type queried
object_id
integer
Object ID queried
field_name
string
Field name queried
has_file
boolean
Whether a file exists in this field
file_name
string
Name of the file (if exists)
file_url
string
URL to access the file (if exists)

Get Model File Fields

curl -X GET "https://api.mantis.com/api/load_files/fields/?model_type=technical"
Retrieve the list of valid file fields for a specific model type, or all model types.

Query Parameters

model_type
string
Specific model type to query (optional - omit to get all models)

Response

success
boolean
Indicates if the query was successful
data
object
File field information by model type
{
  "success": true,
  "data": {
    "model_type": "technical",
    "fields": [
      "dni_file",
      "license_file",
      "vaccine_certificate_file"
    ]
  }
}

Get Document Tree

curl -X GET https://api.mantis.com/api/load_files/tree/
Retrieve a hierarchical tree structure of all documents in the system, organized by category (technicals, vehicles, equipment, projects).

Response

success
boolean
Indicates if the query was successful
data
object
Hierarchical document structure
technicals
array
Technical staff with their passes and vaccination records
vehicles
array
Vehicles with their passes and certifications
equipment
array
Equipment/resource items with images
projects
array
Projects with sheets, custody chains, and shipping guides

Get Project Document Tree

curl -X GET https://api.mantis.com/api/load_files/project/789/tree/
Retrieve the document tree for a specific project, including work sheets, custody chains, and shipping guides.

Path Parameters

project_id
integer
required
Project ID

Response

success
boolean
Indicates if the query was successful
data
object
Project document structure
project
object
Project information
sheets
array
Work sheets with their files and custody chains
shipping_guides
array
Shipping guides with their files
stats
object
Document statistics (total files, loaded files)

Bulk Custody Chain Upload

curl -X POST https://api.mantis.com/api/load_files/project/789/bulk_custody/ \
  -F "file=@/path/to/custody_chains.pdf" \
  -F 'chain_ids=[101,102,103,104]'
Upload a multi-page PDF where each page corresponds to a specific custody chain. The PDF is automatically split and each page is assigned to the corresponding chain in order.

Path Parameters

project_id
integer
required
Project ID that owns the custody chains

Form Data Parameters

file
file
required
Multi-page PDF file
chain_ids
array
required
JSON array of custody chain IDs in the same order as PDF pages

Validation Rules

  • Number of PDF pages must exactly match number of chain IDs
  • All chain IDs must belong to the specified project
  • All chains must be active (not deleted)

Response

success
boolean
Overall success status (true only if all pages processed without errors)
saved
integer
Number of pages successfully saved
errors_count
integer
Number of errors encountered
message
string
Human-readable summary
details
array
Array of successfully saved chain assignments
errors
array
Array of errors encountered during processing
{
  "success": true,
  "saved": 4,
  "errors_count": 0,
  "details": [
    {
      "chain_id": 101,
      "consecutive": "CC-001",
      "page": 1,
      "filename": "CadenaCustodia_CC-001_ProjectName.pdf"
    },
    {
      "chain_id": 102,
      "consecutive": "CC-002",
      "page": 2,
      "filename": "CadenaCustodia_CC-002_ProjectName.pdf"
    }
  ],
  "errors": [],
  "message": "Se asignaron 4 archivo(s) correctamente."
}

Model File Fields

Technical Staff

  • dni_file - National ID document (PDF)
  • license_file - Driver’s license (PDF)
  • vaccine_certificate_file - Vaccination certificate (PDF)

Vaccination Record

  • vaccine_file - Individual vaccine record (PDF)

Technical Pass

  • pass_file - Access pass document (PDF)

Vehicle

  • vehicle_image - Vehicle photo (image)
  • poliza_file - Insurance policy (PDF)
  • matricula_file - Vehicle registration (PDF)
  • rev_tec_file - Technical inspection (PDF)

Vehicle Certification

  • certification_file - Certification document (PDF)

Vehicle Pass

  • pass_file - Access pass document (PDF)

Custody Chain

  • custody_chain_file - Custody chain document (PDF)

Sheet Project (Work Order)

  • sheet_project_file - Work sheet document (PDF)
  • certificate_final_disposition_file - Final disposition certificate (PDF)
  • invoice_file - Invoice document (PDF)

Shipping Guide

  • shipping_guide_file - Shipping guide document (PDF)

Resource Item (Equipment)

  • resource_image - Equipment photo (image)
  • resource_image_2 - Additional equipment photo (image)

Protected Operations

Certain operations are restricted based on document status:

Closed Work Sheets

  • Cannot modify existing files on closed sheets
  • Can add files to empty fields on closed sheets
  • Cannot delete any files from closed sheets

Custody Chains with Closed Sheets

  • Same restrictions as closed work sheets apply to associated custody chains

Invoice Upload

When uploading an invoice file to a sheet project:
  • Sheet status is automatically set to INVOICED
  • Invoice reference can be set via invoice_reference parameter

Build docs developers (and LLMs) love