Manage SMS Costs
This API manages SMS costs at multiple levels: TukuPay (default system-wide), App Owner, Specific Customer, and Direct Customers. If a customer-specific cost is not defined, the system falls back to t
Overview
This API manages SMS costs at multiple levels: TukuPay (default system-wide), App Owner, Specific Customer, and Direct Customers. If a customer-specific cost is not defined, the system falls back to the default customer cost.
1. Add or Update SMS Costs
Method:
POST
URL:
/api/sms-costs
Request Body:
Request Body Fields:
Field
Type
Required
Description
level
string
Yes
The level of cost: TukuPay
, AppOwner
, SpecificCustomer
, or DirectCustomer
.
pricePerSms
number
Yes
The cost per SMS in KES. For TukuPay
, this is the default system-wide cost.
customerId
string
Conditional
Required for SpecificCustomer
.
appId
string
Conditional
Required for AppOwner
level.
reason
string
Conditional
Optional for all but required for internal or customer-specific costs.
effectiveFrom
datetime
Yes
When this cost becomes effective.
createdBy
string
Yes
The user who set the cost.
Key Points:
If
level
isSpecificCustomer
, thecustomerId
field must be provided.If no cost exists for a specific customer, the system will use the default customer cost set under the
DirectCustomer
level.
Example for Default Customer Cost:
Example for Specific Customer Cost:
2. Retrieve Current SMS Costs
Method:
GET
URL:
/api/sms-costs/current
Query Parameters:
Field
Type
Required
Description
level
string
Yes
The level of cost: TukuPay
, AppOwner
, SpecificCustomer
, or DirectCustomer
.
appId
string
Conditional
Required for AppOwner
.
customerId
string
Conditional
Required for SpecificCustomer
.
Response Example (Specific Customer Cost):
Response Example (Default Customer Cost):
3. List Historical SMS Costs
Method:
GET
URL:
/api/sms-costs/history
Query Parameters:
Field
Type
Required
Description
level
string
Yes
The level of cost: TukuPay
, AppOwner
, SpecificCustomer
, or DirectCustomer
.
appId
string
Conditional
Required for AppOwner
.
customerId
string
Conditional
Required for SpecificCustomer
.
Response Example:
Implementation Notes
Default Costs: The system always uses
DirectCustomer
costs as the fallback when noSpecificCustomer
cost is found.Cost Hierarchy:
SpecificCustomer
overridesDirectCustomer
for a particular customer.AppOwner
costs apply for app-based reselling.TukuPay
costs define the default for the entire system.
Validation: Ensure costs are correctly associated with the appropriate level and entity (e.g.,
customerId
orappId
).