{
  "openapi": "3.1.0",
  "info": {
    "title": "Envíos Digitales API",
    "version": "1.1.0",
    "description": "API de Envíos Digitales para tu tienda de Tiendanube (Nuvemshop). Cada clave pertenece a una tienda y tiene permisos fijos (links, read, write, buyers, send). Los mismos servicios están disponibles por MCP en https://enviosdigitalesnube.com/api/mcp. Requiere un plan pago. Guía: https://enviosdigitalesnube.com/docs/products/api (pt-BR: https://enviosdigitalesnube.com/docs-pt/products/api-pt)."
  },
  "externalDocs": {
    "description": "Guía de la API y MCP (pt-BR: https://enviosdigitalesnube.com/docs-pt/products/api-pt)",
    "url": "https://enviosdigitalesnube.com/docs/products/api"
  },
  "servers": [
    {
      "url": "https://enviosdigitalesnube.com/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Links"
    },
    {
      "name": "Archivos"
    },
    {
      "name": "Keys de licencia"
    },
    {
      "name": "Pedidos"
    },
    {
      "name": "Acciones: reenviar y liberar pedidos"
    },
    {
      "name": "Email de entrega"
    },
    {
      "name": "Contactos"
    },
    {
      "name": "Cuenta"
    }
  ],
  "paths": {
    "/products": {
      "get": {
        "operationId": "list_products_with_links",
        "summary": "Listar productos con sus links",
        "description": "Productos y variantes de tu tienda, cada variante con sus links. Seguí pidiendo páginas mientras has_more sea true.",
        "tags": [
          "Links"
        ],
        "x-area": null,
        "x-required-scope": "read",
        "x-mcp-tool": "list_products_with_links",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–100, por defecto 50"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "id": 123,
                      "product_name": "Curso",
                      "variants": [
                        {
                          "id": 456,
                          "variant_name": "PDF",
                          "links": []
                        }
                      ]
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 50,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/products/{productId}": {
      "get": {
        "operationId": "get_products_productId",
        "summary": "Ver un producto con sus links",
        "description": "El mismo formato para un producto. 404 si no es de tu tienda.",
        "tags": [
          "Links"
        ],
        "x-area": null,
        "x-required-scope": "read",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": "{ \"data\": { \"id\": 123, \"product_name\": \"Curso\", \"variants\": [ ... ] } }"
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/links": {
      "post": {
        "operationId": "upsert_link",
        "summary": "Crear o actualizar un link",
        "description": "Si la variante ya tiene esa URL, actualiza el título en vez de duplicarla.",
        "tags": [
          "Links"
        ],
        "x-area": null,
        "x-required-scope": "write",
        "x-mcp-tool": "upsert_link",
        "responses": {
          "201": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "id": 43,
                    "variant_id": "456",
                    "title": "Módulo 1",
                    "link": "https://drive.google.com/..."
                  },
                  "result": "created"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 1 MB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "variant_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "link": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "product_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  }
                },
                "required": [
                  "variant_id",
                  "link"
                ]
              }
            }
          }
        }
      }
    },
    "/links/bulk": {
      "post": {
        "operationId": "bulk_upsert_links",
        "summary": "Links en lote",
        "description": "Hasta 500 filas con las reglas del importador CSV (6 por minuto por clave).",
        "tags": [
          "Links"
        ],
        "x-area": null,
        "x-required-scope": "write",
        "x-mcp-tool": "bulk_upsert_links",
        "responses": {
          "201": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "success": true,
                  "results": {
                    "created": 1,
                    "updated": 0,
                    "deleted": 0,
                    "unchanged": 0,
                    "errors": []
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 1 MB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "array",
                    "items": {},
                    "description": "hasta 500 filas"
                  }
                },
                "required": [
                  "rows"
                ]
              }
            }
          }
        }
      }
    },
    "/links/{id}": {
      "delete": {
        "operationId": "delete_link",
        "summary": "Eliminar un link",
        "description": "Por id. 404 si no existe o no es de tu tienda.",
        "tags": [
          "Links"
        ],
        "x-area": null,
        "x-required-scope": "write",
        "x-mcp-tool": "delete_link",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "id": 43
                  },
                  "result": "deleted"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/files": {
      "get": {
        "operationId": "list_files",
        "summary": "Listar productos con sus archivos",
        "description": "Productos y variantes con nombre, tamaño y fecha de cada archivo. per_page de 1 a 20 (10 por defecto). Si una página tiene muchas variantes, las que no se pudieron listar vienen con files: null y files_truncated: true.",
        "tags": [
          "Archivos"
        ],
        "x-area": "files",
        "x-required-scope": "read",
        "x-mcp-tool": "list_files",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–20"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "id": 123,
                      "product_name": "Curso",
                      "variants": [
                        {
                          "id": 456,
                          "variant_name": "PDF",
                          "files": [
                            {
                              "name": "modulo-1.pdf",
                              "size": 1048576,
                              "updated_at": "2026-12-01T12:00:00.000Z"
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 10,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_file",
        "summary": "Borrar un archivo",
        "description": "Por producto, variante y nombre. 404 si no existe en tu tienda.",
        "tags": [
          "Archivos"
        ],
        "x-area": "files",
        "x-required-scope": "write",
        "x-mcp-tool": "delete_file",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          },
          {
            "name": "variant_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          },
          {
            "name": "file_name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "product_id": "123",
                    "variant_id": "456",
                    "name": "modulo-1.pdf"
                  },
                  "result": "deleted"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/files/uploads": {
      "post": {
        "operationId": "create_file_upload",
        "summary": "Subir un archivo",
        "description": "Hasta 8 MB devuelve una URL para un PUT con el Content-Length firmado. Más grande, una subida multiparte con partes de 8 MiB y las primeras 100 URLs de partes; cada URL firma el Content-Length exacto de su parte (8 MiB, la última el resto). Máximo 80 GB por archivo (413 file_too_large). Un archivo con el mismo nombre se reemplaza.",
        "tags": [
          "Archivos"
        ],
        "x-area": "files",
        "x-required-scope": "write",
        "x-mcp-tool": "create_file_upload",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "type": "single",
                    "file": {
                      "product_id": "123",
                      "variant_id": "456",
                      "name": "modulo-1.pdf"
                    },
                    "size": 1048576,
                    "upload": {
                      "method": "PUT",
                      "url": "https://…",
                      "headers": {
                        "Content-Type": "application/pdf",
                        "Content-Length": "1048576"
                      },
                      "expires_in": 3600
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 64 KB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "variant_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "file_name": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "bytes"
                  },
                  "content_type": {
                    "type": "string"
                  }
                },
                "required": [
                  "product_id",
                  "variant_id",
                  "file_name",
                  "size"
                ]
              }
            }
          }
        }
      }
    },
    "/files/uploads/parts": {
      "post": {
        "operationId": "get_file_upload_parts",
        "summary": "Más URLs de partes",
        "description": "Para subidas multiparte: hasta 100 números de parte por llamada. size es el tamaño del archivo (el mismo de la subida); cada URL firma el Content-Length de su parte.",
        "tags": [
          "Archivos"
        ],
        "x-area": "files",
        "x-required-scope": "write",
        "x-mcp-tool": "get_file_upload_parts",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "upload_id": "…",
                    "parts": [
                      {
                        "part_number": 101,
                        "size": 8388608,
                        "url": "https://…",
                        "headers": {
                          "Content-Length": "8388608"
                        }
                      }
                    ],
                    "parts_expires_in": 14400
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 64 KB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "variant_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "file_name": {
                    "type": "string"
                  },
                  "upload_id": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "bytes"
                  },
                  "part_numbers": {
                    "type": "array",
                    "items": {}
                  }
                },
                "required": [
                  "product_id",
                  "variant_id",
                  "file_name",
                  "upload_id",
                  "size",
                  "part_numbers"
                ]
              }
            }
          }
        }
      }
    },
    "/files/uploads/complete": {
      "post": {
        "operationId": "complete_file_upload",
        "summary": "Completar una subida multiparte",
        "description": "Con el ETag de cada parte. Si el archivo final supera 80 GB se borra y responde 413. Cuerpo de hasta 1 MB.",
        "tags": [
          "Archivos"
        ],
        "x-area": "files",
        "x-required-scope": "write",
        "x-mcp-tool": "complete_file_upload",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "file": {
                      "product_id": "123",
                      "variant_id": "456",
                      "name": "curso.zip",
                      "size": 52428800
                    }
                  },
                  "result": "completed"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 1 MB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "variant_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "file_name": {
                    "type": "string"
                  },
                  "upload_id": {
                    "type": "string"
                  },
                  "parts": {
                    "type": "array",
                    "items": {},
                    "description": "[{ part_number, etag }]"
                  }
                },
                "required": [
                  "product_id",
                  "variant_id",
                  "file_name",
                  "upload_id",
                  "parts"
                ]
              }
            }
          }
        }
      }
    },
    "/files/uploads/abort": {
      "post": {
        "operationId": "abort_file_upload",
        "summary": "Cancelar una subida multiparte",
        "description": "Descarta las partes subidas.",
        "tags": [
          "Archivos"
        ],
        "x-area": "files",
        "x-required-scope": "write",
        "x-mcp-tool": "abort_file_upload",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "result": "aborted"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 64 KB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "variant_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "file_name": {
                    "type": "string"
                  },
                  "upload_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "product_id",
                  "variant_id",
                  "file_name",
                  "upload_id"
                ]
              }
            }
          }
        }
      }
    },
    "/license-keys/summary": {
      "get": {
        "operationId": "license_keys_summary",
        "summary": "Resumen de keys por variante",
        "description": "Keys sin usar, usadas y total por producto y variante. 6 por minuto por clave, junto con exportar contactos.",
        "tags": [
          "Keys de licencia"
        ],
        "x-area": "license_keys",
        "x-required-scope": "read",
        "x-mcp-tool": "license_keys_summary",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–100"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "product_id": "123",
                      "variant_id": "456",
                      "unused": 40,
                      "used": 10,
                      "total": 50
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 50,
                    "has_more": false,
                    "total": 1
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/license-keys": {
      "get": {
        "operationId": "list_license_keys",
        "summary": "Listar keys",
        "description": "El valor de la key solo vuelve con write (value / fields); con read vuelve enmascarado (value_masked). Con buyers, las keys usadas traen buyer_email y buyer_name.",
        "tags": [
          "Keys de licencia"
        ],
        "x-area": "license_keys",
        "x-required-scope": "read",
        "x-mcp-tool": "list_license_keys",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          },
          {
            "name": "variant_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "all | unused | used"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–100"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "id": 9,
                      "product_id": "123",
                      "variant_id": "456",
                      "status": "unused",
                      "order_id": null,
                      "created_at": "2026-12-01T12:00:00.000Z",
                      "value_masked": "••••7F2K"
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 50,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "add_license_keys",
        "summary": "Agregar keys",
        "description": "Hasta 1000 keys por solicitud (cuerpo de hasta 1 MB): texto, o { fields } para keys con varios campos. Las repetidas se saltean. Después actualiza el stock de la variante en Tiendanube.",
        "tags": [
          "Keys de licencia"
        ],
        "x-area": "license_keys",
        "x-required-scope": "write",
        "x-mcp-tool": "add_license_keys",
        "responses": {
          "201": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "added": 2,
                    "duplicates": 0,
                    "unused": 42
                  },
                  "result": "created"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 1 MB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "variant_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  },
                  "keys": {
                    "type": "array",
                    "items": {},
                    "description": "string | { fields }"
                  }
                },
                "required": [
                  "product_id",
                  "variant_id",
                  "keys"
                ]
              }
            }
          }
        }
      }
    },
    "/license-keys/delete": {
      "post": {
        "operationId": "delete_license_keys",
        "summary": "Borrar keys sin usar",
        "description": "Hasta 100 ids. Las keys usadas no se borran (not_deleted).",
        "tags": [
          "Keys de licencia"
        ],
        "x-area": "license_keys",
        "x-required-scope": "write",
        "x-mcp-tool": "delete_license_keys",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "deleted": 2,
                    "not_deleted": 0
                  },
                  "result": "deleted"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 64 KB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {}
                  }
                },
                "required": [
                  "ids"
                ]
              }
            }
          }
        }
      }
    },
    "/orders": {
      "get": {
        "operationId": "list_orders",
        "summary": "Listar pedidos",
        "description": "Pedidos pagos, más nuevos primero, con status (sent, held, sending, processing, skipped, not_sent) y hold (missing_files, no_credits, idle_plan). buyer solo con buyers.",
        "tags": [
          "Pedidos"
        ],
        "x-area": "orders",
        "x-required-scope": "read",
        "x-mcp-tool": "list_orders",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "sent | held | held_missing_files | held_no_credits | held_idle_plan"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "ISO 8601"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "ISO 8601"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–100"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "id": "1690000001",
                      "number": 1234,
                      "created_at": "2026-12-01T12:00:00.000Z",
                      "status": "held",
                      "hold": "missing_files",
                      "reason": "missing_files",
                      "total": "15000.00",
                      "currency": "ARS",
                      "products": [
                        {
                          "product_id": "123",
                          "variant_id": "456",
                          "name": "Curso",
                          "quantity": 1
                        }
                      ],
                      "delivery": null
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 50,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "operationId": "get_order",
        "summary": "Ver un pedido",
        "description": "El mismo formato para un pedido (también pedidos manuales, con id negativo).",
        "tags": [
          "Pedidos"
        ],
        "x-area": "orders",
        "x-required-scope": "read",
        "x-mcp-tool": "get_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "id": "1690000001",
                    "status": "sent",
                    "delivery": {
                      "id": 77,
                      "sent": true,
                      "email_status": "delivered"
                    },
                    "buyer": {
                      "email": "…",
                      "name": "…"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/resend": {
      "post": {
        "operationId": "resend_order_email",
        "summary": "Reenviar la descarga",
        "description": "Solo pedidos que ya se enviaron, hasta 3 veces por día cada uno. sent es true solo si el email salió; si no, reason dice por qué (no_credits, idle_plan, duplicate, missing_files…). Usa 1 envío.",
        "tags": [
          "Acciones: reenviar y liberar pedidos"
        ],
        "x-area": "actions",
        "x-required-scope": "send",
        "x-mcp-tool": "resend_order_email",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "order_id": "1690000001",
                    "sent": false,
                    "reason": "no_credits",
                    "message": "…"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/held": {
      "get": {
        "operationId": "list_held_orders_to_release",
        "summary": "Pedidos en espera para liberar",
        "description": "Los pedidos retenidos por archivos faltantes que ya se pueden enviar, igual que la tarjeta del panel. confirmation.text es el texto exacto que acepta el comercio al liberarlos todos. Solo lectura: no gasta presupuesto.",
        "tags": [
          "Acciones: reenviar y liberar pedidos"
        ],
        "x-area": "actions",
        "x-required-scope": "send",
        "x-mcp-tool": "list_held_orders_to_release",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "order_id": "1690000001",
                      "order_number": 1234,
                      "product_name": "Curso",
                      "created_at": "2026-12-01T12:00:00.000Z"
                    }
                  ],
                  "no_content_count": 0,
                  "credits": 12,
                  "unlimited": false,
                  "confirmation": {
                    "text": "…",
                    "text_version": "held-release-confirm-v1",
                    "locale": "es",
                    "requires": "accept: true"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/held/release": {
      "post": {
        "operationId": "release_held_orders",
        "summary": "Liberar pedidos en espera",
        "description": "Hasta 50 order_ids por llamada, los más viejos primero y como máximo los envíos que te quedan. Para seguir, repetí con los ids de still_processing y el mismo confirmation_id. Cada email usa 1 envío. Quien tiene la clave confirma en nombre del comercio: mostrá antes confirmation.text de GET /orders/held y mandá accept: true (sin eso responde 400 confirmation_required). Queda registrado con el texto, la IP y la clave usada.",
        "tags": [
          "Acciones: reenviar y liberar pedidos"
        ],
        "x-area": "actions",
        "x-required-scope": "send",
        "x-mcp-tool": "release_held_orders",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "confirmation_id": "…",
                    "outcomes": {
                      "sent": [
                        "1690000001"
                      ],
                      "still_processing": []
                    },
                    "counts": {
                      "sent": 1
                    },
                    "retryable": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 64 KB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "order_ids": {
                    "type": "array",
                    "items": {},
                    "description": "1–50"
                  },
                  "accept": {
                    "type": "boolean",
                    "description": "true"
                  },
                  "confirmation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "order_ids",
                  "accept"
                ]
              }
            }
          }
        }
      }
    },
    "/email-template": {
      "get": {
        "operationId": "get_email_template",
        "summary": "Ver el email de entrega",
        "description": "La plantilla de tu tienda (is_default: true si todavía usás la de Envíos Digitales).",
        "tags": [
          "Email de entrega"
        ],
        "x-area": "email",
        "x-required-scope": "read",
        "x-mcp-tool": "get_email_template",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "name": "…",
                    "subject": "Tu compra",
                    "content": "<p>Hola {{nombre}}</p>",
                    "link_label": "Descargar",
                    "key_label": "Tu key",
                    "hide_download_link_for_keys_only": false,
                    "is_default": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "update_email_template",
        "summary": "Editar el email de entrega",
        "description": "Solo cambian los campos que mandás. content hasta 60.000 caracteres. El HTML se guarda limpio: se sacan scripts, eventos on*=, links javascript:, iframes, formularios, SVG y bloques <style> (la respuesta trae lo guardado). link_label y key_label son texto: con < o > responden 400 unsafe_html.",
        "tags": [
          "Email de entrega"
        ],
        "x-area": "email",
        "x-required-scope": "write",
        "x-mcp-tool": "update_email_template",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "subject": "Tu compra",
                    "content": "…",
                    "is_default": false
                  },
                  "result": "updated"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 64 KB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subject": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "link_label": {
                    "type": "string"
                  },
                  "key_label": {
                    "type": "string"
                  },
                  "hide_download_link_for_keys_only": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/email-template/products": {
      "get": {
        "operationId": "list_product_email_texts",
        "summary": "Textos por producto",
        "description": "Los textos que se insertan en {{productos}}, por producto y variante (variant_id null = todas).",
        "tags": [
          "Email de entrega"
        ],
        "x-area": "email",
        "x-required-scope": "read",
        "x-mcp-tool": "list_product_email_texts",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–100"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "id": 5,
                      "product_id": "123",
                      "variant_id": null,
                      "html": "<p>Gracias</p>",
                      "updated_at": "2026-12-01T12:00:00.000Z"
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 50,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/email-template/products/{productId}": {
      "put": {
        "operationId": "set_product_email_text",
        "summary": "Guardar el texto de un producto",
        "description": "html hasta 20.000 caracteres; se limpia igual que al enviar el email.",
        "tags": [
          "Email de entrega"
        ],
        "x-area": "email",
        "x-required-scope": "write",
        "x-mcp-tool": "set_product_email_text",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "id": 5,
                    "product_id": "123",
                    "variant_id": null,
                    "html": "<p>Gracias</p>"
                  },
                  "result": "created"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large (o file_too_large / too_many_rows)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "description": "JSON, hasta 64 KB.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "html": {
                    "type": "string"
                  },
                  "variant_id": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Id numérico"
                  }
                },
                "required": [
                  "html"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_product_email_text",
        "summary": "Borrar el texto de un producto",
        "description": "404 si no había texto.",
        "tags": [
          "Email de entrega"
        ],
        "x-area": "email",
        "x-required-scope": "write",
        "x-mcp-tool": "delete_product_email_text",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "variant_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "integer"
              ],
              "description": "Id numérico"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "result": "deleted"
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/offers": {
      "get": {
        "operationId": "list_contact_offers",
        "summary": "Listar ofertas de Contactos",
        "description": "Tus páginas para conseguir contactos a cambio de un producto gratis.",
        "tags": [
          "Contactos"
        ],
        "x-area": "contacts",
        "x-required-scope": "read",
        "x-mcp-tool": "list_contact_offers",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–100"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "id": "uuid",
                      "slug": "guia",
                      "name": "Guía gratis",
                      "product_id": "123",
                      "active": true,
                      "public_path": "/g/123456/guia"
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 50,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/contacts": {
      "get": {
        "operationId": "list_contacts",
        "summary": "Listar contactos",
        "description": "Más nuevos primero. email y name solo con buyers.",
        "tags": [
          "Contactos"
        ],
        "x-area": "contacts",
        "x-required-scope": "read",
        "x-mcp-tool": "list_contacts",
        "parameters": [
          {
            "name": "offer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–100"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": [
                    {
                      "id": "uuid",
                      "offer_id": "uuid",
                      "offer_name": "Guía gratis",
                      "source": "landing",
                      "consent_at": "2026-12-01T12:00:00.000Z",
                      "created_at": "2026-12-01T12:00:00.000Z"
                    }
                  ],
                  "pagination": {
                    "page": 1,
                    "per_page": 50,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/export": {
      "get": {
        "operationId": "export_contacts",
        "summary": "Exportar contactos (CSV)",
        "description": "Hasta 5000 filas, más nuevas primero (X-Truncated: true si hay más). Por MCP devuelve filas JSON, hasta 1000. 6 por minuto por clave, junto con el resumen de keys.",
        "tags": [
          "Contactos"
        ],
        "x-area": "contacts",
        "x-required-scope": "buyers",
        "x-mcp-tool": "export_contacts",
        "parameters": [
          {
            "name": "offer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "uuid"
            }
          },
          {
            "name": "max_rows",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "1–5000"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                },
                "example": "email,name,offer,consent_at,source,created_at\ncomprador@example.com,Ana,Guía gratis,2026-12-01T12:00:00.000Z,landing,2026-12-01T12:00:00.000Z"
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/account": {
      "get": {
        "operationId": "get_account",
        "summary": "Plan y envíos",
        "description": "Tu plan y los envíos usados y restantes del período (null en planes ilimitados; remaining puede ser negativo si te pasaste).",
        "tags": [
          "Cuenta"
        ],
        "x-area": "account",
        "x-required-scope": "read",
        "x-mcp-tool": "get_account",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "data": {
                    "store_id": "123456",
                    "plan": {
                      "name": "Starter",
                      "interval": "month",
                      "status": "active",
                      "renews_at": "2026-12-31T00:00:00.000Z",
                      "ends_at": null
                    },
                    "envios": {
                      "unlimited": false,
                      "included": 100,
                      "used": 40,
                      "remaining": 60,
                      "period_started_at": "2026-12-01T00:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Solicitud inválida (validation, invalid_json…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave, es inválida o fue revocada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "plan_required o insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe en tu tienda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited / daily_limit",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos a esperar"
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Clave de API (edk_…) de Configuración → API."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Mensaje en español"
          },
          "code": {
            "type": "string",
            "enum": [
              "validation",
              "invalid_json",
              "confirmation_required",
              "unsafe_html",
              "upload_incomplete",
              "missing_key",
              "invalid_key",
              "revoked_key",
              "plan_required",
              "insufficient_scope",
              "not_found",
              "release_not_enabled",
              "no_credits",
              "body_too_large",
              "file_too_large",
              "too_many_rows",
              "rate_limited",
              "daily_limit",
              "order_resend_limit",
              "internal",
              "upstream_error",
              "store_not_connected",
              "unavailable"
            ]
          },
          "required_scope": {
            "type": "string",
            "description": "Con insufficient_scope: el permiso que falta"
          },
          "retry_after": {
            "type": "integer"
          },
          "max_bytes": {
            "type": "integer"
          }
        }
      }
    }
  }
}
