{
  "openapi": "3.1.0",
  "info": {
    "title": "PushSLog API",
    "version": "1.0.0",
    "description": "API REST multitenant para logística, pedidos y canales. Especificación parcial — ver https://docs.pushslog.com/docs/api-reference"
  },
  "servers": [{ "url": "https://api.pushslog.com" }],
  "tags": [
    { "name": "health", "description": "Disponibilidad" },
    { "name": "auth", "description": "Sesión del panel" },
    { "name": "tenant", "description": "API keys" },
    { "name": "custom", "description": "Ecommerce propio (pk_)" },
    { "name": "channels", "description": "Registro y OAuth por plataforma" },
    { "name": "webhooks", "description": "Eventos entrantes" }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": ["health"],
        "summary": "Liveness",
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/health/ready": {
      "get": {
        "tags": ["health"],
        "summary": "Readiness (BD + Redis)",
        "responses": {
          "200": { "description": "OK" },
          "503": { "description": "No listo" }
        }
      }
    },
    "/api/v1/auth/login": {
      "post": {
        "tags": ["auth"],
        "summary": "Login panel",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenantSlug", "email", "password"],
                "properties": {
                  "tenantSlug": { "type": "string" },
                  "email": { "type": "string", "format": "email" },
                  "password": { "type": "string" }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/refresh": {
      "post": {
        "tags": ["auth"],
        "summary": "Renovar tokens",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["refreshToken"],
                "properties": { "refreshToken": { "type": "string" } }
              }
            }
          }
        }
      }
    },
    "/api/v1/tenant/api-keys": {
      "get": {
        "tags": ["tenant"],
        "summary": "Listar API keys",
        "security": [{ "bearerAuth": [] }]
      },
      "post": {
        "tags": ["tenant"],
        "summary": "Crear API key pk_",
        "security": [{ "bearerAuth": [] }]
      }
    },
    "/api/v1/shopify/oauth/diagnostics": {
      "get": {
        "tags": ["channels"],
        "summary": "Diagnóstico OAuth Shopify"
      }
    },
    "/api/v1/shopify/oauth/start": {
      "get": {
        "tags": ["channels"],
        "summary": "Iniciar OAuth Shopify (sesión panel)",
        "security": [{ "bearerAuth": [] }],
        "parameters": [
          {
            "name": "shop",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "example": "tienda.myshopify.com" }
          }
        ]
      }
    },
    "/api/v1/woocommerce/shops/register": {
      "post": {
        "tags": ["channels"],
        "summary": "Registrar tienda WooCommerce",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/woocommerce/shops/{shopId}/sync-status": {
      "get": {
        "tags": ["channels"],
        "summary": "Estado sync Woo",
        "security": [{ "apiKeyAuth": [] }],
        "parameters": [
          { "name": "shopId", "in": "path", "required": true, "schema": { "type": "string" } }
        ]
      }
    },
    "/api/v1/mercadolibre/shops/register": {
      "post": {
        "tags": ["channels"],
        "summary": "Registrar seller Mercado Libre",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/mercadolibre/oauth/start": {
      "get": {
        "tags": ["channels"],
        "summary": "OAuth Mercado Libre",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/tiendanube/shops/register": {
      "post": {
        "tags": ["channels"],
        "summary": "Registrar Tienda Nube",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/tiendanube/oauth/start": {
      "get": {
        "tags": ["channels"],
        "summary": "OAuth Tienda Nube",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/custom/shops/register": {
      "post": {
        "tags": ["custom"],
        "summary": "Registrar tienda CUSTOM",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/custom/orders": {
      "post": {
        "tags": ["custom"],
        "summary": "Ingestar pedido CUSTOM",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/custom/catalog/products": {
      "post": {
        "tags": ["custom"],
        "summary": "Sincronizar catálogo CUSTOM",
        "security": [{ "apiKeyAuth": [] }]
      }
    },
    "/api/v1/webhook/custom": {
      "post": {
        "tags": ["webhooks"],
        "summary": "Webhook pedido CUSTOM (HMAC)",
        "parameters": [
          {
            "name": "X-PushSLog-Shop-Id",
            "in": "header",
            "required": true,
            "schema": { "type": "string" }
          },
          {
            "name": "X-PushSLog-Signature",
            "in": "header",
            "required": true,
            "schema": { "type": "string" }
          }
        ]
      }
    },
    "/api/v1/webhook/shopify": {
      "post": { "tags": ["webhooks"], "summary": "Webhook Shopify" }
    },
    "/api/v1/webhook/woocommerce": {
      "post": { "tags": ["webhooks"], "summary": "Webhook WooCommerce" }
    },
    "/api/v1/webhook/mercadolibre": {
      "post": { "tags": ["webhooks"], "summary": "Webhook Mercado Libre" }
    },
    "/api/v1/webhook/tiendanube": {
      "post": { "tags": ["webhooks"], "summary": "Webhook Tienda Nube" }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Access token del panel (app.pushslog.com)"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Clave pk_ emitida desde el panel"
      }
    }
  }
}
