External Costs
External costs bill third-party spend that Paygent doesn’t track automatically — telephony minutes, SMS, shipping, human review, proprietary APIs, or any pass-through expense. You define cost categories and pricing rules in the dashboard, then report usage from your application with send_external_cost.
How external billing works
Step 1 — Create an external cost category
Sidebar → External Cost → Add Cost
The externalCostId must match ExternalCostData.external_cost_id in your integration.
Step 2 — Add billing configurations
Expand a cost category → Add Config
FLAT example
- Config name:
inbound_call - Billing type: FLAT
- Price:
$0.05per call
Every matching event bills $0.05 regardless of properties.
PER_UNIT example
- Config name:
inbound_call - Billing type: PER_UNIT
- Price:
$0.02 - Unit field:
duration_minutes
Event with properties: {"duration_minutes": 2.5} → $0.02 × 2.5 = $0.05
Multiple property rates
Set property rates when each key has its own rate:
Step 3 — Send usage from your application
Python
Node.js
Required fields
Missing or unknown configs: the event is stored but may not generate revenue until a matching config exists.
Error handling
The SDK validates required fields synchronously and raises ValueError if agent_id, customer_id, name, or external_cost_id is blank.
Network and API errors are logged asynchronously — send_external_cost is fire-and-forget and does not block your application. Wrap init calls in your own retry/monitoring if external costs are business-critical.
Invalid meta_tags are omitted with a warning; the cost event is still sent.
External costs on invoices
When billing runs for an active order:
- External cost events in the period are aggregated per config
- Amounts appear as invoice line items alongside platform fees and usage
- Taxes apply to the subtotal if configured on the order
View usage summaries in the dashboard under External Cost (date range + optional customer filter).
Example: voice agent telephony pass-through
- External Cost → category
telephony/ IDtelephony - Config
inbound_call: PER_UNIT, $0.018/min, unit fieldduration_minutes - Config
outbound_call: PER_UNIT, $0.025/min, unit fieldduration_minutes - After each call, your telephony webhook calls
send_external_cost - Monthly invoice includes telephony line items + AI usage from the same agent
Checklist
- ✓ External cost category created with stable
externalCostId - ✓ Billing config(s) created with matching
nameand active status - ✓ PER_UNIT: property keys in SDK match unit fields / property rates
- ✓ Active order exists for the customer
- ✓ SDK sends events with correct agent and customer IDs
Related: Meta Tags · Orders & Invoicing · Error Handling
