Purchase Orders API
Create and manage purchase orders to vendors programmatically.
The Purchase Orders API lets you issue POs to vendors and track their fulfilment status. Purchase orders record what you intend to buy, at what price, and from which vendor — forming a clear paper trail before any bill is raised.
Use Cases
- Procurement Systems: Issue POs from your ERP and track them in Cashfin
- Approval Workflows: Create POs in
draftstatus pending internal sign-off - Vendor Management: Send structured order requests to suppliers
Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /business/purchase-order/create | Create a new purchase order |
GET | /business/purchase-order/list | List all purchase orders |
GET | /business/purchase-order/details/:id | Get purchase order details |
Create Purchase Order
Issue a new purchase order.
http
POST /business/purchase-order/createRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Purchase order title or description |
orderdate | string | Yes | Date of the order (ISO 8601) |
deliverydate | string | Yes | Expected delivery date (ISO 8601) |
vendorid | string | No | Vendor ID to associate this order with |
description | string | No | Additional notes |
status | string | No | Initial status (default: draft) |
items | array | No | Line items (see Item Object below) |
Item Object
| Field | Type | Description |
|---|---|---|
itemid | string | Product ID |
name | string | Item name |
quantity | integer | Quantity |
rate | number | Price per unit |
Example Request
bash
curl -X POST "https://api.cashfin.africa/business/purchase-order/create" \
-H "Authorization: cs_your_client_secret" \
-H "Content-Type: application/json" \
-d '{
"title": "Q1 Office Equipment",
"orderdate": "2024-01-10",
"deliverydate": "2024-01-25",
"vendorid": "507f1f77bcf86cd799439060",
"description": "Monitors and keyboards for new hires",
"items": [
{
"itemid": "507f1f77bcf86cd799439011",
"name": "27-inch Monitor",
"quantity": 5,
"rate": 32000.00
},
{
"itemid": "507f1f77bcf86cd799439012",
"name": "Mechanical Keyboard",
"quantity": 5,
"rate": 8500.00
}
]
}'javascript
const response = await fetch(
"https://api.cashfin.africa/business/purchase-order/create",
{
method: "POST",
headers: {
Authorization: "cs_your_client_secret",
"Content-Type": "application/json",
},
body: JSON.stringify({
title: "Q1 Office Equipment",
orderdate: "2024-01-10",
deliverydate: "2024-01-25",
vendorid: "507f1f77bcf86cd799439060",
description: "Monitors and keyboards for new hires",
items: [
{
itemid: "507f1f77bcf86cd799439011",
name: "27-inch Monitor",
quantity: 5,
rate: 32000.0,
},
{
itemid: "507f1f77bcf86cd799439012",
name: "Mechanical Keyboard",
quantity: 5,
rate: 8500.0,
},
],
}),
}
);
const data = await response.json();php
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cashfin.africa/business/purchase-order/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'title' => 'Q1 Office Equipment',
'orderdate' => '2024-01-10',
'deliverydate' => '2024-01-25',
'vendorid' => '507f1f77bcf86cd799439060',
'description' => 'Monitors and keyboards for new hires',
'items' => [
[
'itemid' => '507f1f77bcf86cd799439011',
'name' => '27-inch Monitor',
'quantity' => 5,
'rate' => 32000.00,
],
[
'itemid' => '507f1f77bcf86cd799439012',
'name' => 'Mechanical Keyboard',
'quantity' => 5,
'rate' => 8500.00,
],
],
]),
CURLOPT_HTTPHEADER => [
"Authorization: cs_your_client_secret",
"Content-Type: application/json"
],
]);
$result = json_decode(curl_exec($curl), true);python
import requests
response = requests.post(
'https://api.cashfin.africa/business/purchase-order/create',
headers={
'Authorization': 'cs_your_client_secret',
'Content-Type': 'application/json'
},
json={
'title': 'Q1 Office Equipment',
'orderdate': '2024-01-10',
'deliverydate': '2024-01-25',
'vendorid': '507f1f77bcf86cd799439060',
'description': 'Monitors and keyboards for new hires',
'items': [
{
'itemid': '507f1f77bcf86cd799439011',
'name': '27-inch Monitor',
'quantity': 5,
'rate': 32000.00,
},
{
'itemid': '507f1f77bcf86cd799439012',
'name': 'Mechanical Keyboard',
'quantity': 5,
'rate': 8500.00,
},
],
}
)Success Response
json
{
"success": true,
"message": "Purchase order created successfully",
"data": {
"_id": "507f1f77bcf86cd799439090",
"pono": "PO-2024-001",
"title": "Q1 Office Equipment",
"amount": 202500.0,
"status": "draft",
"orderdate": "2024-01-10T00:00:00.000Z",
"deliverydate": "2024-01-25T00:00:00.000Z",
"sourceorigin": "api",
"active": true,
"createdat": "2024-01-10T09:00:00.000Z"
}
}List Purchase Orders
Retrieve a paginated list of purchase orders.
http
GET /business/purchase-order/listQuery Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
limit | integer | 10 | Results per page (max: 100) |
search | string | - | Search by title, PO number, or description |
status | string | - | Filter by status: draft, sent, received, cancelled |
Example Request
bash
curl -X GET "https://api.cashfin.africa/business/purchase-order/list?page=1&limit=10&status=sent" \
-H "Authorization: cs_your_client_secret"javascript
const response = await fetch(
"https://api.cashfin.africa/business/purchase-order/list?page=1&limit=10",
{
headers: { Authorization: "cs_your_client_secret" },
}
);
const data = await response.json();python
import requests
response = requests.get(
'https://api.cashfin.africa/business/purchase-order/list',
headers={'Authorization': 'cs_your_client_secret'},
params={'page': 1, 'limit': 10, 'status': 'sent'}
)Success Response
json
{
"success": true,
"data": [
{
"_id": "507f1f77bcf86cd799439090",
"pono": "PO-2024-001",
"title": "Q1 Office Equipment",
"amount": 202500.0,
"status": "sent",
"orderdate": "2024-01-10T00:00:00.000Z",
"deliverydate": "2024-01-25T00:00:00.000Z",
"vendor_name": "Acme Supplies Ltd",
"createdat": "2024-01-10T09:00:00.000Z"
}
],
"pagination": {
"total": 12,
"page": 1,
"limit": 10,
"pages": 2
}
}Get Purchase Order Details
Retrieve full details of a specific purchase order, including vendor and line items.
http
GET /business/purchase-order/details/:idPath Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Purchase Order ID (MongoDB ObjectID) |
Example Request
bash
curl -X GET "https://api.cashfin.africa/business/purchase-order/details/507f1f77bcf86cd799439090" \
-H "Authorization: cs_your_client_secret"javascript
const poId = "507f1f77bcf86cd799439090";
const response = await fetch(
`https://api.cashfin.africa/business/purchase-order/details/${poId}`,
{
headers: { Authorization: "cs_your_client_secret" },
}
);
const data = await response.json();python
import requests
po_id = '507f1f77bcf86cd799439090'
response = requests.get(
f'https://api.cashfin.africa/business/purchase-order/details/{po_id}',
headers={'Authorization': 'cs_your_client_secret'}
)Success Response
json
{
"success": true,
"data": {
"_id": "507f1f77bcf86cd799439090",
"pono": "PO-2024-001",
"title": "Q1 Office Equipment",
"amount": 202500.0,
"tax": 0,
"taxamount": 0,
"discount": 0,
"status": "sent",
"description": "Monitors and keyboards for new hires",
"orderdate": "2024-01-10T00:00:00.000Z",
"deliverydate": "2024-01-25T00:00:00.000Z",
"items": [
{
"itemid": "507f1f77bcf86cd799439011",
"name": "27-inch Monitor",
"quantity": 5,
"rate": 32000.0
},
{
"itemid": "507f1f77bcf86cd799439012",
"name": "Mechanical Keyboard",
"quantity": 5,
"rate": 8500.0
}
],
"vendor": {
"_id": "507f1f77bcf86cd799439060",
"name": "Acme Supplies Ltd",
"email": "[email protected]",
"phone": "+254700000001"
},
"createdat": "2024-01-10T09:00:00.000Z",
"updatedat": "2024-01-10T09:00:00.000Z"
}
}Purchase Order Statuses
| Status | Description |
|---|---|
draft | Created, awaiting approval |
sent | Sent to vendor |
received | Goods or services received |
cancelled | Order cancelled |
Error Responses
Purchase Order Not Found
json
{
"success": false,
"error": "Purchase order not found"
}Invalid Date Format
json
{
"success": false,
"error": "Invalid orderdate format. Use ISO 8601 (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ)"
}