{
  "openapi": "3.1.0",
  "info": {
    "title": "JENNi Instant Commerce API",
    "description": "Autonomous commerce API for AI agents. Enables searching recently read local store shelf inventory, checking shelf prices (re-checked at checkout) and store hours, checking courier delivery options and same-day guarantees, locking delivery quotes, and generating secure Stripe checkout links for local delivery and shipping from neighborhood US retail merchants.\n",
    "version": "1.1.0",
    "contact": {
      "name": "JENNi / Jockey Delivery Support",
      "email": "support@jockeyvc.com",
      "url": "https://delivery.jockeyvc.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://delivery.jockeyvc.com",
      "description": "Production Delivery API"
    }
  ],
  "paths": {
    "/api/search": {
      "get": {
        "operationId": "searchCatalog",
        "summary": "Search Product Catalog",
        "description": "Search physical retail shelf inventory from local US merchants.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Search term or keyword (e.g. 'boots', 'batteries')",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum items to return (default 10, max 50)",
            "schema": {
              "type": "integer",
              "default": 10
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number",
            "schema": {
              "type": "integer",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching catalog products",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "query": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "products": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jpid": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "price": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "availability": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "image_url": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/products/{jpid}": {
      "get": {
        "operationId": "getProduct",
        "summary": "Get Product Details",
        "description": "Retrieves product details, current shelf price, availability, and description.",
        "parameters": [
          {
            "name": "jpid",
            "in": "path",
            "required": true,
            "description": "Unique product ID (e.g. JPID_BOOT_001)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Product details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "product": {
                      "type": "object",
                      "properties": {
                        "jpid": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "price": {
                          "type": "number"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "availability": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "image_url": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Product not found"
          }
        }
      }
    },
    "/api/delivery/options": {
      "get": {
        "operationId": "checkDeliveryOptions",
        "summary": "Verify Delivery Eligibility & Options",
        "description": "Check available courier delivery windows (same_day, next_day) and fee schedules for a destination ZIP code.",
        "parameters": [
          {
            "name": "zip",
            "in": "query",
            "required": true,
            "description": "5-digit US delivery ZIP code (e.g. 78205)",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{5}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery feasibility and options",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "enum": [
                              "same_day",
                              "next_day"
                            ]
                          },
                          "label": {
                            "type": "string"
                          },
                          "display": {
                            "type": "string"
                          },
                          "feeMinor": {
                            "type": "integer",
                            "description": "Delivery fee in cents (e.g. 999 for $9.99)"
                          },
                          "headline": {
                            "type": "string"
                          },
                          "dateLabel": {
                            "type": "string"
                          },
                          "cta": {
                            "type": "string"
                          },
                          "orderByAt": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          }
                        }
                      }
                    },
                    "note": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/delivery/guarantee": {
      "get": {
        "operationId": "checkDeliveryGuarantee",
        "summary": "Check Same-Day Delivery Guarantee Eligibility",
        "description": "Verifies whether a specific product and destination ZIP qualify for guaranteed same-day delivery.",
        "parameters": [
          {
            "name": "jpid",
            "in": "query",
            "required": true,
            "description": "Product identifier",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "zip",
            "in": "query",
            "required": true,
            "description": "5-digit delivery ZIP code",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Guarantee eligibility assessment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "eligible": {
                      "type": "boolean"
                    },
                    "promiseCopy": {
                      "type": "string"
                    },
                    "orderByAt": {
                      "type": "string"
                    },
                    "serverNow": {
                      "type": "string"
                    },
                    "terms": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "customerMessage": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/address/suggest": {
      "get": {
        "operationId": "suggestAddress",
        "summary": "Autocomplete Delivery Address",
        "description": "Autocompletes and standardizes street addresses within the courier delivery zone.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Address search query string (minimum 3 characters)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of matching standardized addresses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "line1": {
                            "type": "string",
                            "description": "House number and street"
                          },
                          "city": {
                            "type": "string"
                          },
                          "state": {
                            "type": "string"
                          },
                          "postcode": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string",
                            "description": "Single-line standardized address"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/address/reverse": {
      "get": {
        "operationId": "reverseAddress",
        "summary": "Reverse Geocode Delivery Address",
        "description": "Resolves GPS latitude and longitude coordinates into a standardized US delivery address.",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "lon",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matched address or out-of-area notification",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "address": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "line1": {
                          "type": "string"
                        },
                        "city": {
                          "type": "string"
                        },
                        "state": {
                          "type": "string"
                        },
                        "postcode": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        }
                      }
                    },
                    "message": {
                      "type": "string",
                      "description": "Out-of-area or informational message when ok is false"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid coordinates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/checkout": {
      "post": {
        "operationId": "createOrderQuote",
        "summary": "Create Order Booking & Lock Quote",
        "description": "Validates product shelf stock, store hours, and destination address. Locks the total price (shelf price + local tax + courier delivery fee) and reserves a courier delivery window. Returns an order review and a checkout token required to finalize the order.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jpid",
                  "street",
                  "zip"
                ],
                "properties": {
                  "jpid": {
                    "type": "string",
                    "description": "The unique product identifier (e.g. JPID_BOOT_001)"
                  },
                  "variant_id": {
                    "type": "string",
                    "description": "The specific size/color variant identifier if applicable"
                  },
                  "street": {
                    "type": "string",
                    "description": "Street address for courier delivery"
                  },
                  "zip": {
                    "type": "string",
                    "description": "5-digit delivery ZIP code"
                  },
                  "unit": {
                    "type": "string",
                    "description": "Apartment, suite, or unit number (optional)"
                  },
                  "deliveryAddress": {
                    "type": "object",
                    "description": "Alternative nested address structure",
                    "properties": {
                      "street": {
                        "type": "string"
                      },
                      "apt": {
                        "type": "string"
                      },
                      "zip": {
                        "type": "string"
                      }
                    }
                  },
                  "deliveryOption": {
                    "type": "string",
                    "enum": [
                      "same_day",
                      "next_day"
                    ],
                    "default": "same_day"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote created and locked successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "checkout_token": {
                      "type": "string",
                      "description": "Opaque token used to confirm quote acceptance and generate payment link"
                    },
                    "pricing": {
                      "type": "object",
                      "properties": {
                        "shelfPrice": {
                          "type": "number"
                        },
                        "salesTax": {
                          "type": "number"
                        },
                        "courierFee": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        }
                      }
                    },
                    "review": {
                      "type": "object",
                      "properties": {
                        "item": {
                          "type": "string"
                        },
                        "totalMinor": {
                          "type": "integer"
                        },
                        "deliveryWindow": {
                          "type": "string"
                        },
                        "deadlineAt": {
                          "type": "string"
                        },
                        "expiresAt": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Store closed, delivery window unavailable, or stock unconfirmed"
          },
          "422": {
            "description": "Invalid address or product unavailable"
          }
        }
      }
    },
    "/api/checkout/accept": {
      "post": {
        "operationId": "confirmOrderPaymentLink",
        "summary": "Confirm Quote & Retrieve Stripe Payment Link",
        "description": "Called after the customer accepts the order review. Generates a secure, hosted Stripe Checkout URL. The agent never touches card details; the customer completes payment directly on Stripe.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "checkout_token"
                ],
                "properties": {
                  "checkout_token": {
                    "type": "string",
                    "description": "The checkout_token returned from /api/checkout"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Secure payment URL generated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "payment_url": {
                      "type": "string",
                      "description": "Hosted Stripe Checkout session URL"
                    },
                    "expires_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/orders/{orderId}/track": {
      "get": {
        "operationId": "trackOrder",
        "summary": "Track Order Delivery Status",
        "description": "Retrieves live fulfillment, courier dispatch, and delivery status for an active order.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "description": "The order identifier (e.g. Stripe session ID or order ID)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order tracking details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "order": {
                      "type": "object",
                      "properties": {
                        "orderId": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "stepIndex": {
                          "type": "integer"
                        },
                        "statusText": {
                          "type": "string"
                        },
                        "statusDescription": {
                          "type": "string"
                        },
                        "isTerminal": {
                          "type": "boolean"
                        },
                        "fulfilledBy": {
                          "type": "string",
                          "example": "Jockey Delivery"
                        },
                        "pricing": {
                          "type": "object",
                          "properties": {
                            "shelfPrice": {
                              "type": "number"
                            },
                            "tax": {
                              "type": "number"
                            },
                            "courierFee": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          }
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Order ID required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Order not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/ucp": {
      "get": {
        "operationId": "ucpDiscovery",
        "summary": "Universal Commerce Protocol (UCP) Discovery Document",
        "description": "Machine-readable discovery document declaring commerce capabilities and endpoints.",
        "responses": {
          "200": {
            "description": "UCP discovery JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ucp": {
                      "type": "object",
                      "properties": {
                        "version": {
                          "type": "string",
                          "example": "2026-08-25"
                        },
                        "services": {
                          "type": "object",
                          "properties": {
                            "dev.ucp.shopping": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "version": {
                                    "type": "string",
                                    "example": "2026-08-25"
                                  },
                                  "transport": {
                                    "type": "string",
                                    "example": "mcp"
                                  },
                                  "endpoint": {
                                    "type": "string",
                                    "format": "uri",
                                    "example": "https://delivery.jockeyvc.com/mcp"
                                  },
                                  "methods": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    },
                                    "example": [
                                      "initialize",
                                      "tools/list",
                                      "tools/call"
                                    ]
                                  }
                                }
                              }
                            }
                          }
                        },
                        "capabilities": {
                          "type": "object"
                        },
                        "policies": {
                          "type": "object",
                          "properties": {
                            "requires_buyer_approval": {
                              "type": "boolean",
                              "example": true
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpEndpoint",
        "summary": "Streamable HTTP Model Context Protocol (MCP) Endpoint",
        "description": "JSON-RPC 2.0 endpoint implementing Model Context Protocol tools for AI agents (search_catalog, get_product, get_delivery_info, create_checkout, confirm_checkout).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jsonrpc",
                  "method"
                ],
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "example": "2.0"
                  },
                  "id": {
                    "type": "integer",
                    "example": 1
                  },
                  "method": {
                    "type": "string",
                    "example": "tools/list"
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC tool list or tool execution response, or SSE stream"
          }
        }
      }
    }
  }
}
