Agentic Gift Shop

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.

No tokens are published here.

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
catalog:read conversations:read design:read design:write media:write cart:read cart:write orders:read orders:write orders:cancel payments:write fulfillment:write

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.

For agents

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

  1. Fetch products with GET /products.
  2. Fetch detail with GET /products/{product_id}.
  3. Use personalization.capabilities, sizing, variants, colors, sizes, and print areas to guide the customer.
  4. Create a durable draft with POST /design-sessions.
  5. Patch choices and editor layers with PATCH /design-sessions/{design_session_id}.
  6. Generate previews with POST /design-sessions/{design_session_id}/preview.
  7. Send preview_url to the customer and iterate until approved.
  8. Approve the exact design with POST /design-sessions/{design_session_id}/approve.
  9. Create a cart with POST /carts and include channel_identity for messaging channels.
  10. Add the approved design with POST /carts/{cart_id}/items using design_session_id.
  11. Estimate shipping with POST /carts/{cart_id}/shipping-options when the customer shares a destination.
  12. Create a hosted checkout link with POST /carts/{cart_id}/checkout-link.
  13. Send checkout.url to the customer. Do not collect raw card data.
  14. Track order and fulfillment with GET /orders/{order_id}.
  15. 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.

Options

personalization.options exposes customer-selectable values such as color and size.

Variants

personalization.schema.variants contains valid fulfillment combinations. Use it before offering options.

Print Areas

personalization.print_areas and editor.design_areas describe where a gift can be personalized.

Size Guides

sizing.size_guide includes product measurements when available. For shirts, ask chest, height, usual size, and fit preference.

Messaging Images

primary_messaging_image and images[].messaging_src are public product mockups. Generated SVG mockups are not exposed.

Shipping Profile

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.

Agent key only

Agents call this with an Agentic Gift Shop API token. They do not receive or need the store OpenAI key.

Artwork first

By default, concepts are not approval proofs. After the customer chooses one, call the design-session preview endpoint for the official product proof.

Approval guardrails

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.

Controlled use

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.

Coordinates

x, y, width, and height are 0 to 1. A full-area design is x:0, y:0, width:1, height:1.

Print Areas

activePrintArea and per-layer printArea must use values from personalization.print_areas.

Images

Upload PNG, JPG, or WebP images with POST /media, then set attachment_id. Do not hotlink arbitrary image URLs.

Text

Use type:text, text, font, fontSize, color, align, bounds, and rotation. Unsupported fonts normalize to Inter.

Layer Order

Layers are drawn in array order. Put background artwork first and text later when text should appear above art.

No Fallback Mockups

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"
    }
  ]
}
Customer approval loop

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
Customer approval is part of the contract

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.

No substitute mockups

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"
Writable identity fields

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.

Channelchannel_instance_idchannel_user_idNotes
WhatsAppWhatsApp phone_number_idCustomer wa_id or inbound messages[].fromMay also set phone for checkout prefill.
MessengerFacebook Page IDPSID/Page-scoped sender IDMessenger does not automatically provide customer phone/email.
Instagram DMInstagram Professional account ID / IGIDInstagram-scoped customer ID / IGSIDUse webhook sender.id for the customer and recipient.id or entry id for the business account.
SMSBusiness SMS number or messaging service idCustomer E.164 sender numberSet phone too, but mark verified only after OTP or equivalent.
iMessageApple business account/deployment idOpaque Apple customer or conversation idDo not assume phone/email unless separately provided and verified.
WebSite or app idAuthenticated customer id or stable session idSet verified only after login or equivalent verification.
EmailMailbox/inbox idCustomer email or contact idUse 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
Safe revisions after cart

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"
Estimate, then checkout confirms

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.

Product-specific availability

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
Read-only support surface

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
Hosted checkout handoff

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.

Cancellation orchestration

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"
Native or embedded checkout surface

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.

Payment status

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.

Price modifiers

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.

POST /checkout_sessions

Create an ACP session for an existing approved Agent API cart.

GET /checkout_sessions/{id}

Fetch the latest ACP session state, including completed state if the browser checkout became an order.

POST /checkout_sessions/{id}

Update buyer, fulfillment, selected fulfillment, discounts, or metadata.

POST /checkout_sessions/{id}/cancel

Cancel an ACP session before it has produced a WooCommerce order.

Endpoint Reference

Method Path Purpose
GET/healthPublic health check.
GET/auth/whoamiCheck token identity and scopes.
GET/productsList products.
GET/products/{product_id}Product detail, personalization schema, variants, sizing, and fulfillment metadata.
POST/products/{product_id}/personalization/previewGenerate a customer-shareable preview image.
POST/mediaUpload a customer image for editor layers.
GET/conversationsList WhatsApp conversations for support/debugging.
GET/conversations/{conversation_id}Read a conversation summary.
GET/conversations/{conversation_id}/messagesRead customer and agent timeline.
GET/conversations/{conversation_id}/stateRead session state and recent agent actions.
POST/design-conceptsGenerate AI artwork options and draft design sessions.
POST/design-sessionsCreate a durable personalization draft.
GET/PATCH/design-sessions/{design_session_id}Read or update a personalization draft.
POST/design-sessions/{design_session_id}/previewGenerate or refresh a customer-shareable design preview.
POST/design-sessions/{design_session_id}/approveMark the exact current design as customer-approved.
POST/cartsCreate 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}/itemsAdd personalized item.
PATCH/DELETE/carts/{cart_id}/items/{item_id}Update quantity or remove item.
POST/carts/{cart_id}/items/{item_id}/revisionCreate a safe revision preview for a carted item.
POST/carts/{cart_id}/items/{item_id}/revision/commitReplace the cart item with an approved revision.
POST/carts/{cart_id}/shipping-optionsEstimate store-branded shipping options for a destination.
POST/carts/{cart_id}/checkout-linkCreate or reuse a signed hosted checkout URL for the customer.
POST/carts/{cart_id}/orderCreate WooCommerce order and payment URL.
GET/orders/{order_id}Read order, payment, fulfillment, and shipment status.
POST/orders/{order_id}/payment-linkRefresh hosted payment URL.
POST/orders/{order_id}/fulfillment/refreshRefresh fulfillment status.
POST/orders/{order_id}/cancelCancel supplier order, refund payment, update WooCommerce, and notify customer.
POST/acp/checkout_sessionsCreate 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}/completeACP complete route; currently returns browser-checkout escalation.
POST/acp/checkout_sessions/{checkout_session_id}/cancelCancel an ACP session before order creation.

Machine-readable spec: openapi.json.