p202 ltv customer upsert

Create or update a customer by --customer-ref (your id) or --customer-id

New in 1.9.77Writescannot be staged
All commands

01Run it

Straight from the command's own help.

p202 ltv customer upsert --customer-ref ORD-CUST-77 --email [email protected] --first-name Ada
p202 ltv customer upsert --customer-ref 9f1c… --customer-ref-type email_md5 --field plan=pro

02What you get

Captured from the real binary, run against a demo store with 30 days of traffic. Switch tabs to see the same run as JSON, the shape scripts and agents parse.

p202 ltv customer upsert --customer-ref cust-2001 --email [email protected] --first-name Ava --last-name Bennett
$ p202 ltv customer upsert --customer-ref cust-2001 --email [email protected] --first-name Ava --last-name Bennett
active_subscription_count:  0
address_line1:              
address_line2:              
aliases:                    [{"alias_id":116,"alias_type":"custom","alias_value":"cust-2001","created_at":1791540199}]
city:                       
company:                    
company_id:                 
country:                    
created_at:                 1791540199
custom_fields:              []
customer_id:                116
email:                      [email protected]
first_click_id:             
first_name:                 Ava
first_seen_time:            1791540199
last_activity_time:         1791540199
last_name:                  Bennett
merged_into_customer_id:    
mrr:                        0.00000
order_count:                0
phone:                      
postal_code:                
primary_ref:                cust-2001
recent_events:              []
refunded_amount:            0.00000
region:                     
status:                     active
subscriptions:              []
total_revenue:              0.00000
updated_at:                 1791540199
Real output · p202 1.9.77 · demo dataexit 0

03Build your command

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

p202 ltv customer upsert

Set flags below; the command updates as you type.

04Flags

16 flags, plus the global flags every command takes.

FlagWhat it does
--address-line1stringAddress line 1 ("" clears it)
--address-line2stringAddress line 2 ("" clears it)
--aliasstringArrayAnother identifier for this customer, type=value (repeatable; type is one of email_md5, email_sha256, esp_id, merchant_id, subid, custom)
--citystringCity ("" clears it)
--companystringCompany: attaches the customer to that company (created if new); "" detaches ("" clears it)
--countrystringCountry ("" clears it)
--customer-idstringThe customer's internal id (p202 ltv customers)
--customer-refstringYour system's id for the customer; the server finds it, or creates a customer for it
--customer-ref-typestringWhat kind of reference --customer-ref is (default custom): email_md5, email_sha256, esp_id, merchant_id, subid, custom
email_md5email_sha256esp_idmerchant_idsubidcustom
--emailstringEmail address ("" clears it)
--fieldstringArrayA custom field value, key=value (repeatable; key= with nothing after = clears it; p202 ltv fields list shows the keys)
--first-namestringFirst name ("" clears it)
--last-namestringLast name ("" clears it)
--phonestringPhone ("" clears it)
--postal-codestringPostal code ("" clears it)
--regionstringRegion or state ("" clears it)

05How it works

Finds the customer by --customer-id, or by --customer-ref (+ --customer-ref-type), creating one when no customer has that reference, then applies the record flags in one transaction. A record flag given empty clears that field; a flag not given leaves it as it is.

p202 ltv customer upsert --customer-ref ORD-CUST-77 --email [email protected] --first-name Ada
p202 ltv customer upsert --customer-ref 9f1c… --customer-ref-type email_md5 --field plan=pro

06For agents

Running this from an agent

  • Read the same facts as JSON: p202 commands ltv customer upsert --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 customer upsert --json
{
  "path": "p202 ltv customer upsert",
  "use": "upsert",
  "short": "Create or update a customer by --customer-ref (your id) or --customer-id",
  "long": "Finds the customer by --customer-id, or by --customer-ref (+ --customer-ref-type), creating one\nwhen no customer has that reference, then applies the record flags in one transaction.\nA record flag given empty clears that field; a flag not given leaves it as it is.\n\n  p202 ltv customer upsert --customer-ref ORD-CUST-77 --email [email protected] --first-name Ada\n  p202 ltv customer upsert --customer-ref 9f1c… --customer-ref-type email_md5 --field plan=pro",
  "runnable": true,
  "flags": [
    {
      "name": "address-line1",
      "type": "string",
      "default": "",
      "usage": "Address line 1 (\"\" clears it)",
      "required": false
    },
    {
      "name": "address-line2",
      "type": "string",
      "default": "",
      "usage": "Address line 2 (\"\" clears it)",
      "required": false
    },
    {
      "name": "alias",
      "type": "stringArray",
      "default": "[]",
      "usage": "Another identifier for this customer, type=value (repeatable; type is one of email_md5, email_sha256, esp_id, merchant_id, subid, custom)",
      "required": false
    },
    {
      "name": "city",
      "type": "string",
      "default": "",
      "usage": "City (\"\" clears it)",
      "required": false
    },
    {
      "name": "company",
      "type": "string",
      "default": "",
      "usage": "Company: attaches the customer to that company (created if new); \"\" detaches (\"\" clears it)",
      "required": false
    },
    {
      "name": "country",
      "type": "string",
      "default": "",
      "usage": "Country (\"\" clears it)",
      "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": "email",
      "type": "string",
      "default": "",
      "usage": "Email address (\"\" clears it)",
      "required": false
    },
    {
      "name": "field",
      "type": "stringArray",
      "default": "[]",
      "usage": "A custom field value, key=value (repeatable; key= with nothing after = clears it; `p202 ltv fields list` shows the keys)",
      "required": false
    },
    {
      "name": "first-name",
      "type": "string",
      "default": "",
      "usage": "First name (\"\" clears it)",
      "required": false
    },
    {
      "name": "last-name",
      "type": "string",
      "default": "",
      "usage": "Last name (\"\" clears it)",
      "required": false
    },
    {
      "name": "phone",
      "type": "string",
      "default": "",
      "usage": "Phone (\"\" clears it)",
      "required": false
    },
    {
      "name": "postal-code",
      "type": "string",
      "default": "",
      "usage": "Postal code (\"\" clears it)",
      "required": false
    },
    {
      "name": "region",
      "type": "string",
      "default": "",
      "usage": "Region or state (\"\" clears it)",
      "required": false
    }
  ]
}