Purchases API
Create and manage purchase transactions with automatic VSCU submission.
Overview
The Purchases API allows you to record supplier purchases and sync them with KRA eTIMS. All purchases are validated and submitted to VSCU for compliance.
Create Purchase
Submit a purchase transaction to the VSCU system.
POST
/api/v1/purchasesCreate Purchase
Submit a purchase transaction to the VSCU system. The purchase is validated, stored locally, and synced to KRA.
Authentication
Request BodyJSON
Field Descriptions
Main Fields
| Field | Type | Required | Description |
|---|---|---|---|
branch_id | string | Yes | Branch identifier (bhf_id) |
invoice_no | string | Yes | Your unique purchase invoice number |
purchase_date | string | Yes | Date in YYYYMMDD format |
purchase_time | string | Yes | Time in HHMMSS format |
supplier_tin | string | Yes | Supplier’s TIN number |
supplier_name | string | Yes | Supplier’s business name |
supplier_bhf_id | string | No | Supplier’s branch ID |
supplier_invoice_no | string | Yes | Supplier’s invoice number |
purchase_status | string | No | Purchase status code |
purchase_type | string | No | Purchase type (N=Normal, I=Import) |
payment_type | string | Yes | Payment type code (01=Cash, 02=Card, etc.) |
Item Fields
| Field | Type | Required | Description |
|---|---|---|---|
item_sequence | integer | Yes | Item sequence number (1, 2, 3…) |
item_code | string | Yes | Item code |
item_name | string | Yes | Item name |
bcd | string | No | Barcode |
package_unit | string | No | Package unit code |
quantity | number | Yes | Quantity purchased |
unit_price | number | Yes | Unit price |
supply_amount | number | Yes | Supply amount (qty × price) |
discount_rate | number | No | Discount rate (%) |
discount_amount | number | No | Discount amount |
tax_type | string | Yes | Tax type (A, B, C, etc.) |
tax_rate | number | Yes | Tax rate (%) |
tax_amount | number | Yes | Tax amount |
total_amount | number | Yes | Total including tax |
Response
Status: 200 OK
{
"status": "success",
"data": {
"transaction_id": "9d3f4b1a-7c8e-4d2f-b5a6-1e3c9f8d2b4a",
"invoice_no": "PINV-2024-001",
"receipt_no": "20240115-00-P-00001",
"receipt_date": "20240115143030",
"total_amount": 58000,
"tax_amount": 8000,
"vscu_receipt_code": "000",
"vscu_receipt_msg": "SUCCESS"
},
"meta": {
"timestamp": "2024-01-15T14:30:30Z",
"request_id": "req_123abc"
}
}Get Purchase Details
Retrieve details of a specific purchase transaction.
GET
/api/v1/purchases/{transaction_id}Get Purchase Details
Retrieve complete details of a specific purchase transaction.
Authentication
Parameters
transaction_id*string · path
Purchase transaction UUID
Response
Status: 200 OK
{
"status": "success",
"data": {
"transaction_id": "9d3f4b1a-7c8e-4d2f-b5a6-1e3c9f8d2b4a",
"branch_id": "00",
"invoice_no": "PINV-2024-001",
"receipt_no": "20240115-00-P-00001",
"purchase_date": "20240115",
"purchase_time": "143000",
"supplier_tin": "987654321",
"supplier_name": "ABC Suppliers Ltd",
"total_amount": 58000,
"tax_amount": 8000,
"status": "success",
"items": [...],
"response": {...},
"created_at": "2024-01-15T14:30:00Z",
"processed_at": "2024-01-15T14:30:30Z"
}
}Search Purchases
Search purchase transactions with filters.
POST
/api/v1/purchases/searchSearch Purchases
Search and filter purchase transactions by date, invoice number, supplier, or status.
Authentication
Request BodyJSON
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
branch_id | string | No | Filter by branch |
from_date | string | No | Start date (YYYY-MM-DD) |
to_date | string | No | End date (YYYY-MM-DD) |
invoice_no | string | No | Search by invoice number |
supplier_name | string | No | Search by supplier name |
status | string | No | Filter by status |
per_page | integer | No | Results per page (max 100) |
page | integer | No | Page number |
Response
Status: 200 OK
{
"data": [
{
"transaction_id": "...",
"branch_id": "00",
"invoice_no": "PINV-2024-001",
"receipt_no": "20240115-00-P-00001",
"purchase_date": "20240115",
"supplier_name": "ABC Suppliers Ltd",
"total_amount": 58000,
"status": "success",
"created_at": "2024-01-15T14:30:00Z"
}
],
"meta": {
"current_page": 1,
"per_page": 20,
"total": 87,
"total_pages": 5
}
}Error Responses
400 Bad Request
{
"status": "error",
"message": "Invalid request data",
"error": "The supplier_tin field is required."
}422 Unprocessable Entity
{
"status": "error",
"message": "Purchase transaction processing failed",
"error": "VSCU connection timeout",
"transaction_id": "..."
}404 Not Found
{
"status": "error",
"message": "Purchase transaction not found"
}Code Examples
JavaScript
const axios = require('axios');
const apiKey = process.env.CTAX_API_KEY;
const baseURL = 'https://c-tax.1809ltd.co.ke/api/v1';
const purchaseData = {
branch_id: '00',
invoice_no: `PINV-${Date.now()}`,
purchase_date: new Date().toISOString().slice(0,10).replace(/-/g, ''),
purchase_time: new Date().toTimeString().slice(0,8).replace(/:/g, ''),
supplier_tin: '987654321',
supplier_name: 'ABC Suppliers Ltd',
supplier_invoice_no: 'SUP-INV-2024-001',
payment_type: '01',
items: [
{
item_sequence: 1,
item_code: 'ITEM001',
item_name: 'Product A',
quantity: 10,
unit_price: 5000,
supply_amount: 50000,
tax_type: 'A',
tax_rate: 16,
tax_amount: 8000,
total_amount: 58000
}
]
};
const response = await axios.post(`${baseURL}/purchases`, purchaseData, {
headers: { Authorization: `Bearer ${apiKey}` }
});PHP
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://c-tax.1809ltd.co.ke/api/v1/',
'headers' => [
'Authorization' => 'Bearer ' . env('CTAX_API_KEY'),
'Content-Type' => 'application/json',
],
]);
$data = [
'branch_id' => '00',
'invoice_no' => 'PINV-' . time(),
'purchase_date' => date('Ymd'),
'purchase_time' => date('His'),
'supplier_tin' => '987654321',
'supplier_name' => 'ABC Suppliers Ltd',
'supplier_invoice_no' => 'SUP-INV-2024-001',
'payment_type' => '01',
'items' => [
[
'item_sequence' => 1,
'item_code' => 'ITEM001',
'item_name' => 'Product A',
'quantity' => 10,
'unit_price' => 5000,
'supply_amount' => 50000,
'tax_type' => 'A',
'tax_rate' => 16,
'tax_amount' => 8000,
'total_amount' => 58000,
],
],
];
$response = $client->post('purchases', ['json' => $data]);Python
import requests
from datetime import datetime
import os
api_key = os.environ['CTAX_API_KEY']
base_url = 'https://c-tax.1809ltd.co.ke/api/v1'
headers = {'Authorization': f'Bearer {api_key}'}
now = datetime.now()
purchase_data = {
'branch_id': '00',
'invoice_no': f'PINV-{int(datetime.timestamp(now))}',
'purchase_date': now.strftime('%Y%m%d'),
'purchase_time': now.strftime('%H%M%S'),
'supplier_tin': '987654321',
'supplier_name': 'ABC Suppliers Ltd',
'supplier_invoice_no': 'SUP-INV-2024-001',
'payment_type': '01',
'items': [
{
'item_sequence': 1,
'item_code': 'ITEM001',
'item_name': 'Product A',
'quantity': 10,
'unit_price': 5000,
'supply_amount': 50000,
'tax_type': 'A',
'tax_rate': 16,
'tax_amount': 8000,
'total_amount': 58000
}
]
}
response = requests.post(f'{base_url}/purchases', json=purchase_data, headers=headers)Best Practices
- Validate Supplier Information - Ensure supplier TIN and name are correct
- Match Supplier Invoice - Record the exact supplier invoice number
- Verify Calculations - Double-check all amounts match supplier invoice
- Store Receipts - Keep VSCU receipt numbers for audit trails
- Regular Reconciliation - Reconcile purchase records with suppliers regularly
Related Endpoints
- Transactions API - View and manage transactions
- Stock Management - Update stock after purchases
- Codes API - Get tax types and payment types
Last updated on