{
    "schemes": [
        "https",
        "http"
    ],
    "swagger": "2.0",
    "info": {
        "description": "REST API for ERP systems to integrate with VirCat stores.\nAuthenticate all requests with an API key issued from the vendor's\nIntegrations panel (Settings → Integrations → API Keys).\n\n## Authentication\nAll endpoints require `Authorization: Bearer \u003capi_key\u003e` in the request header.\nThe API key determines which store's data is accessed — no additional\nstore ID parameter is needed.\n\nAn invalid or inactive key returns `401`. A valid key whose store plan does not include\nERP integrations returns `403` with `code: PLAN_SIN_INTEGRACION_ERP`.\nA transient validation failure returns `503` (`SERVICE_UNAVAILABLE`); retry with backoff.\n\n## Base URL\n`https://backend-vircat.fly.dev` (production) | `http://localhost:3000` (local)",
        "title": "VirCat ERP Integration API",
        "contact": {
            "name": "VirCat Support",
            "email": "soporte@vircat.shop"
        },
        "version": "1.0"
    },
    "host": "backend-vircat.fly.dev",
    "basePath": "/api/erp",
    "paths": {
        "/categorias": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Keyset-paginated list of the store's active categories, ordered by id. Pass `next_cursor` as `after` to get the next page; `next_cursor` is null on the last page.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "List categories",
                "parameters": [
                    {
                        "minimum": 0,
                        "type": "integer",
                        "description": "Cursor: return ids greater than this (default 0)",
                        "name": "after",
                        "in": "query"
                    },
                    {
                        "maximum": 500,
                        "minimum": 1,
                        "type": "integer",
                        "description": "Page size (default 100, max 500)",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoListResponse"
                        }
                    },
                    "400": {
                        "description": "invalid after/limit, or the removed page param (page is no longer supported; use after/next_cursor)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Create category",
                "parameters": [
                    {
                        "description": "nombre required",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoRequest"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "validation error naming the field",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/categorias/{id}": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Get category",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "category id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "invalid id",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Partial update: only the fields sent change.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Update category",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "category id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Fields to change (at least one)",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "validation error naming the field",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Soft delete. Fails with 409 while the category still has active subcategories.",
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Delete category",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "category id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "204": {
                        "description": "deleted"
                    },
                    "400": {
                        "description": "invalid id",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "409": {
                        "description": "category has active subcategories",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/marcas": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Keyset-paginated list of the store's active brands, ordered by id. Pass `next_cursor` as `after` to get the next page; `next_cursor` is null on the last page.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "List brands",
                "parameters": [
                    {
                        "minimum": 0,
                        "type": "integer",
                        "description": "Cursor: return ids greater than this (default 0)",
                        "name": "after",
                        "in": "query"
                    },
                    {
                        "maximum": 500,
                        "minimum": 1,
                        "type": "integer",
                        "description": "Page size (default 100, max 500)",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoListResponse"
                        }
                    },
                    "400": {
                        "description": "invalid after/limit, or the removed page param (page is no longer supported; use after/next_cursor)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Create brand",
                "parameters": [
                    {
                        "description": "nombre required",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoRequest"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "validation error naming the field",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/marcas/{id}": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Get brand",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "brand id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "invalid id",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Partial update: only the fields sent change.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Update brand",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "brand id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Fields to change (at least one)",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "validation error naming the field",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Soft delete. Fails with 409 while the brand is still used by active products.",
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Delete brand",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "brand id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "204": {
                        "description": "deleted"
                    },
                    "400": {
                        "description": "invalid id",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "409": {
                        "description": "brand is used by active products",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/pedidos": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Keyset-paginated list of the store's orders, newest first (by id_pedido). Pass the\nresponse `next_cursor` as `after` to get the next page; a null `next_cursor` is the last page.\n`desde` / `hasta` are accepted as aliases of `fecha_desde` / `fecha_hasta`.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-orders"
                ],
                "summary": "List orders",
                "parameters": [
                    {
                        "minimum": 0,
                        "type": "integer",
                        "description": "Cursor: return orders with id_pedido lower than this (default: newest)",
                        "name": "after",
                        "in": "query"
                    },
                    {
                        "maximum": 500,
                        "minimum": 1,
                        "type": "integer",
                        "description": "Page size (default 100, max 500)",
                        "name": "limit",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by status: PENDIENTE | PREPARANDO | ENVIADO | ENTREGADO | CANCELADO",
                        "name": "estado",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Start date filter, inclusive. Accepts YYYY-MM-DD (00:00 Paraguay time, UTC-3), YYYY-MM-DDTHH:MM:SS or YYYY-MM-DD HH:MM:SS (offset-less = Paraguay time, UTC-3; optional fractional seconds), or an RFC 3339 timestamp with offset",
                        "name": "fecha_desde",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "End date filter. Accepts YYYY-MM-DD (that whole day in Paraguay time, UTC-3), or an inclusive timestamp as YYYY-MM-DDTHH:MM:SS or YYYY-MM-DD HH:MM:SS (offset-less = Paraguay time, UTC-3; optional fractional seconds) or RFC 3339 with offset",
                        "name": "fecha_hasta",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPListPedidosResponse"
                        }
                    },
                    "400": {
                        "description": "malformed after / limit / estado / dates, fecha_desde after fecha_hasta, or the removed page param (page is no longer supported; use after/next_cursor)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Registers an order from the ERP system. Creates the order and its line items\nin a single transaction, decrements stock of the stock-controlled products, and fires the\n`PEDIDO_CREADO` webhook asynchronously if one is configured. It notifies the store owner in the\npanel only if the store enabled \"Notificarme cuando el ERP crea o actualiza pedidos\" (default off).\n\nEach item must have `id_producto` (and `id_variante`, if any) of this store, `cantidad \u003e 0`, and `precio_unit \u003e 0`;\nforeign ids return 400 naming them. `estado` is one of PENDIENTE, PREPARANDO, ENVIADO, ENTREGADO, CANCELADO (default PENDIENTE).\nOptional `cliente_nombre` / `cliente_telefono` store the customer contact (needed for `notificar_cliente`).\n`precio_total` per item is optional — calculated automatically if omitted.\n\nSend an `Idempotency-Key` header (max 200 chars) to make retries safe: if this store already\ncreated an order with that key, that order is returned with 200 instead of creating a duplicate.\nThe key identifies the order, not the payload: a replay with a different body still returns the first order.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-orders"
                ],
                "summary": "Create order",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Client-chosen unique key for this order (max 200 chars)",
                        "name": "Idempotency-Key",
                        "in": "header"
                    },
                    {
                        "description": "Order data",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCreatePedidoRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "replay: an order with this Idempotency-Key already exists",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCreatePedidoResponse"
                        }
                    },
                    "201": {
                        "description": "Created",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCreatePedidoResponse"
                        }
                    },
                    "400": {
                        "description": "validation error (empty items, missing fields)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/pedidos/{id}": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Returns the full detail of one order including all line items.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-orders"
                ],
                "summary": "Get order detail",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "Order ID (id_pedido)",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPPedidoDetail"
                        }
                    },
                    "400": {
                        "description": "invalid id format",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "order not found",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "patch": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Updates `estado`, `numero_seguimiento`, `url_seguimiento` and/or `notas_internas` of an order\n(only sent fields change; an empty string clears a text field). `estado` accepts the same values\nas the seller panel: PENDIENTE, PREPARANDO, ENVIADO, ENTREGADO, CANCELADO, in any direction.\nMoving to CANCELADO returns the stock the order took, in the same transaction; reopening a\ncancelled order takes it again (409 `stock_insuficiente` if it no longer fits).\nA real estado change also notifies the store owner in the panel, only if the store enabled\n\"Notificarme cuando el ERP crea o actualiza pedidos\" (default off).\nSend `notificar_cliente: true` to also WhatsApp the customer the new estado (same message as the\npanel). It is skipped silently when the store has no WhatsApp connected or the customer has no\ncontact: the response then carries `cliente_notificado: false` and a `motivo`; the update never fails.\nThe customer contact is the order's `cliente_telefono`, else the linked client's phone, else the\nordering user's contact only if it is not the store owner or team. Orders created through the API\nonly have a customer contact if `cliente_telefono` was sent when creating them.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-orders"
                ],
                "summary": "Update order",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "Order ID (id_pedido)",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Fields to change",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPPedidoPatch"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPPedidoPatchResponse"
                        }
                    },
                    "400": {
                        "description": "invalid id, empty body or invalid field",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "order not found",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "409": {
                        "description": "reopening a cancelled order: not enough stock (error stock_insuficiente)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": true
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/pedidos/{id}/cancelar": {
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Same as `PATCH /pedidos/{id}` with `{\"estado\":\"CANCELADO\"}`: the order's stock goes back to the\ninventory in the same transaction. Cancelling an already cancelled order is a no-op (200).\nOptional body `{\"notificar_cliente\": true}` WhatsApps the customer, as in `PATCH /pedidos/{id}`\n(an empty or non-JSON body is ignored; the order is cancelled anyway). Orders created through the\nAPI only have a customer contact if `cliente_telefono` was sent when creating them.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-orders"
                ],
                "summary": "Cancel order",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "Order ID (id_pedido)",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Optional: notificar_cliente",
                        "name": "body",
                        "in": "body",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCancelBody"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPPedidoPatchResponse"
                        }
                    },
                    "400": {
                        "description": "invalid id",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "order not found",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/productos": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Keyset-paginated list of the store's active (not deleted) products, ordered by id_producto. Pass `next_cursor` as `after` to get the next page; `next_cursor` is null on the last page. Replaces the former `page`/`total` pagination.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "List products",
                "parameters": [
                    {
                        "minimum": 0,
                        "type": "integer",
                        "description": "Cursor: return ids greater than this (default 0)",
                        "name": "after",
                        "in": "query"
                    },
                    {
                        "maximum": 500,
                        "minimum": 1,
                        "type": "integer",
                        "description": "Page size (default 100, max 500)",
                        "name": "limit",
                        "in": "query"
                    },
                    {
                        "enum": [
                            "ACTIVO",
                            "INACTIVO",
                            "AGOTADO"
                        ],
                        "type": "string",
                        "description": "Filter by status",
                        "name": "estado",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPListProductosResponse"
                        }
                    },
                    "400": {
                        "description": "invalid after/limit/estado, or the removed page param (page is no longer supported; use after/next_cursor)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Creates a product in the store of the API key. `codigo` must contain at least one non-digit character (all-digit values address products by id) and be unique among the store's non-deleted products (case-insensitive); a deleted product's codigo can be reused. `id_marca` / `id_sub_categoria` must belong to the store. `precio_promo` must not exceed `precio`. `estado` defaults to ACTIVO.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Create product",
                "parameters": [
                    {
                        "description": "Product data (codigo, nombre, precio required)",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPProductoRequest"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPProducto"
                        }
                    },
                    "400": {
                        "description": "validation error or id_marca/id_sub_categoria not in your store",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan limit reached, or plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "409": {
                        "description": "duplicate codigo; id_producto of the existing product returned",
                        "schema": {
                            "type": "object",
                            "additionalProperties": true
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/productos/{id}": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "`:id` is a numeric `id_producto` or the product `codigo`.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Get product",
                "parameters": [
                    {
                        "type": "string",
                        "description": "id_producto (numeric) or codigo",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPProducto"
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Partial update; send only the fields to change (at least one). `:id` is a numeric `id_producto` or the product `codigo`; a `codigo` sent in the body must contain at least one non-digit character (all-digit values address products by id). `id_marca` / `id_sub_categoria` must belong to the store; 0 clears them. `precio_promo` must not exceed the resulting `precio`. `stock` is not accepted here: use PATCH /productos/{id}/stock. Returns the updated product.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Update product",
                "parameters": [
                    {
                        "type": "string",
                        "description": "id_producto (numeric) or codigo",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Fields to update",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPProductoRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPProducto"
                        }
                    },
                    "400": {
                        "description": "validation error or id_marca/id_sub_categoria not in your store",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "409": {
                        "description": "codigo already used by another product",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Soft-deletes the product (it disappears from the storefront and from list/get; its codigo can be reused). `:id` is a numeric `id_producto` or the product `codigo`.",
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Delete product",
                "parameters": [
                    {
                        "type": "string",
                        "description": "id_producto (numeric) or codigo",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "204": {
                        "description": "deleted"
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/productos/{id}/stock": {
            "patch": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Sets or adjusts the stock level of a product atomically.\n`cantidad` is required (400 if absent). `:id` may be the numeric id or the `codigo` (case-insensitive).\n`mode: \"set\"` replaces the stock with `cantidad`.\n`mode: \"delta\"` adds/subtracts `cantidad` from the current stock (negative = decrement).\nThe `:id` path parameter can be a numeric `id_producto` or the string `codigo`.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Adjust stock",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Product ID (numeric) or codigo (string)",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Stock adjustment",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPAdjustStockRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPAdjustStockResponse"
                        }
                    },
                    "400": {
                        "description": "invalid mode or resulting stock \u003c 0",
                        "schema": {
                            "type": "object",
                            "additionalProperties": true
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "product not found",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/sub_categorias": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Keyset-paginated list of the store's active subcategories, ordered by id. Pass `next_cursor` as `after` to get the next page; `next_cursor` is null on the last page.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "List subcategories",
                "parameters": [
                    {
                        "minimum": 0,
                        "type": "integer",
                        "description": "Cursor: return ids greater than this (default 0)",
                        "name": "after",
                        "in": "query"
                    },
                    {
                        "maximum": 500,
                        "minimum": 1,
                        "type": "integer",
                        "description": "Page size (default 100, max 500)",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoListResponse"
                        }
                    },
                    "400": {
                        "description": "invalid after/limit, or the removed page param (page is no longer supported; use after/next_cursor)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Create subcategory",
                "parameters": [
                    {
                        "description": "nombre required, id_categoria required (must belong to the store)",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoRequest"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "validation error naming the field",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/sub_categorias/{id}": {
            "get": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Get subcategory",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "subcategory id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "invalid id",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "put": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Partial update: only the fields sent change.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Update subcategory",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "subcategory id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Fields to change (at least one)",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/handlers.ERPCatalogoItem"
                        }
                    },
                    "400": {
                        "description": "validation error naming the field",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "delete": {
                "security": [
                    {
                        "ApiKeyAuth": []
                    }
                ],
                "description": "Soft delete. Fails with 409 while the subcategory is still used by active products.",
                "tags": [
                    "erp-catalog"
                ],
                "summary": "Delete subcategory",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "subcategory id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "204": {
                        "description": "deleted"
                    },
                    "400": {
                        "description": "invalid id",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "401": {
                        "description": "invalid API key",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "403": {
                        "description": "plan does not include ERP integrations (code PLAN_SIN_INTEGRACION_ERP)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "404": {
                        "description": "not found (or belongs to another store)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "409": {
                        "description": "subcategory is used by active products",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "500": {
                        "description": "internal error",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    },
                    "503": {
                        "description": "API key could not be validated, transient: retry (code SERVICE_UNAVAILABLE)",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "handlers.ERPAdjustStockRequest": {
            "type": "object",
            "properties": {
                "cantidad": {
                    "description": "Cantidad is required (nil = absent, so an omitted value never zeroes the stock).",
                    "type": "number"
                },
                "mode": {
                    "description": "\"set\" (default) | \"delta\"",
                    "type": "string"
                }
            }
        },
        "handlers.ERPAdjustStockResponse": {
            "type": "object",
            "properties": {
                "id_producto": {
                    "type": "integer"
                },
                "stock_ahora": {
                    "type": "number"
                },
                "stock_antes": {
                    "type": "number"
                }
            }
        },
        "handlers.ERPCancelBody": {
            "type": "object",
            "properties": {
                "notificar_cliente": {
                    "description": "NotificarCliente asks to WhatsApp the customer the cancellation (default false).",
                    "type": "boolean",
                    "example": false
                }
            }
        },
        "handlers.ERPCatalogoItem": {
            "type": "object",
            "properties": {
                "created_date": {
                    "type": "string"
                },
                "descripcion": {
                    "description": "marcas, categorias",
                    "type": "string"
                },
                "estado": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "id_categoria": {
                    "description": "sub_categorias only",
                    "type": "integer"
                },
                "nombre": {
                    "type": "string"
                },
                "updated_date": {
                    "type": "string"
                },
                "url_foto": {
                    "description": "marcas, categorias",
                    "type": "string"
                }
            }
        },
        "handlers.ERPCatalogoListResponse": {
            "type": "object",
            "properties": {
                "items": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/handlers.ERPCatalogoItem"
                    }
                },
                "limit": {
                    "type": "integer"
                },
                "next_cursor": {
                    "type": "integer"
                }
            }
        },
        "handlers.ERPCatalogoRequest": {
            "type": "object",
            "properties": {
                "descripcion": {
                    "description": "marcas, categorias",
                    "type": "string"
                },
                "estado": {
                    "description": "ACTIVO | INACTIVO",
                    "type": "string"
                },
                "id_categoria": {
                    "description": "sub_categorias (required on create)",
                    "type": "integer"
                },
                "nombre": {
                    "type": "string"
                },
                "url_foto": {
                    "description": "marcas, categorias",
                    "type": "string"
                }
            }
        },
        "handlers.ERPCreatePedidoRequest": {
            "type": "object",
            "properties": {
                "cliente_nombre": {
                    "description": "ClienteNombre / ClienteTelefono: optional customer contact for this order (max 120 / 32\nchars). Needed for `notificar_cliente` on later estado changes.",
                    "type": "string",
                    "example": "Ana Gómez"
                },
                "cliente_telefono": {
                    "type": "string",
                    "example": "+595981123456"
                },
                "direccion_delivery": {
                    "type": "string"
                },
                "estado": {
                    "type": "string"
                },
                "id_medio_entrega": {
                    "type": "integer"
                },
                "id_medio_pago": {
                    "type": "integer"
                },
                "items": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/handlers.ERPItemPedido"
                    }
                },
                "obs": {
                    "type": "string"
                }
            }
        },
        "handlers.ERPCreatePedidoResponse": {
            "type": "object",
            "properties": {
                "created_date": {
                    "type": "string"
                },
                "estado": {
                    "type": "string"
                },
                "id_pedido": {
                    "type": "integer"
                },
                "total": {
                    "type": "number"
                }
            }
        },
        "handlers.ERPItemPedido": {
            "type": "object",
            "properties": {
                "cantidad": {
                    "type": "number"
                },
                "id_producto": {
                    "type": "integer"
                },
                "id_variante": {
                    "type": "integer"
                },
                "precio_total": {
                    "type": "number"
                },
                "precio_unit": {
                    "type": "number"
                }
            }
        },
        "handlers.ERPItemResponse": {
            "type": "object",
            "properties": {
                "cantidad": {
                    "type": "number"
                },
                "descuento": {
                    "type": "number"
                },
                "id_pedido_item": {
                    "type": "integer"
                },
                "id_producto": {
                    "type": "integer"
                },
                "id_variante": {
                    "description": "IDVariante is null for a line without variant.",
                    "type": "integer",
                    "x-nullable": true
                },
                "nombre_producto": {
                    "type": "string"
                },
                "precio_total": {
                    "type": "number"
                },
                "precio_unit": {
                    "type": "number"
                }
            }
        },
        "handlers.ERPListPedidosResponse": {
            "type": "object",
            "properties": {
                "limit": {
                    "type": "integer"
                },
                "next_cursor": {
                    "type": "integer",
                    "x-nullable": true
                },
                "pedidos": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/handlers.ERPPedidoSummary"
                    }
                }
            }
        },
        "handlers.ERPListProductosResponse": {
            "type": "object",
            "properties": {
                "limit": {
                    "type": "integer"
                },
                "next_cursor": {
                    "type": "integer"
                },
                "productos": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/handlers.ERPProducto"
                    }
                }
            }
        },
        "handlers.ERPPedidoCliente": {
            "type": "object",
            "properties": {
                "codigo_erp": {
                    "type": "string",
                    "x-nullable": true
                },
                "id_cliente": {
                    "type": "integer",
                    "x-nullable": true
                },
                "nombre": {
                    "type": "string"
                },
                "telefono": {
                    "type": "string"
                }
            }
        },
        "handlers.ERPPedidoDetail": {
            "type": "object",
            "properties": {
                "cliente": {
                    "allOf": [
                        {
                            "$ref": "#/definitions/handlers.ERPPedidoCliente"
                        }
                    ],
                    "x-nullable": true
                },
                "cliente_lat": {
                    "type": "number",
                    "x-nullable": true
                },
                "cliente_lng": {
                    "type": "number",
                    "x-nullable": true
                },
                "costo_envio": {
                    "type": "number",
                    "x-nullable": true
                },
                "created_date": {
                    "type": "string"
                },
                "cupon_codigo": {
                    "description": "CuponCodigo, IDListaPrecios and the shipping fields are null when the order has none.",
                    "type": "string",
                    "x-nullable": true
                },
                "cupon_descuento": {
                    "type": "number"
                },
                "direccion_delivery": {
                    "type": "string"
                },
                "distancia_km": {
                    "type": "number",
                    "x-nullable": true
                },
                "estado": {
                    "type": "string"
                },
                "id_lista_precios": {
                    "type": "integer",
                    "x-nullable": true
                },
                "id_medio_entrega": {
                    "type": "integer"
                },
                "id_medio_pago": {
                    "type": "integer"
                },
                "id_pedido": {
                    "type": "integer"
                },
                "items": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/handlers.ERPItemResponse"
                    }
                },
                "notas_internas": {
                    "type": "string"
                },
                "numero_seguimiento": {
                    "type": "string"
                },
                "obs": {
                    "type": "string"
                },
                "total": {
                    "type": "number"
                },
                "url_seguimiento": {
                    "type": "string"
                },
                "vendedor": {
                    "allOf": [
                        {
                            "$ref": "#/definitions/handlers.ERPPedidoVendedor"
                        }
                    ],
                    "x-nullable": true
                }
            }
        },
        "handlers.ERPPedidoPatch": {
            "type": "object",
            "properties": {
                "estado": {
                    "type": "string",
                    "example": "ENVIADO"
                },
                "notas_internas": {
                    "type": "string"
                },
                "notificar_cliente": {
                    "description": "NotificarCliente asks to send the panel's estado WhatsApp to the customer (default false).\nOnly sent when the estado really changed; never fails the update.",
                    "type": "boolean",
                    "example": false
                },
                "numero_seguimiento": {
                    "type": "string"
                },
                "url_seguimiento": {
                    "type": "string",
                    "example": "https://carrier.example/track/123"
                }
            }
        },
        "handlers.ERPPedidoPatchResponse": {
            "type": "object",
            "properties": {
                "cliente": {
                    "allOf": [
                        {
                            "$ref": "#/definitions/handlers.ERPPedidoCliente"
                        }
                    ],
                    "x-nullable": true
                },
                "cliente_lat": {
                    "type": "number",
                    "x-nullable": true
                },
                "cliente_lng": {
                    "type": "number",
                    "x-nullable": true
                },
                "cliente_notificado": {
                    "type": "boolean"
                },
                "costo_envio": {
                    "type": "number",
                    "x-nullable": true
                },
                "created_date": {
                    "type": "string"
                },
                "cupon_codigo": {
                    "description": "CuponCodigo, IDListaPrecios and the shipping fields are null when the order has none.",
                    "type": "string",
                    "x-nullable": true
                },
                "cupon_descuento": {
                    "type": "number"
                },
                "direccion_delivery": {
                    "type": "string"
                },
                "distancia_km": {
                    "type": "number",
                    "x-nullable": true
                },
                "estado": {
                    "type": "string"
                },
                "id_lista_precios": {
                    "type": "integer",
                    "x-nullable": true
                },
                "id_medio_entrega": {
                    "type": "integer"
                },
                "id_medio_pago": {
                    "type": "integer"
                },
                "id_pedido": {
                    "type": "integer"
                },
                "items": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/handlers.ERPItemResponse"
                    }
                },
                "motivo": {
                    "description": "Motivo explains cliente_notificado=false: whatsapp_inactivo (no WhatsApp connected), sin_contacto_cliente (no customer phone),\ntimeout_envio (provider too slow; it may still deliver), sin_cambio_de_estado, pedido_no_encontrado or error_envio.",
                    "type": "string"
                },
                "notas_internas": {
                    "type": "string"
                },
                "numero_seguimiento": {
                    "type": "string"
                },
                "obs": {
                    "type": "string"
                },
                "total": {
                    "type": "number"
                },
                "url_seguimiento": {
                    "type": "string"
                },
                "vendedor": {
                    "allOf": [
                        {
                            "$ref": "#/definitions/handlers.ERPPedidoVendedor"
                        }
                    ],
                    "x-nullable": true
                }
            }
        },
        "handlers.ERPPedidoSummary": {
            "type": "object",
            "properties": {
                "cant_items": {
                    "type": "integer"
                },
                "cliente": {
                    "description": "Cliente / Vendedor: null when the order has none (see ERPPedidoCliente).",
                    "allOf": [
                        {
                            "$ref": "#/definitions/handlers.ERPPedidoCliente"
                        }
                    ],
                    "x-nullable": true
                },
                "created_date": {
                    "type": "string"
                },
                "estado": {
                    "type": "string"
                },
                "id_pedido": {
                    "type": "integer"
                },
                "obs": {
                    "type": "string"
                },
                "total": {
                    "type": "number"
                },
                "vendedor": {
                    "allOf": [
                        {
                            "$ref": "#/definitions/handlers.ERPPedidoVendedor"
                        }
                    ],
                    "x-nullable": true
                }
            }
        },
        "handlers.ERPPedidoVendedor": {
            "type": "object",
            "properties": {
                "codigo_erp": {
                    "type": "string",
                    "x-nullable": true
                },
                "id_tienda_usuario": {
                    "type": "integer"
                },
                "nombre": {
                    "type": "string"
                }
            }
        },
        "handlers.ERPProducto": {
            "type": "object",
            "properties": {
                "codigo": {
                    "type": "string"
                },
                "codigo_barras": {
                    "type": "string"
                },
                "controlar_stock": {
                    "type": "boolean"
                },
                "costo": {
                    "type": "number"
                },
                "created_date": {
                    "type": "string"
                },
                "descripcion": {
                    "type": "string"
                },
                "en_promocion": {
                    "type": "boolean"
                },
                "es_destacado": {
                    "type": "boolean"
                },
                "es_nuevo": {
                    "type": "boolean"
                },
                "estado": {
                    "type": "string"
                },
                "etiquetas": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "id_marca": {
                    "type": "integer"
                },
                "id_producto": {
                    "type": "integer"
                },
                "id_sub_categoria": {
                    "type": "integer"
                },
                "nombre": {
                    "type": "string"
                },
                "obs": {
                    "type": "string"
                },
                "precio": {
                    "type": "number"
                },
                "precio_promo": {
                    "type": "number"
                },
                "requiere_envio": {
                    "type": "boolean"
                },
                "slug": {
                    "type": "string"
                },
                "solo_consulta": {
                    "type": "boolean"
                },
                "stock": {
                    "type": "number"
                },
                "stock_minimo": {
                    "type": "integer"
                },
                "tiene_variantes": {
                    "type": "boolean"
                },
                "updated_date": {
                    "type": "string"
                },
                "url_foto": {
                    "type": "string"
                }
            }
        },
        "handlers.ERPProductoRequest": {
            "type": "object",
            "properties": {
                "codigo": {
                    "type": "string"
                },
                "codigo_barras": {
                    "type": "string"
                },
                "controlar_stock": {
                    "type": "boolean"
                },
                "costo": {
                    "type": "number"
                },
                "descripcion": {
                    "type": "string"
                },
                "en_promocion": {
                    "type": "boolean"
                },
                "es_destacado": {
                    "type": "boolean"
                },
                "es_nuevo": {
                    "type": "boolean"
                },
                "estado": {
                    "type": "string",
                    "enum": [
                        "ACTIVO",
                        "INACTIVO",
                        "AGOTADO"
                    ]
                },
                "etiquetas": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "id_marca": {
                    "type": "integer"
                },
                "id_sub_categoria": {
                    "type": "integer"
                },
                "nombre": {
                    "type": "string"
                },
                "obs": {
                    "type": "string"
                },
                "precio": {
                    "type": "number"
                },
                "precio_promo": {
                    "type": "number"
                },
                "requiere_envio": {
                    "type": "boolean"
                },
                "slug": {
                    "type": "string"
                },
                "solo_consulta": {
                    "type": "boolean"
                },
                "stock": {
                    "type": "number"
                },
                "stock_minimo": {
                    "type": "integer"
                },
                "url_foto": {
                    "type": "string"
                }
            }
        }
    },
    "securityDefinitions": {
        "ApiKeyAuth": {
            "description": "Bearer token issued from the VirCat vendor panel. Format: `Bearer \u003ctoken\u003e`",
            "type": "apiKey",
            "name": "Authorization",
            "in": "header"
        }
    }
}