{
    "openapi": "3.1.0",
    "info": {
        "title": "HStore Partner API",
        "version": "v1",
        "summary": "Production API for catalog sync, balance checks, idempotent orders, and signed webhooks.",
        "description": "All authenticated requests require X-API-Key, X-Timestamp, X-Nonce, and X-Signature. POST /api/v1/orders also requires Idempotency-Key."
    },
    "servers": [
        {
            "url": "https://hstore.site"
        }
    ],
    "components": {
        "securitySchemes": {
            "HStoreApiKey": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-Key",
                "description": "Public key header. Also send X-Timestamp, X-Nonce, and X-Signature."
            }
        },
        "parameters": {
            "TimestampHeader": {
                "name": "X-Timestamp",
                "in": "header",
                "required": true,
                "schema": {
                    "type": "string"
                }
            },
            "NonceHeader": {
                "name": "X-Nonce",
                "in": "header",
                "required": true,
                "schema": {
                    "type": "string"
                }
            },
            "SignatureHeader": {
                "name": "X-Signature",
                "in": "header",
                "required": true,
                "schema": {
                    "type": "string"
                }
            },
            "IdempotencyHeader": {
                "name": "Idempotency-Key",
                "in": "header",
                "required": true,
                "schema": {
                    "type": "string",
                    "maxLength": 190
                }
            }
        },
        "schemas": {
            "ErrorEnvelope": {
                "type": "object",
                "properties": {
                    "success": {
                        "type": "boolean",
                        "const": false
                    },
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            },
                            "status": {
                                "type": "integer"
                            }
                        }
                    }
                }
            }
        }
    },
    "paths": {
        "/api/v1/": {
            "get": {
                "summary": "API metadata",
                "responses": {
                    "200": {
                        "description": "API metadata and supported webhook events."
                    }
                }
            }
        },
        "/api/v1/catalog": {
            "get": {
                "security": [
                    {
                        "HStoreApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TimestampHeader"
                    },
                    {
                        "$ref": "#/components/parameters/NonceHeader"
                    },
                    {
                        "$ref": "#/components/parameters/SignatureHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Catalog page returned."
                    },
                    "401": {
                        "description": "Auth failed.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/products/{id}": {
            "get": {
                "security": [
                    {
                        "HStoreApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TimestampHeader"
                    },
                    {
                        "$ref": "#/components/parameters/NonceHeader"
                    },
                    {
                        "$ref": "#/components/parameters/SignatureHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Product returned."
                    },
                    "404": {
                        "description": "Product unavailable."
                    }
                }
            }
        },
        "/api/v1/balance": {
            "get": {
                "security": [
                    {
                        "HStoreApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TimestampHeader"
                    },
                    {
                        "$ref": "#/components/parameters/NonceHeader"
                    },
                    {
                        "$ref": "#/components/parameters/SignatureHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Balance returned."
                    }
                }
            }
        },
        "/api/v1/orders": {
            "post": {
                "security": [
                    {
                        "HStoreApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TimestampHeader"
                    },
                    {
                        "$ref": "#/components/parameters/NonceHeader"
                    },
                    {
                        "$ref": "#/components/parameters/SignatureHeader"
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyHeader"
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Order created."
                    },
                    "202": {
                        "description": "Order accepted and processing."
                    },
                    "409": {
                        "description": "Conflict or replay state."
                    }
                }
            }
        },
        "/api/v1/orders/{id}": {
            "get": {
                "security": [
                    {
                        "HStoreApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TimestampHeader"
                    },
                    {
                        "$ref": "#/components/parameters/NonceHeader"
                    },
                    {
                        "$ref": "#/components/parameters/SignatureHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Order returned."
                    },
                    "404": {
                        "description": "Order not found."
                    }
                }
            }
        },
        "/api/v1/orders/lookup": {
            "get": {
                "security": [
                    {
                        "HStoreApiKey": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TimestampHeader"
                    },
                    {
                        "$ref": "#/components/parameters/NonceHeader"
                    },
                    {
                        "$ref": "#/components/parameters/SignatureHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Order returned."
                    },
                    "404": {
                        "description": "Order not found."
                    }
                }
            }
        }
    }
}