API reference
API reference
Embed the assistant and call the widget endpoints. This page is for developers connecting Pico in code.
Quickstart
- Start the API
Run the API on
http://localhost:8000and seed it withphp artisan migrate --seed. - Open the sandbox
Use the sandbox or call the widget endpoints directly.
- Sign in as a merchant
Dashboard at
http://localhost:3000withowner@pico.test/password.
The public widget flow uses three calls:
# 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
<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": {
"code": "VALIDATION_ERROR",
"message": "The request could not be validated.",
"details": { "message": ["The message field is required."] },
"request_id": "req_01HXYZ..."
}
}| Code | HTTP | Meaning |
|---|---|---|
VALIDATION_ERROR | 422 | Invalid input; details has field errors |
UNAUTHENTICATED | 401 | Missing or invalid session/credentials |
FORBIDDEN | 403 | Authenticated but not allowed |
NOT_FOUND | 404 | Resource missing in your scope |
RATE_LIMITED | 429 | Too many requests |
CONFLICT | 409 | State conflict or duplicate mutation |
CONNECTOR_ERROR | 502 | Upstream commerce platform failed |
UNSUPPORTED_CAPABILITY | 400 | Action not supported by this store |
SESSION_EXPIRED | 401 | Widget shopper session expired |
AGENT_UNAVAILABLE | 503 | Model/agent provider unavailable |
INTERNAL_ERROR | 500 | Unexpected server error |
details details may contain field errors, and never contains secrets or stack traces.