p202 goal create

Create a goal for a campaign, an app registration or the account

Writessupports --staged
All commands

01Run it

Replace the <placeholders> with your own values, or use the builder below.

p202 goal create

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 goal create

Set flags below; the command updates as you type.

04Flags

25 flags, plus the global flags every command takes.

FlagWhat it does
--accountboolOwner: the account (shared by every app)
--afterstringGoal ids that must be reached first, comma-separated
--campaign-idstringOwner: this campaign (p202 campaign list)
--countstringReached on the Nth matching event (default 1)
--definitionstringThe whole definition as JSON (exclusive with the quick flags)
--eventstringTrigger: the event name that reaches the goal
--file, -FstringRead the definition JSON from a file (- for stdin)
--idempotency-keystringRetry-safe create: the server records the response under this key and replays it on a retry with the same key and payload instead of creating a duplicate
--installboolTrigger: the install itself
--namestringGoal name (unique per owner)
--no-valueboolTracked, not paid (value none)
--no-windowboolRemove the window (update)
--not-payableboolCampaign goal: track it, do not pay for it
--notifystringTell the traffic source when the goal is reached (default true): true, false (aliases: 0=false, 1=true, f=false, t=true)
truefalse0 → false1 → truef → falset → true
--payoutstringCampaign payout for reaching the goal (default: the goal's own value)
--registration-idstringOwner: this app registration (p202 app list)
--repeatstringHow often it can be reached (default once): once, each
onceeach
--repeat-maxstringWith --repeat each: the most times it can be reached (1-10000; required for a --sum-prop goal)
--sum-gtestringThe running-sum threshold
--sum-propstringReached when the running sum of this property (or $revenue) reaches --sum-gte
--valuestringFixed value of reaching the goal, e.g. 4.00
--value-from-propertystringValue from an event property (default the event's revenue)
--wherestringConditions on the event, "<prop> <op> <value>", several separated by ; (ANDed); ops: eq, neq, gt, gte, lt, lte, in, exists
--within-daysstringOnly events within this many days of --within-from
--within-fromstringWindow anchor: install, click
installclick

05How it works

Creates version 1 of a goal. Build the definition from the quick flags, or pass the whole JSON with --definition/--file. A campaign goal with a value is payable on its campaign straight away (--payout overrides the value there, --not-payable tracks it only).

06For agents

Running this from an agent

  • Read the same facts as JSON: p202 commands goal create --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. Add --staged to record it as a proposal a person applies with p202 change apply.
p202 commands goal create --json
{
  "path": "p202 goal create",
  "use": "create",
  "short": "Create a goal for a campaign, an app registration or the account",
  "long": "Creates version 1 of a goal. Build the definition from the quick flags, or pass the\nwhole JSON with --definition/--file. A campaign goal with a value is payable on its\ncampaign straight away (--payout overrides the value there, --not-payable tracks it only).",
  "runnable": true,
  "flags": [
    {
      "name": "account",
      "type": "bool",
      "default": "false",
      "usage": "Owner: the account (shared by every app)",
      "required": false
    },
    {
      "name": "after",
      "type": "string",
      "default": "",
      "usage": "Goal ids that must be reached first, comma-separated",
      "required": false
    },
    {
      "name": "campaign-id",
      "type": "string",
      "default": "",
      "usage": "Owner: this campaign (`p202 campaign list`)",
      "required": false
    },
    {
      "name": "count",
      "type": "string",
      "default": "",
      "usage": "Reached on the Nth matching event (default 1)",
      "required": false
    },
    {
      "name": "definition",
      "type": "string",
      "default": "",
      "usage": "The whole definition as JSON (exclusive with the quick flags)",
      "required": false
    },
    {
      "name": "event",
      "type": "string",
      "default": "",
      "usage": "Trigger: the event name that reaches the goal",
      "required": false
    },
    {
      "name": "file",
      "shorthand": "F",
      "type": "string",
      "default": "",
      "usage": "Read the definition JSON from a file (- for stdin)",
      "required": false
    },
    {
      "name": "idempotency-key",
      "type": "string",
      "default": "",
      "usage": "Retry-safe create: the server records the response under this key and replays it on a retry with the same key and payload instead of creating a duplicate",
      "required": false
    },
    {
      "name": "install",
      "type": "bool",
      "default": "false",
      "usage": "Trigger: the install itself",
      "required": false
    },
    {
      "name": "name",
      "type": "string",
      "default": "",
      "usage": "Goal name (unique per owner)",
      "required": false
    },
    {
      "name": "no-value",
      "type": "bool",
      "default": "false",
      "usage": "Tracked, not paid (value none)",
      "required": false
    },
    {
      "name": "no-window",
      "type": "bool",
      "default": "false",
      "usage": "Remove the window (update)",
      "required": false
    },
    {
      "name": "not-payable",
      "type": "bool",
      "default": "false",
      "usage": "Campaign goal: track it, do not pay for it",
      "required": false
    },
    {
      "name": "notify",
      "type": "string",
      "default": "",
      "usage": "Tell the traffic source when the goal is reached (default true): true, false (aliases: 0=false, 1=true, f=false, t=true)",
      "allowed_values": [
        "true",
        "false"
      ],
      "value_aliases": {
        "0": "false",
        "1": "true",
        "f": "false",
        "t": "true"
      },
      "required": false
    },
    {
      "name": "payout",
      "type": "string",
      "default": "",
      "usage": "Campaign payout for reaching the goal (default: the goal's own value)",
      "required": false
    },
    {
      "name": "registration-id",
      "type": "string",
      "default": "",
      "usage": "Owner: this app registration (`p202 app list`)",
      "required": false
    },
    {
      "name": "repeat",
      "type": "string",
      "default": "",
      "usage": "How often it can be reached (default once): once, each",
      "allowed_values": [
        "once",
        "each"
      ],
      "required": false
    },
    {
      "name": "repeat-max",
      "type": "string",
      "default": "",
      "usage": "With --repeat each: the most times it can be reached (1-10000; required for a --sum-prop goal)",
      "required": false
    },
    {
      "name": "sum-gte",
      "type": "string",
      "default": "",
      "usage": "The running-sum threshold",
      "required": false
    },
    {
      "name": "sum-prop",
      "type": "string",
      "default": "",
      "usage": "Reached when the running sum of this property (or $revenue) reaches --sum-gte",
      "required": false
    },
    {
      "name": "value",
      "type": "string",
      "default": "",
      "usage": "Fixed value of reaching the goal, e.g. 4.00",
      "required": false
    },
    {
      "name": "value-from-property",
      "type": "string",
      "default": "",
      "usage": "Value from an event property (default the event's revenue)",
      "required": false
    },
    {
      "name": "where",
      "type": "string",
      "default": "",
      "usage": "Conditions on the event, \"<prop> <op> <value>\", several separated by ; (ANDed); ops: eq, neq, gt, gte, lt, lte, in, exists",
      "required": false
    },
    {
      "name": "within-days",
      "type": "string",
      "default": "",
      "usage": "Only events within this many days of --within-from",
      "required": false
    },
    {
      "name": "within-from",
      "type": "string",
      "default": "",
      "usage": "Window anchor: install, click",
      "allowed_values": [
        "install",
        "click"
      ],
      "required": false
    }
  ]
}