Idempotency Mechanism
- New
meteringId: The request is processed and stored. A success response is returned. - Duplicate
meteringId: The system returns the cached response without reprocessing. - This ensures safe retries without double billing.
Additional Billing & Session Rules
1. Timestamp Ordering
- All metering reports must have monotonically increasing
timestampvalues. - Out-of-order reports may be rejected or handled with warnings during auditing.
2. Final State Idempotency
- Once a report with
"isFinal": trueis accepted for asessionId, the session is marked as completed. - Any further reports for the same
sessionIdwill be ignored (cached response returned).
3. Session Termination Handling
- No Reports Received: If no metering reports are sent, MuleRun will charge based on internal resource tracking.
- Grace Period: If no final report is received before session end, late reports are accepted within 1 minute after termination.
- Abnormal Termination: In cases of crash or forced termination, the grace period does not apply — charges are settled immediately.
4. Negative Credit Balance
- If a user’s credit balance becomes negative, the session is immediately terminated.
- All subsequent metering reports for that session will be ignored.
Authentication
Authentication is done using your Agent Key as a Bearer token in the Authorization header.Best Practices
- Generate a new UUIDv4 for each
meteringIdto ensure idempotency. - Always send a final report with
"isFinal": truewhen the session completes normally. - Ensure timestamps are monotonically increasing for sequential reports.
Authorizations
Use your Agent Key as the Bearer token
Body
Unique ID assigned by MuleRun to identify the agent.
"123e4567-e89b-12d3-a456-426614174000"
Identifier for the current user session. Multiple reports with the same sessionId belong to the same session.
"987e6543-e21b-45cd-b678-123456789abc"
Usage cost in units of 0.0001 credits. For example, 1050 = 0.105 credits. Must be positive.
x >= 11050
UTC timestamp indicating when this usage was recorded.
"2023-10-27T10:00:00Z"
A globally unique idempotency key. Prevents duplicate processing of the same report. UUID v4 recommended.
"abc123efg-456h-789i-jklm-123nop456qr"
If true, marks this as the final report for the session (AND session will be terminated). Defaults to false.
false