Pico DocsSandbox

API reference

API reference

Embed the assistant and call the widget endpoints. This page is for developers connecting Pico in code.

API v1

Quickstart

  1. Start the API

    Run the API on http://localhost:8000 and seed it with php artisan migrate --seed.

  2. Open the sandbox

    Use the sandbox or call the widget endpoints directly.

  3. Sign in as a merchant

    Dashboard at http://localhost:3000 with owner@pico.test / password.

The public widget flow uses three calls:

Widget session flow
# 1. Fetch widget configuration (public, no auth)
curl http://localhost:8000/api/v1/widget/config/pw_sandbox_demo_widget_001

# 2. Start a shopper session
curl -X POST http://localhost:8000/api/v1/widget/sessions \
  -H "Content-Type: application/json" \
  -d '{"public_widget_id":"pw_sandbox_demo_widget_001","locale":"en"}'

# 3. Send a message
curl -X POST http://localhost:8000/api/v1/widget/sessions/<session_id>/messages \
  -H "Content-Type: application/json" \
  -d '{"message":"Waterproof hiking boots under 150"}'

Embed the widget

Storefront embed
<script type="module" src="https://cdn.example.com/pico-widget.js"
  data-public-widget-id="pw_sandbox_demo_widget_001"
  data-api-url="http://localhost:8000/api/v1"></script>

The widget renders inside a Shadow DOM so your site styles can’t break it. Add-to-cart is only shown when the connected store reports the add_to_cart capability.

Error format

Every error uses an HTTP status and one consistent JSON body. Always log request_id when reporting an issue.

Error body
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "The request could not be validated.",
    "details": { "message": ["The message field is required."] },
    "request_id": "req_01HXYZ..."
  }
}
CodeHTTPMeaning
VALIDATION_ERROR422Invalid input; details has field errors
UNAUTHENTICATED401Missing or invalid session/credentials
FORBIDDEN403Authenticated but not allowed
NOT_FOUND404Resource missing in your scope
RATE_LIMITED429Too many requests
CONFLICT409State conflict or duplicate mutation
CONNECTOR_ERROR502Upstream commerce platform failed
UNSUPPORTED_CAPABILITY400Action not supported by this store
SESSION_EXPIRED401Widget shopper session expired
AGENT_UNAVAILABLE503Model/agent provider unavailable
INTERNAL_ERROR500Unexpected server error

details details may contain field errors, and never contains secrets or stack traces.

API reference · Pico