Agent API documentation
This API lets approved agents browse products, explain variants and sizing, create personalized previews, build carts, hand customers to hosted checkout, and test ACP checkout sessions in parallel.
Use a token issued separately by the store owner. Do not put live tokens in public prompts, screenshots, or shared docs.
Base URL:
https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/agent
Authentication
Every protected request uses bearer-token auth. Tokens are scoped and can be revoked.
Authorization: Bearer AGS_AGENT_API_TOKEN
Access Management
Agent API tokens are issued separately by the store owner. There is no public self-service token dashboard yet. Tokens are generated server-side, saved as hashes, and shown only once when created.
Ask the store owner for a token and use it only in secure tool configuration or secret storage. Never paste live tokens into shared prompts or public docs.
Recommended Agent Flow
- Fetch products with
GET /products. - Fetch detail with
GET /products/{product_id}. - Use
personalization.capabilities,sizing, variants, colors, sizes, and print areas to guide the customer. - Create a durable draft with
POST /design-sessions. - Patch choices and editor layers with
PATCH /design-sessions/{design_session_id}. - Generate previews with
POST /design-sessions/{design_session_id}/preview. - Send
preview_urlto the customer and iterate until approved. - Approve the exact design with
POST /design-sessions/{design_session_id}/approve. - Create a cart with
POST /cartsand includechannel_identityfor messaging channels. - Add the approved design with
POST /carts/{cart_id}/itemsusingdesign_session_id. - Estimate shipping with
POST /carts/{cart_id}/shipping-optionswhen the customer shares a destination. - Create a hosted checkout link with
POST /carts/{cart_id}/checkout-link. - Send
checkout.urlto the customer. Do not collect raw card data. - Track order and fulfillment with
GET /orders/{order_id}. - Cancel only with customer confirmation using
POST /orders/{order_id}/cancel.
Products, Variants, And Sizing
Product detail responses are self-describing. Agents should use the returned schema instead of hardcoding colors, sizes, print areas, fonts, or valid variants.
personalization.options exposes customer-selectable values such as color and size.
personalization.schema.variants contains valid fulfillment combinations. Use it before offering options.
personalization.print_areas and editor.design_areas describe where a gift can be personalized.
sizing.size_guide includes product measurements when available. For shirts, ask chest, height, usual size, and fit preference.
primary_messaging_image and images[].messaging_src are public product mockups. Generated SVG mockups are not exposed.
supplier.shipping_profile warns that shipping methods vary by product/provider. Resolve exact methods with the cart shipping quote.
curl -H "Authorization: Bearer $AGS_AGENT_API_TOKEN" \
"https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/agent/products/24"
Personalization Preview
The product preview endpoint is still available for one-off previews. For WhatsApp and other long-running conversations, use design sessions instead so customer choices survive multiple messages and webhook retries.
Personalized previews are rendered from the same official product
editor templates used by the product page. Agents may provide a PNG
client_preview_data_url exported from that editor, or let the API
compose the preview server-side. If the official template cannot be rendered,
the API returns an error instead of substituting another image.
curl -X POST \
-H "Authorization: Bearer $AGS_AGENT_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"options": {
"color": "Heather Kelly",
"size": "3XL"
},
"print_area": "Front side",
"editor_state": {
"activePrintArea": "Front side",
"layers": [
{
"type": "text",
"text": "ELF",
"x": 0.28,
"y": 0.38,
"width": 0.44,
"height": 0.18,
"rotation": 0,
"font": "Inter",
"fontSize": 9,
"color": "#ffffff",
"align": "center"
}
]
}
}' \
"https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/agent/products/24/personalization/preview"
For image layers, upload the image first with POST /media, then use
the returned attachment_id in the layer.
Design Concepts
Use this high-level endpoint when a customer asks for generated visual options. The store generates flat artwork server-side, stores it as media, places it into durable draft design sessions, and returns artwork images for customer selection.
Agents call this with an Agentic Gift Shop API token. They do not receive or need the store OpenAI key.
By default, concepts are not approval proofs. After the customer chooses one, call the design-session preview endpoint for the official product proof.
If the API filled missing size/color defaults, responses include defaulted_options. Confirm those options before approval; approve rejects sessions that have not rendered an official preview.
The store pays for image generation. Generate small, intentional sets such as two or three options.
curl -X POST \
-H "Authorization: Bearer $AGS_AGENT_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"product_id": 24,
"prompt": "three floral print-ready shirt artwork options with pink flowers, warm boutique typography, spring gift feel",
"count": 3,
"options": {
"color": "Pink",
"size": "M"
},
"print_area": "Front side",
"idempotency_key": "whatsapp-message-id-or-agent-turn-id"
}' \
"https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/agent/design-concepts"
Send each design_concepts[].concept_image_url or
messaging.image_url to the customer as an image option or carousel.
If used_default_options is true, confirm or change the returned
defaulted_options before approval/cart.
When the customer chooses one, continue with that design_session_id,
call /design-sessions/{design_session_id}/preview for the official
product proof, approve, add to cart, and create a checkout link.
Editor Layer Contract
Agents personalize gifts by sending the same editor_state shape used
by the browser editor. Coordinates are normalized inside the selected printable
area, not the whole product image.
x, y, width, and height are 0 to 1. A full-area design is x:0, y:0, width:1, height:1.
activePrintArea and per-layer printArea must use values from personalization.print_areas.
Upload PNG, JPG, or WebP images with POST /media, then set attachment_id. Do not hotlink arbitrary image URLs.
Use type:text, text, font, fontSize, color, align, bounds, and rotation. Unsupported fonts normalize to Inter.
Layers are drawn in array order. Put background artwork first and text later when text should appear above art.
Previews use official product templates. If one cannot render, the API returns a recovery error instead of substituting generated product art.
{
"activePrintArea": "Front side",
"layers": [
{
"type": "image",
"attachment_id": 123,
"imageName": "floral-stamp.png",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"rotation": 0,
"removeBackground": false
},
{
"type": "text",
"text": "Blooming With Love",
"x": 0.18,
"y": 0.12,
"width": 0.64,
"height": 0.16,
"rotation": 0,
"font": "Inter",
"fontSize": 8,
"color": "#2f6846",
"align": "center"
}
]
}
After every text, image, color, size, placement, scale, or rotation change, patch the design session, generate a fresh preview, send preview_url, and wait for explicit approval before cart.
Design Sessions
A design session is a durable personalized line-item draft. It stores the product, selected variant options, print area, editor layers, generated preview, and customer approval state. Agents should add approved design sessions to cart instead of rebuilding personalization from chat memory.
POST /design-sessions
GET /design-sessions/{design_session_id}
PATCH /design-sessions/{design_session_id}
POST /design-sessions/{design_session_id}/preview
POST /design-sessions/{design_session_id}/approve
Add a design to cart with design_session_id only after the customer approves the preview. The approve endpoint rejects missing previews, and generated concepts that used defaulted size/color options can require options_confirmed=true after customer confirmation. If a design is incomplete or unapproved, the API returns clear recovery hints such as missing options, missing content, or needing a fresh preview.
POST /design-sessions/{design_session_id}/preview returns a personalized PNG from the official product editor template. It can also accept client_preview_data_url when an agent has rendered the browser editor itself.
curl -X POST \
-H "Authorization: Bearer $AGS_AGENT_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"design_session_id": "design_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"quantity": 1
}' \
"https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/agent/carts/cart_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/items"
Carts
Create a cart after the customer has approved a preview. The preferred path is to add an approved design_session_id; the API will preserve the exact options, print area, editor layers, preview, and approval hash.
channel_identity is writable on cart creation. WhatsApp, Messenger,
Instagram DM, SMS, and similar agents should send it on POST /carts
so the paid order can later be found by the same channel identity.
curl -X POST \
-H "Authorization: Bearer $AGS_AGENT_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"channel_identity": {
"channel": "messenger",
"channel_instance_id": "FACEBOOK_PAGE_ID",
"channel_user_id": "PAGE_SCOPED_ID_FROM_MESSENGER",
"display_name": "Customer Name"
}
}' \
"https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/agent/carts"
Use channel_identity on POST /carts. Use PATCH /carts/{cart_id} only to attach or correct identity before checkout conversion. customer_identity is accepted as an alias, but channel_identity is preferred.
Messenger should send the Facebook Page ID as channel_instance_id and the PSID/Page-scoped ID as channel_user_id. WhatsApp should send the inbound wa_id as channel_user_id, and may also send it as phone for checkout prefill.
| Channel | channel_instance_id | channel_user_id | Notes |
|---|---|---|---|
WhatsApp phone_number_id | Customer wa_id or inbound messages[].from | May also set phone for checkout prefill. | |
| Messenger | Facebook Page ID | PSID/Page-scoped sender ID | Messenger does not automatically provide customer phone/email. |
| Instagram DM | Instagram Professional account ID / IGID | Instagram-scoped customer ID / IGSID | Use webhook sender.id for the customer and recipient.id or entry id for the business account. |
| SMS | Business SMS number or messaging service id | Customer E.164 sender number | Set phone too, but mark verified only after OTP or equivalent. |
| iMessage | Apple business account/deployment id | Opaque Apple customer or conversation id | Do not assume phone/email unless separately provided and verified. |
| Web | Site or app id | Authenticated customer id or stable session id | Set verified only after login or equivalent verification. |
| Mailbox/inbox id | Customer email or contact id | Use verified only after magic link, OTP, account login, or support verification. |
{
"channel_identity": {
"channel": "instagram",
"channel_instance_id": "INSTAGRAM_PROFESSIONAL_ACCOUNT_ID",
"channel_user_id": "INSTAGRAM_SCOPED_CUSTOMER_ID",
"display_name": "Customer Name"
}
}
POST /carts
GET /carts/{cart_id}
PATCH /carts/{cart_id}
POST /carts/{cart_id}/items
PATCH /carts/{cart_id}/items/{item_id}
DELETE /carts/{cart_id}/items/{item_id}
POST /carts/{cart_id}/items/{item_id}/revision
POST /carts/{cart_id}/items/{item_id}/revision/commit
If the customer changes size, color, placement, or design for a carted item, call /items/{item_id}/revision first. Send the returned preview, approve the revision design session after explicit customer approval, then call /revision/commit. The original cart item is unchanged until commit.
Shipping Options
Estimate store-branded shipping options after the cart has approved personalized items. The API intentionally abstracts fulfillment providers; agents should quote the returned labels, costs, and transit guidance without naming suppliers.
Shipping methods are product-specific. A mug may return Standard, Priority, and Express, while a poster, tee, cap, or tote may only return Standard for the same destination. Agents must quote only the options returned for the exact cart.
curl -X POST \
-H "Authorization: Bearer $AGS_AGENT_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"destination": {
"country": "US",
"region": "CA",
"city": "San Francisco",
"postal_code": "94107"
}
}' \
"https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/agent/carts/cart_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/shipping-options"
accuracy is destination_estimate when the customer only gave country, region, city, or ZIP/postal code. Include address_line1 for an address_quote. Shipping and tax are still finalized in hosted checkout before payment.
availability.available_types lists the methods available for this cart and destination. If availability.limited_to_standard is true, do not offer faster methods unless a later quote returns them.
Conversation Debug
The API exposes read-only WhatsApp conversation history for support and agent debugging. These endpoints help a supervisor inspect customer messages, outbound responses, active cart state, checkout links, recent actions, and where a handoff stalled.
GET /conversations
GET /conversations/{conversation_id}
GET /conversations/{conversation_id}/messages?limit=200
GET /conversations/{conversation_id}/state
Conversation endpoints require conversations:read. They do not send messages, change carts, or modify orders.
Orders And Payments
The preferred messaging handoff is a hosted checkout link. The agent builds and personalizes the cart, then sends a signed browser URL so the customer fills contact, shipping, billing, and payment details in WooCommerce checkout.
POST /carts/{cart_id}/order
POST /carts/{cart_id}/checkout-link
POST /orders/{order_id}/payment-link
GET /orders/{order_id}
POST /orders/{order_id}/fulfillment/refresh
POST /orders/{order_id}/cancel
POST /carts/{cart_id}/checkout-link requires cart:read and cart:write. It returns a signed, expiring /ags-agent-checkout/{token} URL. When the customer opens it, the store loads the saved personalized agent cart into a normal WooCommerce session and redirects to /checkout/.
Repeated calls return the same active URL while the cart is unchanged. If the cart changes, request a fresh link. Empty, expired, stale, converted, or unavailable carts return API errors with recovery hints.
POST /orders/{order_id}/cancel requires orders:cancel, payments:write, and fulfillment:write. The request must include confirm_cancel_and_refund: true. The store cancels the supplier order first, then refunds the WooCommerce/Stripe payment only if supplier cancellation succeeds.
Order responses include actions.cancel and payment.remaining_refund_amount so agents can explain whether cancellation is available, already completed, or blocked by supplier status.
Agents must not call the cancel endpoint when actions.cancel.available is false. Orders that are in production, ready to ship, shipped, out for delivery, delivered, fulfilled, or completed should be handed to support instead. Use actions.cancel.customer_message and actions.cancel.support_contact; the current support email is hello@agenticgiftshop.com.
ACP Test Adapter
ACP runs beside the production WooCommerce checkout. For the MVP, agents still
use the Agent API to personalize products and build a cart, then create an ACP
checkout session from that cart. Agents with ACP UI can render this response as
a native or embedded checkout review, then use continue_url for hosted
WooCommerce payment.
ACP Base URL:
https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/acp
curl -X POST \
-H "Authorization: Bearer $AGS_AGENT_API_TOKEN" \
-H "Idempotency-Key: $UUID" \
-H "API-Version: 2026-04-17" \
-H "Content-Type: application/json" \
-d '{
"line_items": [
{ "id": "cart_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }
],
"currency": "usd",
"capabilities": {},
"metadata": {
"agent_cart_id": "cart_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}' \
"https://store.agenticgiftshop.com/wp-json/agentic-gift-shop/v1/acp/checkout_sessions"
Use line_items, line_items[].images, line_items[].variant_options, line_items[].custom_attributes, totals, messages, and links to show the customer an ACP-native review. The first line-item image is the personalized preview when available, so customized gifts can be shown before checkout.
Native ACP delegated payment completion is intentionally disabled while browser checkout is the live payment path. POST /checkout_sessions/{id}/complete accepts ACP-shaped payment_data, then returns the session as requires_escalation with the same continue_url. Agents should open or send continue_url after the customer approves the native review.
Personalization does not currently change price. If it does later, agents should trust line_items[].totals and top-level totals instead of recalculating from the base catalog price. Extra personalization fees can be represented as fee totals and explained in custom_attributes.
Create an ACP session for an existing approved Agent API cart.
Fetch the latest ACP session state, including completed state if the browser checkout became an order.
Update buyer, fulfillment, selected fulfillment, discounts, or metadata.
Cancel an ACP session before it has produced a WooCommerce order.
Endpoint Reference
| Method | Path | Purpose |
|---|---|---|
| GET | /health | Public health check. |
| GET | /auth/whoami | Check token identity and scopes. |
| GET | /products | List products. |
| GET | /products/{product_id} | Product detail, personalization schema, variants, sizing, and fulfillment metadata. |
| POST | /products/{product_id}/personalization/preview | Generate a customer-shareable preview image. |
| POST | /media | Upload a customer image for editor layers. |
| GET | /conversations | List WhatsApp conversations for support/debugging. |
| GET | /conversations/{conversation_id} | Read a conversation summary. |
| GET | /conversations/{conversation_id}/messages | Read customer and agent timeline. |
| GET | /conversations/{conversation_id}/state | Read session state and recent agent actions. |
| POST | /design-concepts | Generate AI artwork options and draft design sessions. |
| POST | /design-sessions | Create a durable personalization draft. |
| GET/PATCH | /design-sessions/{design_session_id} | Read or update a personalization draft. |
| POST | /design-sessions/{design_session_id}/preview | Generate or refresh a customer-shareable design preview. |
| POST | /design-sessions/{design_session_id}/approve | Mark the exact current design as customer-approved. |
| POST | /carts | Create cart. Messaging agents should send writable channel_identity here. |
| GET/PATCH | /carts/{cart_id} | Read cart, or update customer, metadata, and channel_identity. |
| POST | /carts/{cart_id}/items | Add personalized item. |
| PATCH/DELETE | /carts/{cart_id}/items/{item_id} | Update quantity or remove item. |
| POST | /carts/{cart_id}/items/{item_id}/revision | Create a safe revision preview for a carted item. |
| POST | /carts/{cart_id}/items/{item_id}/revision/commit | Replace the cart item with an approved revision. |
| POST | /carts/{cart_id}/shipping-options | Estimate store-branded shipping options for a destination. |
| POST | /carts/{cart_id}/checkout-link | Create or reuse a signed hosted checkout URL for the customer. |
| POST | /carts/{cart_id}/order | Create WooCommerce order and payment URL. |
| GET | /orders/{order_id} | Read order, payment, fulfillment, and shipment status. |
| POST | /orders/{order_id}/payment-link | Refresh hosted payment URL. |
| POST | /orders/{order_id}/fulfillment/refresh | Refresh fulfillment status. |
| POST | /orders/{order_id}/cancel | Cancel supplier order, refund payment, update WooCommerce, and notify customer. |
| POST | /acp/checkout_sessions | Create an ACP test session from an approved agent cart. |
| GET/POST | /acp/checkout_sessions/{checkout_session_id} | Read or update an ACP session. |
| POST | /acp/checkout_sessions/{checkout_session_id}/complete | ACP complete route; currently returns browser-checkout escalation. |
| POST | /acp/checkout_sessions/{checkout_session_id}/cancel | Cancel an ACP session before order creation. |
Machine-readable spec: openapi.json.