{
  "openapi": "3.1.0",
  "info": {
    "title": "Physical AI Parts Agent Commerce API",
    "version": "1.0.0",
    "description": "Read approved Physical AI Parts inventory and create/check secure agent-initiated Stripe Checkout sessions."
  },
  "servers": [
    {
      "url": "https://qvrvjmktcdjskvojhqpd.supabase.co/functions/v1/agent-commerce"
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "Search approved marketplace inventory",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "part_number",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Approved inventory catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create agent checkout or check payment status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "listing_id",
                      "buyer_email"
                    ],
                    "properties": {
                      "action": {
                        "const": "checkout"
                      },
                      "listing_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "buyer_email": {
                        "type": "string",
                        "format": "email"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "session_id",
                      "buyer_email"
                    ],
                    "properties": {
                      "action": {
                        "const": "status"
                      },
                      "session_id": {
                        "type": "string"
                      },
                      "buyer_email": {
                        "type": "string",
                        "format": "email"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout URL or order status"
          },
          "400": {
            "description": "Invalid request"
          },
          "409": {
            "description": "Listing unavailable/out of stock/seller not ready"
          }
        }
      }
    }
  }
}