p202 ltv subscription event

Record a subscription's renewal (extends it, adds revenue), refund (negative revenue) or cancellation

New in 1.9.77Writescannot be staged
All commands

01Run it

Straight from the command's own help.

p202 ltv subscription event sub_123 --type renewal --transaction-id ch_889

02What you get

Pick the shape you need. People get a table. Add --json, --csv or --ndjson for scripts, or -q for ids only. An AI agent gets compact JSON without asking. All output formats

03Build your command

Pick values and the command line writes itself, quoted and ready to paste.

p202 ltv subscription event

Set flags below; the command updates as you type.

04Flags

7 flags, plus the global flags every command takes.

FlagWhat it does
--amountstringRenewal or refund amount (default the subscription's amount)
--currencystringCurrency code; must be the account currency (default it)
--idempotency-keystringYour id for this renewal or refund: the same request again records nothing; a different one under it is refused
--occurred-atstringWhen it happened, unix seconds (default now)
--period-endstringRenewal only: the new paid-through time, unix seconds (default one interval on)
--transaction-idstringThe payment's transaction id (also makes a retry safe when there is no key)
--typestringrequiredWhat happened (required): renewal, cancel, refund
renewalcancelrefund

05How it works

renewal adds a renewal to the ledger (the subscription's amount unless --amount), extends the paid-through period and reactivates it; refund adds negative revenue; cancel marks it canceled and moves no money. --idempotency-key (or --transaction-id) makes a retried renewal or refund safe; a repeat answers changed: false. A different amount, time or transaction id under a used key is refused, naming the key, and records nothing.

p202 ltv subscription event sub_123 --type renewal --transaction-id ch_889

06For agents

Running this from an agent

  • Read the same facts as JSON: p202 commands ltv subscription event --json.
  • With AI_AGENT, CLAUDECODE or another agent variable set, output is compact JSON and errors arrive on stderr as a JSON envelope with a hint.
  • Exit codes: 0 ok, 1 bad input, 2 auth, 3 network, 4 server error, 5 partial failure.
  • This command writes and cannot be staged: --staged is refused before anything is sent. Have a person run it, or give the agent a key without write scope.
p202 commands ltv subscription event --json
{
  "path": "p202 ltv subscription event",
  "use": "event <external-sub-id> --type renewal|cancel|refund",
  "short": "Record a subscription's renewal (extends it, adds revenue), refund (negative revenue) or cancellation",
  "long": "renewal adds a renewal to the ledger (the subscription's amount unless --amount), extends the\npaid-through period and reactivates it; refund adds negative revenue; cancel marks it canceled\nand moves no money. --idempotency-key (or --transaction-id) makes a retried renewal or refund\nsafe; a repeat answers changed: false. A different amount, time or transaction id under a used\nkey is refused, naming the key, and records nothing.\n\n  p202 ltv subscription event sub_123 --type renewal --transaction-id ch_889",
  "runnable": true,
  "flags": [
    {
      "name": "amount",
      "type": "string",
      "default": "",
      "usage": "Renewal or refund amount (default the subscription's amount)",
      "required": false
    },
    {
      "name": "currency",
      "type": "string",
      "default": "",
      "usage": "Currency code; must be the account currency (default it)",
      "required": false
    },
    {
      "name": "idempotency-key",
      "type": "string",
      "default": "",
      "usage": "Your id for this renewal or refund: the same request again records nothing; a different one under it is refused",
      "required": false
    },
    {
      "name": "occurred-at",
      "type": "string",
      "default": "",
      "usage": "When it happened, unix seconds (default now)",
      "required": false
    },
    {
      "name": "period-end",
      "type": "string",
      "default": "",
      "usage": "Renewal only: the new paid-through time, unix seconds (default one interval on)",
      "required": false
    },
    {
      "name": "transaction-id",
      "type": "string",
      "default": "",
      "usage": "The payment's transaction id (also makes a retry safe when there is no key)",
      "required": false
    },
    {
      "name": "type",
      "type": "string",
      "default": "",
      "usage": "What happened (required): renewal, cancel, refund",
      "allowed_values": [
        "renewal",
        "cancel",
        "refund"
      ],
      "required": true
    }
  ]
}