- Register once. เก็บ api_key ไว้ถาวร ห้ามเรียก /agents/register ซ้ำ แม้ได้ 403 agent_pending_approval / agent_key_expired ให้เช็ก GET /agents/me แทน
- Keys expire daily. key หมดอายุเที่ยงคืน (Asia/Bangkok) ร้านกด "ต่ออายุ" แล้วใช้ key เดิมต่อได้ทันที REVOKED = ร้านเพิกถอน หยุดใช้
- Idempotency-Key on every POST. UUID v4 ใหม่ทุกคำสั่ง (8–128 ตัว A-Z a-z 0-9 . _ : -) ส่งซ้ำด้วย key เดิมได้ผลเดิม ไม่ตัดสต็อกซ้ำ
- Server prices win. ใช้ item id จาก /menu ราคาและยอดรวมคำนวณที่เซิร์ฟเวอร์เสมอ ค่าที่ agent ส่งมาไม่ถูกใช้
- Delivery needs the buyer. agent สร้างออเดอร์จัดส่งเองไม่ได้: เรียก /orders/prepare แล้วส่ง continue_url ให้ผู้ซื้อ login และยืนยัน (อายุ ≤ 1 ชม.)
- Signatures (recommended). ผูก signing_jwk (ES256/Ed25519) แล้วทุกคำขอต้องเซ็น RFC 9421: @method @authority @path (+@query, content-digest, content-type, idempotency-key)
- Rate limits. GET /orders/<id> 60/นาที, /agents/me 30/นาที ใช้ webhook แทนการ poll ถี่ ๆ
1Register (one time)
Optional: signing_jwk + webhook_urlOptional fields: signing_jwk (public JWK; sign this request with it) and webhook_url (must echo the signed webhook.verification challenge).
curl -X POST https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/agents/register \
-H "Content-Type: application/json" \
-d '{ "agent_name": "MyAssistantAI", "scopes": ["order:create", "order:read"] }'
# 201 → { "agent_id": "...", "api_key": "pgm_...", "approval_status": "PENDING", ... }
# Save api_key now. It is shown only once.2Check approval
Proceed only when can_transact = truecurl https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/agents/me -H "Authorization: Bearer pgm_YOUR_SAVED_KEY"
# approval_status: PENDING | APPROVED | EXPIRED | REVOKED
# { "approval_status": "APPROVED", "can_transact": true, "key_expires_at": "...",
# "signing": { "bound": false }, "webhook_url": null }3Discover capabilities & catalog
Publiccurl https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/capabilities
curl https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/menu
curl "https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/order-schema?intent=order"
4AOrder for pickup (intent "order")
Food & goodscurl -X POST https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/orders -H "Authorization: Bearer pgm_YOUR_SAVED_KEY" \
-H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
-d '{ "intent": "order", "items": [{ "id": "290142f0-b5af-438d-b34d-62e498d9db80", "quantity": 1 }], "notes": "No chili" }'
# → { "order_id": "...", "status": "pending_confirmation", "total": ..., "tracking_url": "..." }5Track the order
Webhook preferredWebhooks are signed (ES256, keys in the discovery document). data.status is the status at the event; ignore events whose order_version is older than one you applied.
curl https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/orders/<ORDER_ID> -H "Authorization: Bearer pgm_YOUR_SAVED_KEY"
curl https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/track/<ORDER_ID> -H "Authorization: Bearer pgm_YOUR_SAVED_KEY"
# Webhook body:
# { "type": "order.updated", "api_version": "2026-10-21",
# "data": { "order_id": "...", "status": "preparing", "previous_status": "pending_confirmation",
# "current_status": "ready", "order_version": 3, "occurred_at": "..." } }6Payment intent
PromptPay or cash_on_deliverycurl -X POST https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/orders/<ORDER_ID>/payment -H "Authorization: Bearer pgm_YOUR_SAVED_KEY" \
-H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
-d '{ "provider": "promptpay" }'7Cancel (orders you created, before the buyer owns them)
curl -X POST https://pugmod.com/api/v1/commerce/store/c410b936-f1d1-4744-84d4-75052c3bdf50/orders/<ORDER_ID>/cancel -H "Authorization: Bearer pgm_YOUR_SAVED_KEY"