Developer API & eTIMS Integration Guide
Seamlessly connect Point of Sale (POS) terminals, e-commerce stores (WooCommerce, Shopify), or ERP platforms (Odoo, SAP) to issue KRA eTIMS fiscal invoices and process M-Pesa payments with zero custody.
Authentication
All requests to the CiftPay API must include your organization's secret key in the Authorization HTTP header as a Bearer token.
Authorization: Bearer cp_live_2b8d4fd7b6b4e3fdb21507ce5ea72f...cp_live_ and possess full administrator privileges scoped to your organization under PostgreSQL Row Level Security (RLS). Never expose this key in public client-side browser JavaScript or mobile source code.Interactive Code Snippets
curl -X POST https://api-ciftpay-071e66a802ff.herokuapp.com/sales \
-H "Authorization: Bearer cp_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"kind": "cash",
"buyer_name": "Acme Holdings Ltd",
"buyer_pin": "P051234567Z",
"buyer_msisdn": "254712345678",
"lines": [
{
"description": "Enterprise Software License",
"qty": "1",
"unit_price_cents": 5000000,
"tax_category": "B",
"etims_class_code": "50101501"
}
]
}'eTIMS Fiscal Lifecycle & Architecture
When your system calls POST /sales with kind: "cash" or settles an open order, CiftPay manages the complete KRA fiscal validation pipeline asynchronously:
Sale Created
Database commits transaction, generates internal invoice & customer receipt code.
eTIMS Worker Job
Invoice is enqueued for signing with exponential retry protection against network latency.
KRA Acknowledgment
KRA fiscal unit signs invoice, emits official Control Number & cryptographic QR payload.
Webhook & Polling
Invoice transitions to ACKED. Receipt modal & your webhook receive verified status.
Live In-Browser API Tester
Test real HTTP requests against the live production server directly in your browser.
https://api-ciftpay-071e66a802ff.herokuapp.com/itemsKRA eTIMS Tax Categories & Codes
When passing items in lines[].tax_category, you must provide one of the standard Kenya Revenue Authority tax categories:
| Category | VAT Rate | Description & Eligible Goods |
|---|---|---|
| A | 16.0% | Standard VAT Rate on general taxable goods & services |
| B | 16.0% | General merchandise and retail goods (Default for POS) |
| C | 0.0% | Zero-rated items (Exports, unpasteurized milk, pharmaceuticals) |
| D | Exempt | Exempt goods & services (Financial services, basic education) |
| E | Non-VAT | Out of scope / non-taxable transactions |
Error Codes & Troubleshooting
| HTTP Code | Error Code | Cause & Remediation |
|---|---|---|
| 401 | unauthenticated | API key is missing, revoked, or prefixed incorrectly. Ensure Authorization: Bearer cp_live_... |
| 403 | forbidden | Accountant role restricted or accessing an unauthorized organization tenant. |
| 422 | validation | Invalid KRA PIN structure (must be A or P followed by 9 digits and 1 letter), or invalid tax category. |
| 503 | service_unavailable | KRA OSCU/VSCU hardware or upstream gateway is unreachable. Invoice will automatically queue in River for retry. |