---
title: "Meter on the server after the work · Agent Wranglers"
url: https://agentwranglers.se/playbook/usage-billing/metering/server-side-metering
id: USG-2
level: Recommended
applies: payments
updated: 2026-10-22
tokens: 607
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Meter on the server after the work succeeds

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Metering](https://agentwranglers.se/playbook/usage-billing/metering.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: USG-2
- Level: Recommended
- Chapter: [Metering](https://agentwranglers.se/playbook/usage-billing/metering.md)
- Rule: Record usage only on the server that did the work, after it succeeded, with the quantity it measured. Never take a quantity from the browser or the app.
- Check: Search the API for request fields named quantity, tokens or units that reach the usage table. None do. A test makes a model call fail after the provider answers, and the result and the usage event are both saved or both missing.
- Applies when: The project takes payments.
- How: A count sent by the client can be changed, so a customer could bill themselves zero. Measure the quantity where the work happens, such as the token counts the model provider returns. Write the usage event in the same transaction as the result, or through an [outbox](https://agentwranglers.se/playbook/data/transactions-and-concurrency/outbox.md), so a saved result always has its event. Decide in writing whether a failed or cancelled request is billed, and test that choice.

## Sources

- [CWE-602 Client-Side Enforcement of Server-Side Security](https://cwe.mitre.org/data/definitions/602.html)

## Related rules

- DAT-18 [Send side effects through an outbox](https://agentwranglers.se/playbook/data/transactions-and-concurrency/outbox.md) in Data and databases

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/usage-billing/metering/server-side-metering">Agent Wranglers usage-based billing playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Give every usage event a key and count it once](https://agentwranglers.se/playbook/usage-billing/metering/idempotent-usage-events.md)
- Next: [Keep raw events and derive every total from them](https://agentwranglers.se/playbook/usage-billing/metering/raw-usage-events.md)
- [Metering](https://agentwranglers.se/playbook/usage-billing/metering.md)
