Items API
Manage inventory items and register them with KRA. Items are the products and services you sell, purchase, or stock.
Overview
The Items API allows you to:
- List items from your local database
- Search KRA-registered items
- Register new items with KRA
- Manage item details and pricing
Item Structure
Key Fields
| Field | Description |
|---|---|
item_code | Unique item identifier |
item_name | Item name/description |
item_class_code | KRA classification code |
item_type_code | Item type (1=Raw Material, 2=Finished, 3=Service) |
tax_type_code | Tax type (A, B, C, D, E) |
tax_rate | Tax rate percentage |
default_price | Default selling price |
pkg_unit_code | Packaging unit code |
qty_unit_code | Quantity unit code |
Tax Types
| Code | Name | Rate |
|---|---|---|
| A | Standard Rate | 16% |
| B | Exempt | 0% |
| C | Special | 0% |
| D | Zero-rated | 0% |
| E | Special Exemption | 0% |
Search Items
Search for items in your local database or KRA registry.
/api/v1/items/searchSearch Items
Search for items by code, name, or barcode. Searches both local database and KRA registry.
Query/Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
branch_id | string | No | Branch ID (default: “00”) |
search | string | No | Search term |
limit | integer | No | Max results (default: 20, max: 100) |
Response
Status: 200 OK
{
"status": "success",
"data": [
{
"item_code": "ITEM001",
"item_name": "Product A",
"item_class_code": "5101",
"item_type": "2",
"tax_type": "A",
"tax_rate": 16,
"default_price": 1000.00,
"is_active": true,
"source": "kra_registry"
}
],
"meta": {
"total": 5,
"search": "laptop",
"limit": 20,
"source": "kra_registry",
"timestamp": "2025-01-15T14:30:00Z"
}
}Get Item Details
Retrieve details of a specific item.
/api/v1/items/{itemCode}Get Item Details
Retrieve detailed information about a specific item from local database or KRA registry.
itemCode*Item code
branch_idBranch ID (default: '00')
Response
Status: 200 OK
{
"status": "success",
"data": {
"item_code": "ITEM001",
"item_name": "Product A",
"item_class_code": "5101",
"item_type": "2",
"tax_type": "A",
"tax_rate": 16,
"default_price": 1000.00,
"barcode": "1234567890123",
"pkg_unit_code": "NT",
"qty_unit_code": "U",
"origin_country": "KE",
"safety_qty": 10,
"is_active": true,
"is_insurance_applicable": false
},
"meta": {
"source": "kra_registry",
"timestamp": "2025-01-15T14:30:00Z"
}
}Status: 404 Not Found
{
"status": "error",
"message": "Item not found in KRA registry"
}Create Item
Register a new item with KRA and save to local database.
/api/v1/itemsCreate Item
Register a new item with KRA. The item is saved locally and synced to KRA.
Field Descriptions
| Field | Type | Required | Description |
|---|---|---|---|
branch_id | string | No | Branch ID (default: “00”) |
item_name | string | Yes | Item name (max 200 chars) |
item_class_code | string | Yes | KRA classification code (max 20 chars) |
item_code | string | No | Item code (auto-generated if not provided) |
item_type_code | string | No | Item type: 1=Raw, 2=Finished, 3=Service (default: “2”) |
unit_price | number | No | Default price (min 0) |
tax_type | string | Yes | Tax type: A, B, C, D, or E |
pkg_unit_code | string | No | Packaging unit code (default: “NT”) |
qty_unit_code | string | No | Quantity unit code (default: “U”) |
barcode | string | No | Barcode (max 100 chars) |
origin_nation_code | string | No | Origin country code (default: “KE”) |
safety_qty | number | No | Safety stock quantity (min 0) |
additional_info | string | No | Additional information |
is_insurance_applicable | boolean | No | Insurance applicable flag |
Response
Status: 201 Created
{
"status": "success",
"message": "Item registered successfully with KRA",
"data": {
"id": 123,
"item_code": "NEWITEM001",
"item_name": "New Product",
"item_class_code": "5101",
"default_price": 1500.00,
"synced_to_kra": true
},
"meta": {
"source": "local_database",
"timestamp": "2025-01-15T14:30:00Z"
}
}Note: If KRA sync fails, the item is still saved locally with
synced_to_kra: false.
Validation Errors
Status: 422 Unprocessable Entity
{
"status": "error",
"message": "Validation failed",
"errors": {
"item_name": ["The item name field is required."],
"tax_type": ["The selected tax type is invalid."]
}
}Item Code Generation
If item_code is not provided, it’s auto-generated using the format:
KE + [First 3 digits of TIN] + [8-digit sequence]Example: KE12300000001
Code Examples
JavaScript
const axios = require('axios');
const apiKey = process.env.CTAX_API_KEY;
const baseURL = 'https://c-tax.1809ltd.co.ke/api/v1';
// Search items
const searchResults = await axios.post(`${baseURL}/items/search`, {
branch_id: '00',
search: 'laptop',
limit: 20
}, {
headers: { Authorization: `Bearer ${apiKey}` }
});
// Create item
const newItem = await axios.post(`${baseURL}/items`, {
branch_id: '00',
item_name: 'Premium Laptop',
item_class_code: '8471',
unit_price: 85000.00,
tax_type: 'A',
barcode: '1234567890123'
}, {
headers: { Authorization: `Bearer ${apiKey}` }
});
console.log(`Item created: ${newItem.data.data.item_code}`);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',
],
]);
// Search items
$response = $client->post('items/search', [
'json' => [
'branch_id' => '00',
'search' => 'laptop'
],
]);
$items = json_decode($response->getBody(), true)['data'];
// Create item
$response = $client->post('items', [
'json' => [
'branch_id' => '00',
'item_name' => 'Premium Laptop',
'item_class_code' => '8471',
'unit_price' => 85000.00,
'tax_type' => 'A',
],
]);Python
import requests
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}'}
# Search for item
response = requests.post(
f'{base_url}/items/search',
json={'branch_id': '00', 'search': 'laptop'},
headers=headers
)
items = response.json()['data']
# Create item
response = requests.post(
f'{base_url}/items',
json={
'branch_id': '00',
'item_name': 'Premium Laptop',
'item_class_code': '8471',
'unit_price': 85000.00,
'tax_type': 'A',
},
headers=headers
)Item Classification Codes
Use the Codes API to get valid classification codes:
const response = await axios.get('/api/v1/codes/item-classes/select', {
params: { search: 'laptop' },
headers: { Authorization: `Bearer ${apiKey}` }
});
const itemClasses = response.data.data;
// [{ value: '8471', label: '8471 - Computers', code: '8471', name: 'Computers' }]Packaging and Quantity Units
Common Packaging Units
| Code | Description |
|---|---|
NT | No Package |
BX | Box |
CT | Carton |
PK | Pack |
BG | Bag |
BT | Bottle |
Common Quantity Units
| Code | Description |
|---|---|
U | Unit/Piece |
KG | Kilogram |
LT | Liter |
M | Meter |
M2 | Square Meter |
M3 | Cubic Meter |
Get full list from Codes API:
// Get packaging units
const pkgUnits = await axios.get('/api/v1/codes/packaging-units', {
headers: { Authorization: `Bearer ${apiKey}` }
});
// Get quantity units
const qtyUnits = await axios.get('/api/v1/codes/quantity-units', {
headers: { Authorization: `Bearer ${apiKey}` }
});Best Practices
- Use Local Database - Prefer
/items/searchwith cached results for better performance - Sync Regularly - Keep local items synced with KRA
- Unique Codes - Use meaningful, unique item codes
- Correct Tax Types - Verify tax classification for each item
- Valid Classifications - Use valid KRA item class codes
- Handle Sync Failures - Items saved locally can be synced later
Related Endpoints
- Sales API - Use items in sales
- Purchases API - Use items in purchases
- Stock API - Stock movements for items
- Codes API - Item classifications and units