{
  "openapi": "3.1.0",
  "info": {
    "title": "Templa Administrative API — Read-only subset",
    "version": "1.1.0",
    "description": "Version 1 is available at /api/v1/mcp; /api/mcp is a compatible legacy alias. See /docs/versioning.md for compatibility and retirement policy. Authenticated owner API. This document covers three existing read actions only; the owner token also authorizes mutation tools outside this subset.",
    "contact": {
      "email": "support@templa.app",
      "url": "https://templa.app/contact"
    }
  },
  "servers": [
    {
      "url": "https://templa.app"
    }
  ],
  "security": [
    {
      "ownerBearer": []
    }
  ],
  "paths": {
    "/api/mcp": {
      "post": {
        "operationId": "readTemplaCatalog",
        "summary": "Read catalog data as an authorized Templa owner",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "list_products"
                      },
                      "args": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "search": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "category": {
                            "type": "string",
                            "maxLength": 60
                          },
                          "published": {
                            "type": "boolean"
                          },
                          "limit": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 50
                          },
                          "offset": {
                            "type": "integer",
                            "minimum": 0,
                            "default": 0
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "args"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "get_product"
                      },
                      "args": {
                        "type": "object",
                        "required": [
                          "slug"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "slug": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 80,
                            "description": "Product slug; the server trims surrounding whitespace."
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "list_categories"
                      },
                      "args": {
                        "type": "object",
                        "additionalProperties": false
                      }
                    }
                  }
                ]
              },
              "example": {
                "action": "list_products",
                "args": {
                  "published": true,
                  "limit": 10
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "data": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "HTTP 400: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The request is invalid.",
                  "hint": "Send a valid JSON action envelope.",
                  "status": 400,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "401": {
            "description": "HTTP 401: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "missing_token",
                  "code": "missing_token",
                  "message": "An owner token is required or invalid.",
                  "hint": "Send Authorization: Bearer with a valid seller-issued token.",
                  "status": 401,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "403": {
            "description": "HTTP 403: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The token no longer grants administrator access.",
                  "hint": "Check token expiry, revocation and current owner permissions.",
                  "status": 403,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "404": {
            "description": "HTTP 404: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The requested resource or API route does not exist.",
                  "hint": "Check the endpoint and product slug against the documentation.",
                  "status": 404,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "405": {
            "description": "HTTP 405: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "This endpoint accepts POST requests only.",
                  "hint": "Send POST with Content-Type: application/json.",
                  "status": 405,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "422": {
            "description": "HTTP 422: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The action or its arguments are invalid.",
                  "hint": "Validate the request against the OpenAPI schema.",
                  "status": 422,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "429": {
            "description": "HTTP 429: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The request rate limit was reached.",
                  "hint": "Wait before retrying; do not repeatedly retry authorization failures.",
                  "status": 429,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "500": {
            "description": "HTTP 500: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The server could not complete the request.",
                  "hint": "Retry later; contact support if the error persists. Do not assume a mutation succeeded.",
                  "status": 500,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/mcp": {
      "post": {
        "operationId": "readTemplaCatalogV1",
        "summary": "Read catalog data as an authorized Templa owner",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "list_products"
                      },
                      "args": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "search": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "category": {
                            "type": "string",
                            "maxLength": 60
                          },
                          "published": {
                            "type": "boolean"
                          },
                          "limit": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 50
                          },
                          "offset": {
                            "type": "integer",
                            "minimum": 0,
                            "default": 0
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "args"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "get_product"
                      },
                      "args": {
                        "type": "object",
                        "required": [
                          "slug"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "slug": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 80,
                            "description": "Product slug; the server trims surrounding whitespace."
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "list_categories"
                      },
                      "args": {
                        "type": "object",
                        "additionalProperties": false
                      }
                    }
                  }
                ]
              },
              "example": {
                "action": "list_products",
                "args": {
                  "published": true,
                  "limit": 10
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "data": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "HTTP 400: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The request is invalid.",
                  "hint": "Send a valid JSON action envelope.",
                  "status": 400,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "401": {
            "description": "HTTP 401: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "missing_token",
                  "code": "missing_token",
                  "message": "An owner token is required or invalid.",
                  "hint": "Send Authorization: Bearer with a valid seller-issued token.",
                  "status": 401,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "403": {
            "description": "HTTP 403: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The token no longer grants administrator access.",
                  "hint": "Check token expiry, revocation and current owner permissions.",
                  "status": 403,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "404": {
            "description": "HTTP 404: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The requested resource or API route does not exist.",
                  "hint": "Check the endpoint and product slug against the documentation.",
                  "status": 404,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "405": {
            "description": "HTTP 405: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "This endpoint accepts POST requests only.",
                  "hint": "Send POST with Content-Type: application/json.",
                  "status": 405,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "422": {
            "description": "HTTP 422: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The action or its arguments are invalid.",
                  "hint": "Validate the request against the OpenAPI schema.",
                  "status": 422,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "429": {
            "description": "HTTP 429: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The request rate limit was reached.",
                  "hint": "Wait before retrying; do not repeatedly retry authorization failures.",
                  "status": 429,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          },
          "500": {
            "description": "HTTP 500: structured error with resolution hint",
            "headers": {
              "Templa-API-Version": {
                "schema": {
                  "type": "string",
                  "const": "1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "ok": false,
                  "error": "request_failed",
                  "code": "request_failed",
                  "message": "The server could not complete the request.",
                  "hint": "Retry later; contact support if the error persists. Do not assume a mutation succeeded.",
                  "status": 500,
                  "api_version": "1",
                  "docs": "https://templa.app/developers.md"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ApiError": {
        "type": "object",
        "required": [
          "ok",
          "error",
          "code",
          "message",
          "hint",
          "status",
          "api_version",
          "docs"
        ],
        "properties": {
          "ok": {
            "const": false
          },
          "error": {
            "type": "string",
            "description": "Legacy error string retained for existing MCP clients."
          },
          "code": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,79}$"
          },
          "message": {
            "type": "string",
            "minLength": 1
          },
          "hint": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599
          },
          "api_version": {
            "type": "string",
            "const": "1"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    },
    "securitySchemes": {
      "ownerBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Seller-issued administrative token, not a customer session."
      }
    }
  }
}