01Run it
Straight from the command's own help.
p202 ltv revenue record --customer-ref CUST-77 --amount 49.00 --idempotency-key ORD-1001 --item '{"sku":"PRO-1","quantity":1,"unit_price":49}'02What you get
--json, --csv or --ndjson for scripts, or -q for ids only. An AI agent gets compact JSON without asking. All output formats03Build your command
Pick values and the command line writes itself, quoted and ready to paste.
p202 ltv revenue recordSet flags below; the command updates as you type.
04Flags
13 flags, plus the global flags every command takes.
| Flag | What it does |
|---|---|
| --amountstringrequired | The amount, in the account currency (required) |
| --currencystring | Currency code; must be the account currency (default it) |
| --customer-crmstring | CRM fields as a JSON object, applied only when this call creates the customer, e.g. '{"email":"[email protected]","first_name":"Ada"}' |
| --customer-idstringrequired, or --customer-ref | The customer's internal id (p202 ltv customers) |
| --customer-refstringrequired, or --customer-id | Your system's id for the customer; the server finds it, or creates a customer for it |
| --customer-ref-typestring | What kind of reference --customer-ref is (default custom): email_md5, email_sha256, esp_id, merchant_id, subid, customemail_md5email_sha256esp_idmerchant_idsubidcustom |
| --event-typestring | What it is (default purchase): purchase, one_time, refund, chargeback, adjustmentpurchaseone_timerefundchargebackadjustment |
| --external-refstring | Your reference for the event (an order number) |
| --idempotency-keystring | Your id for this event: the same request again records nothing and answers with the first event; a different one under it is refused |
| --itemstringArray | A line item as a JSON object (repeatable), e.g. '{"sku":"PRO-1","name":"Pro plan","quantity":1,"unit_price":49}' |
| --items-filestring | Line items as a JSON array in a file (- for stdin), instead of --item |
| --occurred-atstring | When it happened, unix seconds (default now) |
| --transaction-idstring | The payment's transaction id |
05How it works
Appends one event to the customer's revenue ledger (source api) and updates their totals.
Refunds and chargebacks are sent positive and stored negative; a negative amount is only an
adjustment. Renewals go through p202 ltv subscription event. --idempotency-key makes a retry
safe: the same request again records nothing and answers with the first event (duplicate:
true). A different request under a used key (another amount, customer, items, ...) is refused
naming idempotency_key and what differs, and records nothing: a different event needs its own key.
p202 ltv revenue record --customer-ref CUST-77 --amount 49.00 --idempotency-key ORD-1001 \
--item '{"sku":"PRO-1","quantity":1,"unit_price":49}'06For agents
Running this from an agent
- Read the same facts as JSON:
p202 commands ltv revenue record --json. - With
AI_AGENT,CLAUDECODEor another agent variable set, output is compact JSON and errors arrive on stderr as a JSON envelope with ahint. - Exit codes: 0 ok, 1 bad input, 2 auth, 3 network, 4 server error, 5 partial failure.
- This command writes and cannot be staged:
--stagedis refused before anything is sent. Have a person run it, or give the agent a key without write scope.
{
"path": "p202 ltv revenue record",
"use": "record --amount <n> (--customer-ref <id> | --customer-id <id>)",
"short": "Record a purchase, one-time charge, refund, chargeback or adjustment on a customer",
"long": "Appends one event to the customer's revenue ledger (source api) and updates their totals.\nRefunds and chargebacks are sent positive and stored negative; a negative amount is only an\nadjustment. Renewals go through `p202 ltv subscription event`. --idempotency-key makes a retry\nsafe: the same request again records nothing and answers with the first event (duplicate:\ntrue). A different request under a used key (another amount, customer, items, ...) is refused\nnaming idempotency_key and what differs, and records nothing: a different event needs its own key.\n\n p202 ltv revenue record --customer-ref CUST-77 --amount 49.00 --idempotency-key ORD-1001 \\\n --item '{\"sku\":\"PRO-1\",\"quantity\":1,\"unit_price\":49}'",
"runnable": true,
"flags": [
{
"name": "amount",
"type": "string",
"default": "",
"usage": "The amount, in the account currency (required)",
"required": true
},
{
"name": "currency",
"type": "string",
"default": "",
"usage": "Currency code; must be the account currency (default it)",
"required": false
},
{
"name": "customer-crm",
"type": "string",
"default": "",
"usage": "CRM fields as a JSON object, applied only when this call creates the customer, e.g. '{\"email\":\"[email protected]\",\"first_name\":\"Ada\"}'",
"required": false
},
{
"name": "customer-id",
"type": "string",
"default": "",
"usage": "The customer's internal id (`p202 ltv customers`)",
"required": false
},
{
"name": "customer-ref",
"type": "string",
"default": "",
"usage": "Your system's id for the customer; the server finds it, or creates a customer for it",
"required": false
},
{
"name": "customer-ref-type",
"type": "string",
"default": "",
"usage": "What kind of reference --customer-ref is (default custom): email_md5, email_sha256, esp_id, merchant_id, subid, custom",
"allowed_values": [
"email_md5",
"email_sha256",
"esp_id",
"merchant_id",
"subid",
"custom"
],
"required": false
},
{
"name": "event-type",
"type": "string",
"default": "",
"usage": "What it is (default purchase): purchase, one_time, refund, chargeback, adjustment",
"allowed_values": [
"purchase",
"one_time",
"refund",
"chargeback",
"adjustment"
],
"required": false
},
{
"name": "external-ref",
"type": "string",
"default": "",
"usage": "Your reference for the event (an order number)",
"required": false
},
{
"name": "idempotency-key",
"type": "string",
"default": "",
"usage": "Your id for this event: the same request again records nothing and answers with the first event; a different one under it is refused",
"required": false
},
{
"name": "item",
"type": "stringArray",
"default": "[]",
"usage": "A line item as a JSON object (repeatable), e.g. '{\"sku\":\"PRO-1\",\"name\":\"Pro plan\",\"quantity\":1,\"unit_price\":49}'",
"required": false
},
{
"name": "items-file",
"type": "string",
"default": "",
"usage": "Line items as a JSON array in a file (- for stdin), instead of --item",
"required": false
},
{
"name": "occurred-at",
"type": "string",
"default": "",
"usage": "When it happened, unix seconds (default now)",
"required": false
},
{
"name": "transaction-id",
"type": "string",
"default": "",
"usage": "The payment's transaction id",
"required": false
}
]
}