Project Ploughshares API Documentation
Endpoints
1. List All Transactions
GET /api/transactions
Complete Example:
curl -X GET "http://ploughshares.nixc.us/api/transactions"
Response:
[
{
"transaction_id": 1,
"transaction_no": "78708",
"transaction_type": "Subcontract",
"company_division": "C A E Inc",
"amount": 0.00,
"recipient": "US Army",
"created_at": "2023-07-02T12:34:56.789012"
},
{
"transaction_id": 2,
"transaction_no": "78709",
"transaction_type": "Purchase Order",
"company_division": "Example Corp",
"amount": 1000.00,
"recipient": "Test Recipient",
"created_at": "2023-07-03T10:11:12.131415"
}
]
2. Get Transaction Details
GET /api/transaction/{id}
Complete Example:
curl -X GET "http://ploughshares.nixc.us/api/transaction/1"
Response:
{
"transaction": {
"transaction_id": 1,
"transaction_no": "78708",
"transaction_type": "Subcontract",
"company_division": "C A E Inc",
"address_1": "5585 Cote de Liesse",
"address_2": "P O Box 1800",
"city": "ST LAURENT",
"province": "QC",
"region": "Quebec",
"postal_code": "H4T 1G6",
"is_primary": true,
"source_date": "2023-08-23",
"source_description": "Source Description",
"description": "7000XR Full Flight Simulator (FFS) in Global 6000/6500 configuration (subc)",
"amount": 0.00,
"recipient": "US Army",
"commodity_class": "Aerospace",
"contract_number": "SUMMARY",
"comments": "Subcontract with Leidos, US, through CAE Defense & Security...",
"created_at": "2023-07-02T12:34:56.789012"
},
"documents": [
{
"document_id": 1,
"transaction_id": 1,
"filename": "78708_20240501.pdf",
"file_path": "1/78708_20240501.pdf",
"document_type": "Contract",
"description": "Contract document",
"note": "Original contract",
"upload_date": "2023-07-02T12:34:56.789012"
}
]
}
3. Create New Transaction
POST /api/transaction
Note: All transactions created via API are set to "pending approval" status by default. They must be explicitly approved using the approval endpoint before being considered valid.
Complete Example:
curl -X POST "http://ploughshares.nixc.us/api/transaction" \
-H "Content-Type: application/json" \
-d '{
"transaction_no": "12345",
"transaction_type": "Purchase Order",
"company_division": "Example Corp",
"description": "Test transaction",
"amount": 1000.00,
"recipient": "Test Recipient"
}'
Response:
{
"message": "Transaction created successfully and is pending approval",
"transaction_id": 2
}
4. Update Transaction
PUT /api/transaction/{id}
Note: This endpoint only updates transaction details. It does not change the approval status of a transaction. To approve a transaction, use the dedicated approval endpoint.
Complete Example:
curl -X PUT "http://ploughshares.nixc.us/api/transaction/2" \
-H "Content-Type: application/json" \
-d '{
"transaction_type": "Purchase Order",
"company_division": "Updated Corp",
"description": "Updated transaction",
"amount": 1500.00,
"recipient": "Updated Recipient"
}'
Response:
{
"message": "Transaction updated successfully"
}
5. Delete Transaction
DELETE /api/transaction/{id}
Complete Example:
curl -X DELETE "http://ploughshares.nixc.us/api/transaction/3"
Response:
{
"message": "Transaction deleted successfully"
}
6. Get Pending Transactions
GET /api/transactions/pending
Complete Example:
curl -X GET "http://ploughshares.nixc.us/api/transactions/pending"
Response:
[
{
"transaction_id": 1,
"transaction_type": "Subcontract",
"company_division": "C A E Inc",
"amount": 0.00,
"recipient": "US Army",
"created_at": "2023-07-02T12:34:56.789012",
"approved": false
},
{
"transaction_id": 2,
"transaction_type": "Purchase Order",
"company_division": "Example Corp",
"amount": 1000.00,
"recipient": "Test Recipient",
"created_at": "2023-07-03T10:11:12.131415",
"approved": false
}
]
7. Approve Transaction
POST /api/transaction/{id}/approve
Important: This endpoint provides human-in-the-loop verification. All transactions (especially those created via API) require explicit approval before being considered valid. The system automatically records the approval with a standard identifier.
Complete Example:
curl -X POST "http://ploughshares.nixc.us/api/transaction/2/approve"
Response:
{
"message": "Transaction approved successfully"
}