AnyaSelf Docs

Headless CartPrep

Automated shopping cart preparation via headless browser automation.

The headless-cartprep service isolates the fragile logic of automating third-party e-commerce carts from the core Orchestrator. When the AI agent decides to build a cart, it dispatches a job here for asynchronous browser-based automation.

Endpoints

MethodPathDescription
POST/api/v1/households/{id}/cartprep/jobsCreate a new cart prep job
GET/api/v1/households/{id}/cartprep/jobs/{jobId}Poll job state + result
POST/api/v1/households/{id}/cartprep/jobs/{jobId}/processTrigger async processing

Create Job

{
  "offerUrl": "https://brand.com/jacket-1",
  "size": "M",
  "color": "Black",
  "quantity": 1,
  "shippingPrefs": "standard",
  "sessionId": "ses_99xyz",
  "purchaseRequestId": "req_123",
  "purchaseIntentId": "pi_456"
}

Job Response

{
  "jobId": "cp_abc123",
  "householdId": "h1",
  "requestedByUserId": "usr_1",
  "purchaseRequestId": "req_123",
  "purchaseIntentId": "pi_456",
  "state": "CART_READY",
  "offerUrl": "https://brand.com/jacket-1",
  "size": "M",
  "color": "Black",
  "quantity": 1,
  "cartUrl": "https://brand.com/cart?session=xyz",
  "recording": [...],
  "summary": { "itemsAdded": 1, "total": "$450.00" },
  "errorCode": null,
  "errorMessage": null,
  "createdAt": "2026-03-08T10:00:00+00:00",
  "updatedAt": "2026-03-08T10:00:12+00:00"
}

Job Lifecycle

See Data Models → CartPrep Job Lifecycle for the state diagram and full error code table.

Runner Backends

BackendDescription
simulatedImmediate fake success — no browser launched (default for local dev)
playwrightReal Chromium instance via Playwright, physically manipulating the DOM

Configuration

VariableDefaultDescription
CARTPREP_RUNNER_BACKENDsimulatedsimulated or playwright
CARTPREP_ENFORCE_DOMAIN_ALLOWLISTfalseRestrict automation to allowed domains
PERSISTENCE_BACKENDinmemoryfirestore or inmemory
ARTIFACTS_AUDIT_BASE_URLhttp://artifacts-audit:8007/api/v1Audit service URL
ARTIFACTS_AUDIT_ENABLEDtrueEnable recording persistence
ARTIFACTS_AUDIT_REQUIREDfalseFail if audit service unreachable

On this page