Skip to main content
Custody chains (CustodyChain) are critical documents for tracking waste disposal operations, equipment movement, and responsibility transfers. They ensure environmental compliance and accountability.

Endpoints

Create custody chain

POST /api/workorders/custody_chain/create/
Creates a new custody chain document for tracking waste disposal or equipment transfers.
sheet_project_id
integer
required
Associated work sheet ID
date
string
required
Date of custody transfer (YYYY-MM-DD format)
type_waste
string
required
Type of waste being transferred. Options:
  • AGUAS NEGRAS - Black water
  • AGUAS GRISES - Grey water
  • AGUA LIMPIA - Clean water
  • LODOS - Sludge
  • RIPIOS - Drilling cuttings
  • OTROS - Other
volume_gallons
decimal
Volume in gallons
volume_barrels
decimal
Volume in barrels (1 barrel = 42 gallons)
volume_cubic_meters
decimal
Volume in cubic meters
contact_name
string
required
Name of responsible contact at destination
contact_phone
string
Contact phone number
driver_name
string
Driver name
driver_license
string
Driver’s license number
technical_name
string
Technical staff name
observations
string
Additional notes or observations
{
  "success": true,
  "message": "Custody chain created successfully",
  "data": {
    "id": 42,
    "sheet_project_id": 1,
    "date": "2025-03-01",
    "type_waste": "AGUAS NEGRAS",
    "volume_gallons": "500.00",
    "contact_name": "John Doe"
  }
}

Get custody chain detail

GET /api/workorders/custody_chain/detail/{id}/
Retrieves complete details of a custody chain including all equipment items.
id
integer
required
Custody chain ID
{
  "success": true,
  "data": {
    "id": 42,
    "sheet_project": {
      "id": 1,
      "series_code": "PSL-PS-2025-0001",
      "project": {
        "id": 5,
        "partner_name": "PETROECUADOR"
      }
    },
    "date": "2025-03-01",
    "type_waste": "AGUAS NEGRAS",
    "volume_gallons": "500.00",
    "volume_barrels": "11.90",
    "volume_cubic_meters": "1.89",
    "contact_name": "John Doe",
    "contact_phone": "+593987654321",
    "driver_name": "Jane Smith",
    "driver_license": "DL-123456",
    "technical_name": "Tech-001",
    "observations": "Normal disposal operation",
    "equipment_items": [
      {
        "id": 1,
        "resource_code": "BS-001",
        "resource_name": "BATERIA SANITARIA HOMBRE",
        "physical_equipment_code": 1
      }
    ]
  }
}

Edit custody chain

PUT /api/workorders/custody_chain/{id}/edit/
Updates an existing custody chain.
id
integer
required
Custody chain ID to update
date
string
Updated date
type_waste
string
Updated waste type
volume_gallons
decimal
Updated volume in gallons
contact_name
string
Updated contact name
observations
string
Updated observations
Only provide fields that need to be updated. Other fields will remain unchanged.

Regenerate equipment codes

POST /api/workorders/custody_chain/regenerate-codes/
Regenerates physical equipment codes for all equipment in a custody chain. Useful when equipment assignments change.
custody_chain_id
integer
required
ID of the custody chain
{
  "success": true,
  "message": "Equipment codes regenerated successfully",
  "data": {
    "custody_chain_id": 42,
    "updated_items": 3
  }
}
This action reassigns sequential codes to all equipment. Use carefully as it may affect printed documents.

Custody chain model

id
integer
Unique identifier
sheet_project
object
Associated work sheet
date
string
Date of custody transfer
type_waste
string
Type of waste: AGUAS NEGRAS, AGUAS GRISES, AGUA LIMPIA, LODOS, RIPIOS, OTROS
volume_gallons
decimal
Volume in gallons
volume_barrels
decimal
Volume in barrels (auto-calculated: gallons ÷ 42)
volume_cubic_meters
decimal
Volume in cubic meters (auto-calculated: gallons × 0.00378541)
contact_name
string
Responsible contact at destination
contact_phone
string
Contact phone number
driver_name
string
Driver performing the transfer
driver_license
string
Driver’s license number
technical_name
string
Technical staff responsible
observations
text
Additional notes
is_deleted
boolean
Soft delete flag

Chain custody detail model

Equipment items tracked in the custody chain:
id
integer
Unique identifier
custody_chain
object
Parent custody chain
resource_item
object
The equipment/resource being tracked
physical_equipment_code
integer
Sequential code for this custody chain (e.g., 1, 2, 3)

Waste type reference

Aguas negras

Black water from sanitary facilities

Aguas grises

Grey water from washing stations

Agua limpia

Clean water storage and transfer

Lodos

Sludge from treatment processes

Ripios

Drilling cuttings and waste

Otros

Other waste types

Workflow example

1

Create custody chain

Create a new custody chain for waste disposal:
curl -X POST https://mantis.peisol.com.ec/api/workorders/custody_chain/create/ \
  -H "Content-Type: application/json" \
  -d '{
    "sheet_project_id": 1,
    "date": "2025-03-01",
    "type_waste": "AGUAS NEGRAS",
    "volume_gallons": 500,
    "contact_name": "John Doe",
    "contact_phone": "+593987654321",
    "driver_name": "Jane Smith",
    "driver_license": "DL-123456"
  }'
2

Equipment assignment

Equipment items are automatically associated based on the project resources at the time of creation. Each item receives a sequential physical_equipment_code.
3

Volume calculations

When you specify volume_gallons, the system automatically calculates:
  • volume_barrels = volume_gallons ÷ 42
  • volume_cubic_meters = volume_gallons × 0.00378541
4

Update if needed

Edit the custody chain if information changes:
curl -X PUT https://mantis.peisol.com.ec/api/workorders/custody_chain/42/edit/ \
  -H "Content-Type: application/json" \
  -d '{
    "volume_gallons": 600,
    "observations": "Additional waste collected"
  }'

Best practices

The system uses the following conversion factors:
  • 1 barrel = 42 gallons
  • 1 gallon = 0.00378541 cubic meters
  • 1 cubic meter = 264.172 gallons
Enter volume in the most convenient unit; other units are calculated automatically.
Custody chains are legal documents for environmental compliance. Ensure:
  • Accurate waste type classification
  • Precise volume measurements
  • Complete contact and driver information
  • Proper equipment tracking
Physical equipment codes are sequential numbers (1, 2, 3…) used to identify equipment in printed custody chain documents. Use the regenerate-codes endpoint if equipment assignments change after creation.
Once a custody chain is created and signed, avoid editing unless absolutely necessary. Changes should be tracked in the observations field or by creating a new custody chain.

Work sheets

Manage work sheets and billing

Project resources

View equipment assigned to projects

Documents

Generate and merge custody chain PDFs