{
  "openapi": "3.0.0",
  "info": {
    "version": "2.0.0",
    "title": "AIR-Core API",
    "description": "REST API of AIR-Core (version 2), the data and artificial intelligence platform of AIR Institute.\n\n**What changed from API v1.** The same operations under `/api/v2/`, with the same tokens, permissions, limits and errors, except the alerts: they are now part of the **automations** (`/api/v2/workspace/{workspaceId}/automations`), which list, create, change, delete, test and read the history of the simple notices and the flows of a workspace together. In API v1, which is deprecated and keeps working, the operations of the alerts answer 410 Gone with the code `ALERTS_REMOVED`, the operation that replaces each one (`replacement`) and a link to this documentation. The MCP tools changed the same way: `list_automations`, `create_automation` and `get_automation_history`.\n\n**Authentication.** Create an authorization token in the *Account* section (*API and AI applications*) and send it in the `x-auth-token` header. The token is shown only once, when it is created: AIR-Core keeps only its hash, and the lists show its name, dates and last 4 characters. Resetting the password revokes every token, and changing it can revoke them too. Endpoints that act on workspaces also take the organization in the `x-organization` header.\n\n**Asynchronous work.** Uploading data and training models start a task: the response carries its `task_id`, and `GET /api/v2/workspace/{workspaceId}/task/{taskId}` reports its status and result.\n\n**Automations.** A simple notice warns the notice list of the workspace (and a chat or a system through a webhook) when new rows of a source meet a condition, or when a source gets no data for some hours. A flow can also predict with a model, retrain it, write rows to another source and act on a schedule. When an automation is created, AIR-Core saves it as a simple notice when it is exactly one and as a flow otherwise, and says which and why.\n\n**Explainability and model cards.** `models/{modelId}/explanation`, `explanation/prediction` and `card` return SHAP explanations and a model card when the explainability module is enabled; `explanation/rules`, `explanation/prototypes`, `explanation/counterfactuals`, `explanation/compare`, `explanation/effects` and `explanation/fairness` return the rules of a model, representative cases, what would have to change for another prediction, where two models disagree, the effect of each input and a bias audit by a sensitive field.\n\n**Assistants and agents.** The same operations are exposed to AI assistants through the MCP server of the deployment (Streamable HTTP at `/mcp`, OAuth 2.1), with the permissions of the user who connects it. An OAuth authorization granted for the directory tool set (`/mcp/directory`, which cannot edit or delete data) is bound to it: the API answers its tokens only the operations of those tools, and 403 with the code `DIRECTORY_SCOPE` to the rest.\n\n**Limits.** A deployment may limit the requests per second of each address; the API answers 429 when the limit is exceeded.",
    "contact": {
      "name": "AIR Institute",
      "url": "https://air-core.io",
      "email": "info@air-institute.com"
    }
  },
  "servers": [
    {
      "url": "https://app.air-core.io/"
    },
    {
      "url": "https://localhost/"
    },
    {
      "url": "http://localhost/"
    }
  ],
  "tags": [
    {
      "name": "authentication",
      "description": "Authentication API (OAuth 2.0)"
    },
    {
      "name": "account",
      "description": "Account API. Profile and personal information."
    },
    {
      "name": "workspaces",
      "description": "Workspaces API. Workspaces allow you to group your resources (sources, models, visualizations, dashboards) and manage their permissions."
    },
    {
      "name": "tasks",
      "description": "Tasks API. Tasks are asynchronous and are created when you request AIR-Core a batch task. For example uploading a data source or training a model."
    },
    {
      "name": "sources",
      "description": "Sources API. Sources allow you to store your data."
    },
    {
      "name": "metrics",
      "description": "Metrics API. The metric dictionary of a workspace (each metric defined once), their values with why they changed, unusual values, targets, automations and the briefing of the metrics each person follows."
    },
    {
      "name": "models",
      "description": "Models API. Models allow you to use artificial intelligence algorithms to analyze your data and extract knowledge from it."
    },
    {
      "name": "automations",
      "description": "Automations: the simple notices and the flows of a workspace in one list. A new automation is saved as a simple notice (`kind: notice`) when it is exactly one, and as a flow (`kind: flow`) otherwise; editing never changes its kind."
    },
    {
      "name": "emails",
      "description": "API to manage email notifications"
    },
    {
      "name": "visualizations",
      "description": "Visualizations API."
    },
    {
      "name": "dashboards",
      "description": "Dashboards API."
    },
    {
      "name": "ai",
      "description": "Explainability of models and activity of AI assistants and agents"
    },
    {
      "name": "organization",
      "description": "The organization: its value report (what AIR-Core did on its own in a month)."
    },
    {
      "name": "scim",
      "description": "SCIM 2.0 user provisioning of an organization (RFC 7643, 7644). Authentication: the bearer token generated in Organization settings › Corporate sign-in (not an x-auth-token). Every call is recorded in the activity of the organization."
    },
    {
      "name": "collaboration",
      "description": "Comments on dashboards and visualizations (with mentions), annotations of dates on time series and the notifications of the user"
    }
  ],
  "paths": {
    "/api/oauth/login": {
      "post": {
        "description": "Obtains an authentication token given a bearer token. You can obtain a bearer token when the user gives authorization to your application to access their account.",
        "tags": [
          "authentication"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "client_id": {
                    "description": "Client ID of your application.",
                    "type": "string",
                    "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                  },
                  "client_secret": {
                    "description": "Client secret of your application.",
                    "type": "string",
                    "example": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                  },
                  "bearer": {
                    "description": "Bearer token.",
                    "type": "string",
                    "example": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                  },
                  "expiration": {
                    "description": "Expiration options. Define the duration of the token.",
                    "type": "string",
                    "example": "never",
                    "enum": [
                      "never",
                      "year",
                      "month",
                      "week",
                      "day"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "auth_token": {
                      "type": "string",
                      "description": "Authentication token. You need it in order to access the API v1.0.",
                      "example": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Application or bearer token not found.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INVALID_CREDENTIALS",
                        "INVALID_BEARER",
                        "USER_NOT_FOUND"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Invalid application credentials."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/oauth/revoke": {
      "post": {
        "description": "Revokes an authentication token.",
        "tags": [
          "authentication"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "client_id": {
                    "description": "Client ID of your application.",
                    "type": "string",
                    "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                  },
                  "client_secret": {
                    "description": "Client secret of your application.",
                    "type": "string",
                    "example": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                  },
                  "auth_token": {
                    "description": "Autehntication token",
                    "type": "string",
                    "example": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Application or token not found.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INVALID_CREDENTIALS",
                        "INVALID_TOKEN"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Invalid application credentials."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/who": {
      "get": {
        "description": "Gets the session basic information",
        "tags": [
          "account"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "user_id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "user_name": {
                      "type": "string",
                      "example": "Example_User"
                    },
                    "user_email": {
                      "type": "string",
                      "example": "user@example.com"
                    },
                    "token_expiration": {
                      "type": "string",
                      "description": "Expiration date or 'never' if the token never expires.",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "permissions": {
                      "description": "Session permissions (by the auth token)",
                      "properties": {
                        "read_workspaces": {
                          "type": "boolean",
                          "description": "Permission to read workspaces and its children elements."
                        },
                        "write_workspaces": {
                          "type": "boolean",
                          "description": "Permission to create, edit and remove workspaces."
                        },
                        "profile": {
                          "type": "boolean",
                          "description": "Permission modify user's profile."
                        }
                      }
                    },
                    "organizations": {
                      "description": "List of organizations",
                      "type": "array",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Organization ID",
                            "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                          },
                          "name": {
                            "type": "string",
                            "description": "Organization Name",
                            "example": "My Organization"
                          },
                          "role": {
                            "type": "string",
                            "description": "Role",
                            "example": "admin"
                          }
                        }
                      }
                    },
                    "toolset": {
                      "type": "string",
                      "enum": [
                        "full",
                        "directory"
                      ],
                      "description": "Tool set the token was issued for. `directory`: an OAuth authorization granted for the directory tool set of the MCP server (`/mcp/directory`), which cannot edit or delete data; the API answers it only the operations of those tools and 403 `DIRECTORY_SCOPE` to the rest. `full`: any other token (personal tokens and OAuth authorizations for `/mcp`).",
                      "example": "full"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          }
        }
      }
    },
    "/api/v2/profile": {
      "get": {
        "description": "Gets the user's public profile",
        "tags": [
          "account"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "user_name": {
                      "type": "string",
                      "example": "Example_User"
                    },
                    "full_name": {
                      "type": "string",
                      "example": "John Doe"
                    },
                    "bio": {
                      "type": "string",
                      "example": "User's short description."
                    },
                    "url": {
                      "type": "string",
                      "example": "https://www.johndoe.com/"
                    },
                    "country": {
                      "type": "string",
                      "example": "United States"
                    },
                    "picture": {
                      "type": "string",
                      "example": "https://app.air-core.io/static/images/user.jpg",
                      "description": "If the picture is not set. Take 'https://app.air-core.io/static/images/user.jpg' by default."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          }
        }
      },
      "post": {
        "description": "Modifies user's profile",
        "tags": [
          "account"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "full_name": {
                    "description": "Full name (max 200 characters).",
                    "type": "string",
                    "example": "John Doe"
                  },
                  "bio": {
                    "description": "Bio. (max 300 characters)",
                    "type": "string",
                    "example": "User's short description."
                  },
                  "url": {
                    "description": "User's personal website (max 200 characters)",
                    "type": "string",
                    "example": "https://www.johndoe.com/"
                  },
                  "country": {
                    "description": "Country (max 200 characters)",
                    "type": "string",
                    "example": "United States"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_FULL_NAME",
                        "BAD_BIO",
                        "BAD_URL",
                        "BAD_COUNTRY"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Acess denied. The authorization token lacks from the required permissions."
          }
        }
      }
    },
    "/api/v2/workspaces": {
      "get": {
        "description": "Obtains the list of workspaces",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Select Organization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                      },
                      "name": {
                        "type": "string",
                        "example": "Example workspace"
                      },
                      "description": {
                        "type": "string",
                        "example": "Example workspace description."
                      },
                      "created": {
                        "type": "string",
                        "description": "Date when the workspace was created",
                        "example": "2020-01-27T10:34:41.702Z"
                      },
                      "last_modified": {
                        "type": "string",
                        "description": "Date when the workspace was last modified",
                        "example": "2020-01-27T10:34:41.702Z"
                      },
                      "last_access": {
                        "type": "string",
                        "description": "Date when the workspace was accessed by an user",
                        "example": "2020-01-27T10:34:41.702Z"
                      },
                      "sources_count": {
                        "type": "integer",
                        "format": "int32",
                        "description": "Number of sources in the workspace"
                      },
                      "dashboards_count": {
                        "type": "integer",
                        "format": "int32",
                        "description": "Number of dashboards in the workspace"
                      },
                      "visualizations_count": {
                        "type": "integer",
                        "format": "int32",
                        "description": "Number of visualizations in the workspace"
                      },
                      "models_count": {
                        "type": "integer",
                        "format": "int32",
                        "description": "Number of artificial intelligence models in the workspace"
                      },
                      "size_bytes": {
                        "type": "integer",
                        "format": "int64",
                        "description": "Size (bytes) of the sources and models in the workspace"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "description": "Creates a new workspace",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Select Organization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Workspace name (max 80 characters)",
                    "example": "Example workspace"
                  },
                  "description": {
                    "type": "string",
                    "description": "Workspace description (max 300 characters)",
                    "example": "Example workspace description."
                  },
                  "folder": {
                    "type": "string",
                    "description": "Folder (sidebar group) of the workspace (max 80 characters). Optional; empty means no folder. Never taken from the description.",
                    "example": "Reports"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "workspace_id": {
                      "type": "string",
                      "description": "The ID of the new workspace.",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_FOLDER"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspaces/import": {
      "post": {
        "description": "Creates a new workspace (mport from ZIP)",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Select Organization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Workspace name (max 80 characters)",
                    "example": "Example workspace"
                  },
                  "description": {
                    "type": "string",
                    "description": "Workspace description (max 300 characters)",
                    "example": "Example workspace description."
                  },
                  "folder": {
                    "type": "string",
                    "description": "Folder (sidebar group) of the workspace (max 80 characters). Optional; empty means no folder. Never taken from the description.",
                    "example": "Reports"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "ZIP file to upload",
                    "example": "... (Binary data) ..."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "workspace_id": {
                      "type": "string",
                      "description": "The ID of the new workspace.",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_FOLDER"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}": {
      "get": {
        "description": "Gets the information of a workspace",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "name": {
                      "type": "string",
                      "example": "Example workspace"
                    },
                    "description": {
                      "type": "string",
                      "example": "Example workspace description."
                    },
                    "created": {
                      "type": "string",
                      "description": "Date when the workspace was created",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_modified": {
                      "type": "string",
                      "description": "Date when the workspace was last modified",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_access": {
                      "type": "string",
                      "description": "Date when the workspace was accessed by an user",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "sources_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Number of sources in the workspace"
                    },
                    "dashboards_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Number of dashboards in the workspace"
                    },
                    "visualizations_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Number of visualizations in the workspace"
                    },
                    "models_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Number of artificial intelligence models in the workspace"
                    },
                    "size_bytes": {
                      "type": "integer",
                      "format": "int64",
                      "description": "Size (bytes) of the sources and models in the workspace"
                    },
                    "disableIndividualAlerts": {
                      "type": "boolean",
                      "description": "True if individual email notifications are disabled"
                    },
                    "hasSecret": {
                      "type": "boolean",
                      "description": "Whether the workspace has an iframe signing key; the key is never returned."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied to the resource",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Modifies workspace metadata. The signing key is preserved; rotation uses POST /api/ws/secret/rotate with an authorized session and CSRF token.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Workspace name (max 80 characters)",
                    "example": "Example workspace"
                  },
                  "description": {
                    "type": "string",
                    "description": "Workspace description (max 300 characters)",
                    "example": "Example workspace description."
                  },
                  "folder": {
                    "type": "string",
                    "description": "Folder (sidebar group) of the workspace (max 80 characters). Optional; empty means no folder. Never taken from the description.",
                    "example": "Reports"
                  },
                  "disableIndividualAlerts": {
                    "type": "boolean",
                    "description": "True if individual email notifications are disabled"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_FOLDER"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "delete": {
        "description": "Deletes a workspace",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/iframe": {
      "post": {
        "description": "Creates iframe token for the workspace. Requires a secret to be set.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "dashboard",
                      "visualization"
                    ],
                    "description": "Iframe type"
                  },
                  "id": {
                    "type": "string",
                    "description": "ID of the dashboard or the visualization",
                    "example": "xxxxx-xxxxx-xxxxx-xxxxx"
                  },
                  "filters": {
                    "type": "array",
                    "items": {
                      "properties": {
                        "source": {
                          "type": "string",
                          "description": "ID of the source to apply the filter to",
                          "example": "xxxxx-xxxxx-xxxxx-xxxxx"
                        },
                        "root": {
                          "$ref": "#/components/schemas/QueryTree"
                        }
                      }
                    },
                    "description": "List of filters to enforce"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "token": {
                      "type": "string",
                      "description": "Json web token"
                    },
                    "url": {
                      "type": "string",
                      "description": "Iframe URL"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/export": {
      "post": {
        "description": "Exports a workspace to a ZIP file",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/clone": {
      "post": {
        "description": "Clones a workspace. With source_mapping, the visualizations and dashboards of the copy read from other sources of the workspace.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Workspace name (max 80 characters)",
                    "example": "Example workspace"
                  },
                  "source_mapping": {
                    "type": "object",
                    "description": "Optional. Sources to replace in the copy: ID of a source read by the visualizations and dashboards of the workspace -> ID of another source of the same workspace. Columns are matched by name (exact, then ignoring case) and every column index of the visualizations, dashboard filters and filter widgets is translated.",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "example": {
                      "SOURCE_2025_ID": "SOURCE_2026_ID"
                    }
                  },
                  "force": {
                    "type": "boolean",
                    "description": "Only with source_mapping. Clone even if some visualizations or filters use columns that the new source does not have: those columns are removed from them. Without it, the request is refused with 409 and the report.",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "workspace_id": {
                      "type": "string",
                      "description": "The ID of the new workspace.",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_SOURCE_MAPPING",
                        "SOURCE_MAPPING_NOT_FOUND"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          },
          "409": {
            "description": "The source mapping would remove columns from some visualizations or filters. Send force=true to clone anyway.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "SOURCE_MAPPING_BREAKS"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "report": {
                      "$ref": "#/components/schemas/SourceMappingReport"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/tasks": {
      "get": {
        "description": "Obtains the list of tasks",
        "tags": [
          "tasks"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "description": "Requested page (starts with 0)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "limit",
            "description": "Max number of items per page (max 500)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "page": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Current page"
                    },
                    "limit": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Max items per page"
                    },
                    "pages_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of pages"
                    },
                    "items_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of items"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                          },
                          "user_id": {
                            "type": "string",
                            "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx",
                            "description": "User who created the task"
                          },
                          "user_name": {
                            "type": "string",
                            "example": "UserName",
                            "description": "User who created the task"
                          },
                          "created": {
                            "type": "string",
                            "description": "Task creation date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "status": {
                            "type": "string",
                            "description": "Task status. (pending = Pending to be handled, running = Executing, success = Ended successfully, failed = Ended with an error)",
                            "enum": [
                              "pending",
                              "running",
                              "success",
                              "failed"
                            ]
                          },
                          "duration": {
                            "type": "integer",
                            "format": "int64",
                            "description": "Duration of the task (in milliseconds)"
                          },
                          "name": {
                            "type": "string",
                            "example": "Task name"
                          },
                          "description": {
                            "type": "string",
                            "example": "Task description"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/task/{taskId}": {
      "get": {
        "description": "Obtains task information",
        "tags": [
          "tasks"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "taskId",
            "description": "Identifier of the task",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "user_id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx",
                      "description": "User who created the task"
                    },
                    "user_name": {
                      "type": "string",
                      "example": "UserName",
                      "description": "User who created the task"
                    },
                    "created": {
                      "type": "string",
                      "description": "Task creation date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "status": {
                      "type": "string",
                      "description": "Task status. (pending = Pending to be handled, running = Executing, success = Ended successfully, failed = Ended with an error)",
                      "enum": [
                        "pending",
                        "running",
                        "success",
                        "failed"
                      ]
                    },
                    "duration": {
                      "type": "integer",
                      "format": "int64",
                      "description": "Duration of the task (in milliseconds)"
                    },
                    "name": {
                      "type": "string",
                      "example": "Task name"
                    },
                    "description": {
                      "type": "string",
                      "example": "Task description"
                    },
                    "subtask": {
                      "type": "string",
                      "description": "Name of the current sub-task"
                    },
                    "progress": {
                      "type": "number",
                      "format": "double",
                      "description": "Progress of the current sub-task"
                    },
                    "result": {
                      "type": "string",
                      "description": "ID of the resulting object of the task. For an export (result_type file), the URL that downloads its ZIP with the token.",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "result_type": {
                      "type": "string",
                      "enum": [
                        "source",
                        "model",
                        "file",
                        "experiment",
                        "template"
                      ]
                    },
                    "error_description": {
                      "type": "string",
                      "description": "Error message (if the task failed)",
                      "example": "Unexpected error"
                    },
                    "template": {
                      "$ref": "#/components/schemas/TemplateRun"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "delete": {
        "description": "Force stops a running task.",
        "tags": [
          "tasks"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "taskId",
            "description": "Identifier of the task",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "TASK_NOT_RUNNING"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/task/{taskId}/file": {
      "get": {
        "description": "Downloads the ZIP file made by an export task (of a workspace or a dashboard). It needs the data export permission in the workspace. The file is kept for 24 hours after the export ends.",
        "tags": [
          "tasks"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "taskId",
            "description": "Identifier of the export task",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ZIP file.",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied (the token lacks permissions, or the user cannot export data from the workspace)"
          },
          "404": {
            "description": "The task is not a finished export, or its file is no longer available (FILE_EXPIRED)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sources": {
      "get": {
        "description": "Obtains the list of data sources",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "description": "Requested page (starts with 0)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "limit",
            "description": "Max number of items per page (max 500)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "field_type",
            "description": "Optional: only the sources with at least one field of this type (date lists the sources a forecast can use). The answer then also has field_type and total_sources, the number of sources of the workspace.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "date",
                "numeric",
                "nominal",
                "logic",
                "text"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "page": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Current page"
                    },
                    "limit": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Max items per page"
                    },
                    "pages_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of pages"
                    },
                    "items_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of items"
                    },
                    "field_type": {
                      "type": "string",
                      "description": "The field_type asked for, when it was given"
                    },
                    "total_sources": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Number of sources of the workspace, when field_type was given (to tell an empty workspace from one without sources of that type)"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                          },
                          "created": {
                            "type": "string",
                            "description": "Creation date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_modified": {
                            "type": "string",
                            "description": "Last modified date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_access": {
                            "type": "string",
                            "description": "Last access date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "name": {
                            "type": "string",
                            "example": "Example name"
                          },
                          "description": {
                            "type": "string",
                            "example": "Example description"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "mysql",
                              "ms_sql",
                              "oracle",
                              "pg",
                              "empty",
                              "derived",
                              "url_json",
                              "file_json",
                              "url_csv",
                              "file_csv",
                              "mqtt",
                              "mongo",
                              "influx",
                              "s3",
                              "external",
                              "rt"
                            ]
                          },
                          "features": {
                            "type": "integer",
                            "format": "int32",
                            "description": "Number of features"
                          },
                          "instances": {
                            "type": "integer",
                            "format": "int32",
                            "description": "Number of instances"
                          },
                          "size_bytes": {
                            "type": "integer",
                            "format": "int64",
                            "description": "Source size in bytes"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Creates a new data source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Example source name",
                    "description": "Source name. Max 120 characters."
                  },
                  "description": {
                    "type": "string",
                    "example": "Example source description",
                    "description": "Source description. Max 300 characters."
                  },
                  "encrypted": {
                    "type": "boolean",
                    "description": "True to encrypt the data source"
                  },
                  "shuffled": {
                    "type": "boolean",
                    "description": "True to shuffle instances"
                  },
                  "features": {
                    "type": "array",
                    "description": "List of features to create",
                    "items": {
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Feature name (max 120 characters)",
                          "example": "Field_1"
                        },
                        "type": {
                          "type": "string",
                          "description": "Feature type",
                          "enum": [
                            "nominal",
                            "logic",
                            "numeric",
                            "date",
                            "text",
                            "unknown"
                          ]
                        },
                        "date_format": {
                          "type": "string",
                          "description": "Date formatting (max 80 characters)",
                          "example": "YYYY-MM-DD hh:mm:ss"
                        },
                        "indexed": {
                          "type": "boolean",
                          "description": "True if the feature must be indexed."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "source_id": {
                      "type": "string",
                      "description": "ID of the source created.",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_FEATURES",
                        "BAD_NAME",
                        "BAD_DESCRIPTION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/clone": {
      "post": {
        "description": "Clones Source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Source name (Max 120 characters)",
                    "example": "Source name"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "source_id": {
                      "type": "string",
                      "description": "ID of the new source",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sources/derived": {
      "post": {
        "description": "Creates a derived source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Example source name",
                    "description": "Source name. Max 120 characters."
                  },
                  "description": {
                    "type": "string",
                    "example": "Example source description",
                    "description": "Source description. Max 300 characters."
                  },
                  "derived_type": {
                    "type": "string",
                    "enum": [
                      "filter",
                      "extend",
                      "join",
                      "merge",
                      "aggregate",
                      "join_multi",
                      "recipe",
                      "text_analysis"
                    ],
                    "description": "Derived type. filter = Filters a source. extend = Melts a source. join = Join 2 sources. merge = merges 2 sources. aggregate = Performs instances aggregations. join_multi = Joins a main source with 1 to 5 more (main, lookups and columns): the lookups are loaded in memory up to the cap of the plan (JOIN_TOO_BIG above it), a repeated key of a lookup uses its first row, and each run keeps a report (GET .../source/{sourceId}/join-report). recipe = a prepared source: the steps over the origin, recomputed each time the origin updates (see GET .../source/{sourceId}/recipe). text_analysis = «Analizar textos»: the columns of the origin plus a classical analysis of one of its columns of texts (origin, column, tasks, language, keywords_top, date_column, topics, classifiers, names), applied again when the origin updates when the plan includes it (see GET .../source/{sourceId}/text-analysis); refused with TEXT_ANALYSIS_LIMIT or TEXT_ANALYSIS_PLAN by the caps of the plan and TEXT_ENGINE_OUTDATED when the AI module cannot analyse texts"
                  },
                  "origin": {
                    "type": "string",
                    "description": "ID of the origin source.",
                    "example": "xxxx-xxxx-xxxx-xxxx"
                  },
                  "origin_b": {
                    "type": "string",
                    "description": "ID of the second origin source. For join and merge.",
                    "example": "xxxx-xxxx-xxxx-xxxx"
                  },
                  "query": {
                    "$ref": "#/components/schemas/QueryTree"
                  },
                  "features": {
                    "type": "string",
                    "description": "List of features indexes, split by commas. For filter, this selects the list of features to keep in the derived source. For extend, this selects the features to melt.",
                    "example": "0,1,2,3,4,5"
                  },
                  "steps": {
                    "type": "array",
                    "maxItems": 50,
                    "description": "recipe: the steps, checked against the columns of the origin (400 with the code of the first one that cannot be used)",
                    "items": {
                      "$ref": "#/components/schemas/RecipeStep"
                    }
                  },
                  "column": {
                    "type": "string",
                    "description": "text_analysis: NAME of the column of texts (text or nominal)"
                  },
                  "tasks": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "language",
                        "sentiment",
                        "keywords",
                        "entities",
                        "topics"
                      ]
                    },
                    "description": "text_analysis: what to compute (default language, sentiment, keywords); entities on the plans that include them"
                  },
                  "language": {
                    "type": "string",
                    "description": "text_analysis: auto (default: identified in each text) or es, en, ca, de, fr, it, pt, ja, zh"
                  },
                  "keywords_top": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 20,
                    "description": "text_analysis: keywords per text (default 5)"
                  },
                  "date_column": {
                    "type": "string",
                    "description": "text_analysis: NAME of a column of dates: sentiment (and topics, on the plans with topics over time) by period"
                  },
                  "topics": {
                    "type": "object",
                    "description": "text_analysis with the task topics: {k: 0 (automatic) or 2 to the maximum of the plan, method?: nmf or lda, model?: an existing topics model of the workspace}"
                  },
                  "classifiers": {
                    "type": "array",
                    "maxItems": 5,
                    "description": "text_analysis: text classifiers of the workspace to apply ({model, column, kind: emotions or labels}); own classifiers on the plans that include them",
                    "items": {
                      "type": "object"
                    }
                  },
                  "names": {
                    "type": "object",
                    "description": "text_analysis: names of the new columns by output (language, sentiment, score, keywords, entities, people, topic, topic_weight); a name taken by the origin gets « 2»"
                  },
                  "field_a": {
                    "type": "number",
                    "format": "int32",
                    "description": "Match feature for join in first origin source. For merge, this sets the source name filed if the first source is already a merge source. For aggregate, this is the field to group by, set to -1 for no grouping."
                  },
                  "field_b": {
                    "type": "number",
                    "format": "int32",
                    "description": "Match feature for join in the second origin source."
                  },
                  "encrypted": {
                    "type": "boolean",
                    "description": "True to encrypt the data source"
                  },
                  "shuffled": {
                    "type": "boolean",
                    "description": "True to shuffle instances"
                  },
                  "main": {
                    "type": "string",
                    "description": "join_multi: identifier of the main source (one output row per row of it, or fewer with inner lookups)"
                  },
                  "lookups": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 5,
                    "description": "join_multi: the sources joined to the main one, in order",
                    "items": {
                      "$ref": "#/components/schemas/JoinMultiLookup"
                    }
                  },
                  "columns": {
                    "type": "array",
                    "maxItems": 100,
                    "description": "join_multi: the columns of the new source, in order (default: every column of the main source and of each lookup without its key columns)",
                    "items": {
                      "$ref": "#/components/schemas/JoinMultiColumn"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created. This task, if success, will create and initialize the derived source.",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "INVALID_DERIVED_TYPE",
                        "ORIGIN_SOURCE_INVALID",
                        "ORIGIN_SOURCE_INVALID_B",
                        "ORIGIN_SOURCE_EXTERNAL",
                        "FIELD_A_INVALID",
                        "FIELD_B_INVALID",
                        "BAD_JOIN",
                        "BAD_JOIN_KEYS",
                        "BAD_JOIN_COLUMNS",
                        "TOO_MANY_SOURCES",
                        "UNKNOWN_KEY_COLUMN",
                        "UNKNOWN_COLUMN",
                        "NO_COLUMNS",
                        "TOO_MANY_COLUMNS",
                        "EXTERNAL",
                        "JOIN_TOO_BIG"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sources/external": {
      "post": {
        "description": "Creates an external source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Example source name",
                    "description": "Source name. Max 120 characters."
                  },
                  "description": {
                    "type": "string",
                    "example": "Example source description",
                    "description": "Source description. Max 300 characters."
                  },
                  "url": {
                    "type": "string",
                    "description": "External connection URL",
                    "example": "https://example.sources.air-core.io/?pub=pub-key&secret=secret-key"
                  },
                  "features": {
                    "type": "array",
                    "description": "List of features to create",
                    "items": {
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Feature name (max 120 characters)",
                          "example": "Field_1"
                        },
                        "type": {
                          "type": "string",
                          "description": "Feature type",
                          "enum": [
                            "nominal",
                            "logic",
                            "numeric",
                            "date",
                            "text"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "source_id": {
                      "type": "string",
                      "description": "ID of the new source",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_FEATURES",
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_URL"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sources/real_time": {
      "post": {
        "description": "Creates a real time source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Example source name",
                    "description": "Source name. Max 120 characters."
                  },
                  "description": {
                    "type": "string",
                    "example": "Example source description",
                    "description": "Source description. Max 300 characters."
                  },
                  "max_age": {
                    "type": "number",
                    "format": "int64",
                    "description": "Max age of registers in milliseconds. Set to 0 or negative for unlimited age. It can never be longer than the maximum age of the plan of the organization: a longer age (or 0) is shortened to it.",
                    "example": "0"
                  },
                  "features": {
                    "type": "array",
                    "description": "List of features to create",
                    "items": {
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Feature name (max 120 characters)",
                          "example": "Field_1"
                        },
                        "type": {
                          "type": "string",
                          "description": "Feature type",
                          "enum": [
                            "nominal",
                            "logic",
                            "numeric",
                            "date",
                            "text"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "source_id": {
                      "type": "string",
                      "description": "ID of the new source",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_FEATURES",
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_URL"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sources/other": {
      "post": {
        "description": "Creates other type of source. Including database sources or MQTT sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Example source name",
                    "description": "Source name. Max 120 characters."
                  },
                  "description": {
                    "type": "string",
                    "example": "Example source description",
                    "description": "Source description. Max 300 characters."
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "file/any",
                      "url/any",
                      "s3",
                      "ckan",
                      "database/mongo",
                      "database/mysql",
                      "database/influx",
                      "mqtt"
                    ]
                  },
                  "encrypted": {
                    "type": "boolean",
                    "description": "True to encrypt the data source"
                  },
                  "shuffled": {
                    "type": "boolean",
                    "description": "True to shuffle instances"
                  },
                  "indexed": {
                    "type": "boolean",
                    "description": "True to index the fields"
                  },
                  "dyn_enabled": {
                    "type": "boolean",
                    "description": "Set to true to enable auto update"
                  },
                  "dyn_delay": {
                    "type": "number",
                    "format": "int64",
                    "description": "Auto update delay (milliseconds). Min is 5 minutes."
                  },
                  "dyn_replace": {
                    "type": "boolean",
                    "description": "Set to  true to replace the entire data set with each update. False to append the data."
                  },
                  "dyn_pk": {
                    "type": "string",
                    "description": "Name of the primary key field. In order to check for duplicates when appending."
                  },
                  "dyn_update_mode": {
                    "type": "boolean",
                    "description": "Set to true to update existing rows (by primary key). Set to false to skip duplicate rows. If you set dyn_replace to true. This option does not have any effect."
                  },
                  "file": {
                    "type": "string",
                    "example": "File (multipart/form-data) for file/any (required)",
                    "description": "File (multipart/form-data) for file/any (required)"
                  },
                  "file_name": {
                    "type": "string",
                    "example": "file.csv",
                    "description": "Name of the uploaded file"
                  },
                  "separator": {
                    "type": "string",
                    "example": ",",
                    "description": "Separator character for csv files"
                  },
                  "quotes": {
                    "type": "string",
                    "example": "\"",
                    "description": "Quotes character for csv files"
                  },
                  "csv_header": {
                    "type": "boolean",
                    "description": "Set to false if the csv files does not have a header."
                  },
                  "json_fields": {
                    "type": "array",
                    "description": "List of fileds to get, in order, for json files or mongo databases.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "json_prefix": {
                    "type": "string",
                    "example": "result.items",
                    "description": "Prefix to tell the engine where the data is in the JSON file. Use dots to split levels."
                  },
                  "json_mode": {
                    "type": "string",
                    "enum": [
                      "single",
                      "default"
                    ],
                    "example": "default",
                    "description": "Set to single in case there is a single instance in the JSON"
                  },
                  "date_format": {
                    "type": "string",
                    "example": "",
                    "description": "Date format in the CSV of JSON file. By default is the ISO format. This uses the Moment.js formats."
                  },
                  "url": {
                    "type": "string",
                    "description": "URL for url/any and ckan source types. In case of S3. This is the URI of the object inside the bucket. For mongo and influx, this is the connection URL."
                  },
                  "parser": {
                    "type": "string",
                    "description": "File format: 'auto' (or empty) detects it from its content, content type and name; or one of csv, json, jsonl (JSON Lines), parquet, xlsx (Excel, also XLS), ods, sqlite. Share links of Google Sheets, Google Drive, OneDrive, SharePoint and Dropbox are downloaded as the file they point to.",
                    "enum": [
                      "auto",
                      "csv",
                      "json",
                      "jsonl",
                      "parquet",
                      "xlsx",
                      "ods",
                      "sqlite"
                    ]
                  },
                  "sheet": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Sheet of a spreadsheet (xlsx, ods, Google Sheets) to read, by the name on its tab. Empty: the first one."
                  },
                  "http_headers": {
                    "type": "string",
                    "example": "Header1: Value1\nHeader2: Value2",
                    "description": "Custom headers to send"
                  },
                  "rejectUnauthorized": {
                    "type": "boolean",
                    "description": "Set to false to ignore invalid certificates: of the HTTPS server (url/any), or of a Microsoft SQL Server (database/mysql with db = ms, for a self-signed certificate). Default true."
                  },
                  "sdp_enabled": {
                    "type": "boolean",
                    "description": "Set to true to enable stored data parameter in the Query. Any instances of ${SDP} will be replaced."
                  },
                  "sdp_name": {
                    "type": "string",
                    "description": "Name of the field to use for SDP"
                  },
                  "sdp_dir": {
                    "type": "string",
                    "description": "Sorting direction to calc the SDP",
                    "enum": [
                      "desc",
                      "asc"
                    ]
                  },
                  "database": {
                    "type": "string",
                    "description": "Name of the database or the S3 bucket."
                  },
                  "user": {
                    "type": "string",
                    "description": "User / Access key ID"
                  },
                  "password": {
                    "type": "string",
                    "description": "Password / Secret key"
                  },
                  "table": {
                    "type": "string",
                    "description": "Name of the table / collection"
                  },
                  "query": {
                    "type": "string",
                    "description": "Database Query. For mongo, this is a JSON."
                  },
                  "sort": {
                    "type": "string",
                    "description": "For MongoDB. Sorting",
                    "example": "{\"field\": 1}"
                  },
                  "project": {
                    "type": "string",
                    "description": "MongoDB project.",
                    "example": "{\"field\": 1, \"field2\": 1}"
                  },
                  "limit": {
                    "type": "number",
                    "format": "int32",
                    "description": "Limit of results"
                  },
                  "db": {
                    "type": "string",
                    "description": "Database type (for relational)",
                    "enum": [
                      "mysql",
                      "pg",
                      "oracle",
                      "ms"
                    ]
                  },
                  "host": {
                    "type": "string",
                    "description": "Database host. For Microsoft SQL Server (db = ms) it can also be server\\INSTANCE (a named instance, found through the SQL Server Browser), server,port or tcp:server,port."
                  },
                  "port": {
                    "type": "number",
                    "format": "int32",
                    "description": "Port number"
                  },
                  "topics": {
                    "type": "string",
                    "description": "For MQTT, list of topics split by commas."
                  },
                  "fields_expected": {
                    "type": "array",
                    "description": "List of expected fields for MQTT",
                    "items": {
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Name of the field"
                        },
                        "type": {
                          "type": "string",
                          "description": "Field type",
                          "enum": [
                            "numeric",
                            "nominal",
                            "text",
                            "date",
                            "logic"
                          ]
                        },
                        "dateFormat": {
                          "type": "string",
                          "description": "Date format"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "source_id": {
                      "type": "string",
                      "description": "ID of the new source",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_FEATURES",
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_URL"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}": {
      "get": {
        "description": "Obtains information about a source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "catalog",
            "description": "true: adds `catalog`, the catalogue of the source as GET .../catalog gives it (only to a member who can read the sources). Without it the answer is the same as always.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "created": {
                      "type": "string",
                      "description": "Creation date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_modified": {
                      "type": "string",
                      "description": "Last modified date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_access": {
                      "type": "string",
                      "description": "Last access date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "name": {
                      "type": "string",
                      "example": "Example name"
                    },
                    "description": {
                      "type": "string",
                      "example": "Example description"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "mysql",
                        "ms_sql",
                        "oracle",
                        "pg",
                        "empty",
                        "derived",
                        "url_json",
                        "file_json",
                        "url_csv",
                        "file_csv",
                        "mqtt",
                        "mongo",
                        "influx",
                        "s3",
                        "external",
                        "rt"
                      ]
                    },
                    "features": {
                      "type": "array",
                      "description": "Description of the features",
                      "items": {
                        "properties": {
                          "index": {
                            "type": "integer",
                            "format": "int32",
                            "description": "Feature index, starting with 0"
                          },
                          "name": {
                            "type": "string",
                            "description": "Feature name",
                            "example": "Field_0"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "nominal",
                              "logic",
                              "numeric",
                              "date",
                              "text",
                              "unknown"
                            ]
                          },
                          "indexed": {
                            "type": "boolean"
                          },
                          "date_format": {
                            "type": "string",
                            "example": "YYYY-MM-DD hh:mm:ss"
                          },
                          "computed": {
                            "type": "boolean",
                            "description": "True for computed fields"
                          },
                          "computed_exp": {
                            "type": "string",
                            "description": "Computed expression. Empty for regular fields.",
                            "example": "$1 + $2 * $3"
                          },
                          "null_count": {
                            "type": "integer",
                            "format": "int32",
                            "description": "Number of instances with value = null"
                          },
                          "min": {
                            "type": "number",
                            "format": "double",
                            "description": "Min value"
                          },
                          "max": {
                            "type": "number",
                            "format": "double",
                            "description": "Max value"
                          },
                          "mean": {
                            "type": "number",
                            "format": "double",
                            "description": "Average value"
                          },
                          "deviation": {
                            "type": "number",
                            "format": "double",
                            "description": "Standard deviation"
                          },
                          "values": {
                            "type": "array",
                            "description": "Values of a category (nominal) field, up to 40, as the data writes them.",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "instances": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Number of instances"
                    },
                    "size_bytes": {
                      "type": "integer",
                      "format": "int64",
                      "description": "Source size in bytes"
                    },
                    "shuffed": {
                      "type": "boolean",
                      "description": "True if instances are shuffled"
                    },
                    "catalog": {
                      "description": "Only with catalog=true: the catalogue of the source",
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/SourceCatalog"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Sets the name and description of the source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Source name (max 120 characters)",
                    "example": "Example name"
                  },
                  "description": {
                    "type": "string",
                    "description": "Source description (max 300 characters)",
                    "example": "Example description"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "delete": {
        "description": "Deletes the data source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/dependents": {
      "get": {
        "description": "Dependency map of a source: what is built from it, to check before editing or deleting it.\n\n- `derived`: its derived sources as a tree (`how`: `filter`, `join`, `merge`, `extend` (melt), `aggregate`, or `model` for the predictions of a model applied to it), followed down to 6 levels; `deeper` counts the sources one level beyond.\n- `models`, `visualizations` and `alerts` (the simple notices): those built on the source or on one of its derived sources (`direct` is false for the latter, and `source` says which).\n- `dashboards`: those that show one of those visualizations, a widget of one of those models, or use the source or a derived source in a monitor, a filter or a variable input (`via`).\n\nEach kind lists up to 50 items, direct ones first; `more` counts the rest and `partial` marks a count cut by a safety limit. Groups the user of the token cannot read in the workspace (`read_sources`, `read_models`, `read_views`, `read_dashboards`) keep their count, with `hidden: true` and no items. A public source does not make its map public: the token is always required.\n",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceLineage"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "ACCESS_DENIED"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/connection": {
      "get": {
        "description": "Gets external source connection URL",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "url": {
                      "type": "string",
                      "description": "Marker, never the stored URL: the connection URL holds the secret key. Empty when there is no connection configured.",
                      "example": "****"
                    },
                    "url_origin": {
                      "type": "string",
                      "description": "Destination of the connection, for presentation only. No user, password, path or query.",
                      "example": "https://example.sources.air-core.io:443"
                    },
                    "pub": {
                      "type": "string",
                      "description": "Public key of the connection",
                      "example": "pub-key"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Sets the Connection for a external source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "External connection URL",
                    "example": "https://example.sources.air-core.io/?pub=pub-key&secret=secret-key"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_URL"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/real_time": {
      "get": {
        "description": "Gets real time connection details and configuration",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "max_age": {
                      "type": "number",
                      "format": "int64",
                      "description": "Max age of registers in milliseconds that the source keeps (its own, capped by the plan). 0 for unlimited."
                    },
                    "plan_max_age": {
                      "type": "number",
                      "format": "int64",
                      "description": "Maximum age of registers allowed by the plan of the organization, in milliseconds. 0 for no limit."
                    },
                    "mqtt_url": {
                      "type": "string",
                      "description": "Marker, never the configured URI: it can carry credentials of its own.",
                      "example": "****"
                    },
                    "mqtt_user": {
                      "type": "string",
                      "description": "Username to authenticate to the source"
                    },
                    "mqtt_password": {
                      "type": "string",
                      "description": "Marker, never the stored password. Regenerate it with POST real_time and regenerate_password to obtain a new value.",
                      "example": "****"
                    },
                    "mqtt_topic": {
                      "type": "string",
                      "description": "Topic to publish registers to the source"
                    },
                    "has_mqtt_password": {
                      "type": "boolean",
                      "description": "Whether a password is configured"
                    },
                    "mqtt_url_origin": {
                      "type": "string",
                      "description": "Destination of the MQTT service, which is what a client needs to connect.",
                      "example": "mqtts://mqtt.air-core.io:8883"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Updates real time configuration",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "max_age": {
                    "type": "number",
                    "format": "int64",
                    "description": "Max age of registers in milliseconds. Set to 0 or negative for unlimited. It can never be longer than the maximum age of the plan of the organization: a longer age (or 0) is shortened to it."
                  },
                  "regenerate_password": {
                    "type": "boolean",
                    "description": "Set to true to regenerate the MQTT password. Use if it was compromised."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "new_password": {
                      "type": "string",
                      "description": "Only present when regenerate_password was set. The single moment the value leaves the server."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/real_time_push": {
      "post": {
        "description": "Inserts an instance in real time. Alternative to MQTT for slower inserts.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "data": {
                    "type": "array",
                    "description": "Array of data fields. This does not include the timestamp or the computed fields",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/real_time_clear": {
      "post": {
        "description": "Clears instances of a real time source to fit into limits.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "from_time": {
                    "type": "number",
                    "format": "int64",
                    "description": "Timestamp (Unix millis). Start of the clear range"
                  },
                  "to_time": {
                    "type": "number",
                    "format": "int64",
                    "description": "Timestamp (Unix millis). End of the clear range"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/autoupdate": {
      "get": {
        "description": "Gets source auto update configuration",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "updateConfig": {
                      "description": "Auto update configuration",
                      "properties": {
                        "enabled": {
                          "type": "boolean",
                          "description": "True if auto update enabled"
                        },
                        "delay": {
                          "type": "number",
                          "format": "int64",
                          "description": "Delay (ms)"
                        },
                        "replace": {
                          "type": "boolean",
                          "description": "True to replace, false to append"
                        },
                        "updateMode": {
                          "type": "boolean",
                          "description": "True to update duplicates, false to skip duplicates"
                        },
                        "pk": {
                          "type": "string",
                          "description": "Name of the primary key, to detect duplicates."
                        },
                        "configuration": {
                          "description": "Auto update configuration.",
                          "properties": {
                            "separator": {
                              "type": "string",
                              "example": ",",
                              "description": "Separator character for csv files"
                            },
                            "quotes": {
                              "type": "string",
                              "example": "\"",
                              "description": "Quotes character for csv files"
                            },
                            "noheader": {
                              "type": "boolean",
                              "description": "Set to true if the csv files does not have a header."
                            },
                            "json_fields": {
                              "type": "array",
                              "description": "List of fileds to get, in order, for json files or mongo databases.",
                              "items": {
                                "type": "string"
                              }
                            },
                            "json_prefix": {
                              "type": "string",
                              "example": "result.items",
                              "description": "Prefix to tell the engine where the data is in the JSON file. Use dots to split levels."
                            },
                            "json_mode": {
                              "type": "string",
                              "enum": [
                                "single",
                                "default"
                              ],
                              "example": "default",
                              "description": "Set to single in case there is a single instance in the JSON"
                            },
                            "date_format": {
                              "type": "string",
                              "example": "",
                              "description": "Date format in the CSV of JSON file. By default is the ISO format. This uses the Moment.js formats."
                            },
                            "url": {
                              "type": "string",
                              "description": "URL for url/any and ckan source types. In case of S3. This is the URI of the object inside the bucket. For mongo and influx, this is the connection URL."
                            },
                            "parser": {
                              "type": "string",
                              "description": "File format: 'auto' (or empty) detects it from its content, content type and name; or one of csv, json, jsonl (JSON Lines), parquet, xlsx (Excel, also XLS), ods, sqlite. Share links of Google Sheets, Google Drive, OneDrive, SharePoint and Dropbox are downloaded as the file they point to.",
                              "enum": [
                                "auto",
                                "csv",
                                "json",
                                "jsonl",
                                "parquet",
                                "xlsx",
                                "ods",
                                "sqlite"
                              ]
                            },
                            "sheet": {
                              "type": "string",
                              "maxLength": 100,
                              "description": "Sheet of a spreadsheet (xlsx, ods, Google Sheets) to read, by the name on its tab. Empty: the first one."
                            },
                            "http_headers": {
                              "type": "string",
                              "example": "Header1: Value1\nHeader2: Value2",
                              "description": "Custom headers to send"
                            },
                            "rejectUnauthorized": {
                              "type": "boolean",
                              "description": "Set to false to ignore invalid certificates: of the HTTPS server (url/any), or of a Microsoft SQL Server (database/mysql with db = ms, for a self-signed certificate). Default true."
                            },
                            "sdp_enabled": {
                              "type": "boolean",
                              "description": "Set to true to enable stored data parameter in the Query. Any instances of ${SDP} will be replaced."
                            },
                            "sdp_name": {
                              "type": "string",
                              "description": "Name of the field to use for SDP"
                            },
                            "sdp_dir": {
                              "type": "string",
                              "description": "Sorting direction to calc the SDP",
                              "enum": [
                                "desc",
                                "asc"
                              ]
                            },
                            "database": {
                              "type": "string",
                              "description": "Name of the database or the S3 bucket."
                            },
                            "user": {
                              "type": "string",
                              "description": "User / Access key ID"
                            },
                            "password": {
                              "type": "string",
                              "description": "Password / Secret key"
                            },
                            "table": {
                              "type": "string",
                              "description": "Name of the table / collection"
                            },
                            "query": {
                              "type": "string",
                              "description": "Database Query. For mongo, this is a JSON."
                            },
                            "sort": {
                              "type": "string",
                              "description": "For MongoDB. Sorting",
                              "example": "{\"field\": 1}"
                            },
                            "project": {
                              "type": "string",
                              "description": "MongoDB project.",
                              "example": "{\"field\": 1, \"field2\": 1}"
                            },
                            "limit": {
                              "type": "number",
                              "format": "int32",
                              "description": "Limit of results"
                            },
                            "db": {
                              "type": "string",
                              "description": "Database type (for relational)",
                              "enum": [
                                "mysql",
                                "pg",
                                "oracle",
                                "ms"
                              ]
                            },
                            "host": {
                              "type": "string",
                              "description": "Database host. For Microsoft SQL Server (db = ms) it can also be server\\INSTANCE (a named instance, found through the SQL Server Browser), server,port or tcp:server,port."
                            },
                            "port": {
                              "type": "number",
                              "format": "int32",
                              "description": "Port number"
                            },
                            "topics": {
                              "type": "string",
                              "description": "For MQTT, list of topics split by commas."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Sets the auto update configuration",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "dyn_enabled": {
                    "type": "boolean",
                    "description": "Set to true to enable auto update"
                  },
                  "dyn_delay": {
                    "type": "number",
                    "format": "int64",
                    "description": "Auto update delay (milliseconds). Min is 5 minutes."
                  },
                  "dyn_replace": {
                    "type": "boolean",
                    "description": "Set to  true to replace the entire data set with each update. False to append the data."
                  },
                  "dyn_pk": {
                    "type": "string",
                    "description": "Name of the primary key field. In order to check for duplicates when appending."
                  },
                  "dyn_update_mode": {
                    "type": "boolean",
                    "description": "Set to true to update existing rows (by primary key). Set to false to skip duplicate rows. If you set dyn_replace to true. This option does not have any effect."
                  },
                  "separator": {
                    "type": "string",
                    "example": ",",
                    "description": "Separator character for csv files"
                  },
                  "quotes": {
                    "type": "string",
                    "example": "\"",
                    "description": "Quotes character for csv files"
                  },
                  "csv_header": {
                    "type": "boolean",
                    "description": "Set to false if the csv files does not have a header."
                  },
                  "json_fields": {
                    "type": "array",
                    "description": "List of fileds to get, in order, for json files or mongo databases.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "json_prefix": {
                    "type": "string",
                    "example": "result.items",
                    "description": "Prefix to tell the engine where the data is in the JSON file. Use dots to split levels."
                  },
                  "json_mode": {
                    "type": "string",
                    "enum": [
                      "single",
                      "default"
                    ],
                    "example": "default",
                    "description": "Set to single in case there is a single instance in the JSON"
                  },
                  "date_format": {
                    "type": "string",
                    "example": "",
                    "description": "Date format in the CSV of JSON file. By default is the ISO format. This uses the Moment.js formats."
                  },
                  "url": {
                    "type": "string",
                    "description": "URL for url/any and ckan source types. In case of S3. This is the URI of the object inside the bucket. For mongo and influx, this is the connection URL."
                  },
                  "parser": {
                    "type": "string",
                    "description": "File format: 'auto' (or empty) detects it from its content, content type and name; or one of csv, json, jsonl (JSON Lines), parquet, xlsx (Excel, also XLS), ods, sqlite. Share links of Google Sheets, Google Drive, OneDrive, SharePoint and Dropbox are downloaded as the file they point to.",
                    "enum": [
                      "auto",
                      "csv",
                      "json",
                      "jsonl",
                      "parquet",
                      "xlsx",
                      "ods",
                      "sqlite"
                    ]
                  },
                  "sheet": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Sheet of a spreadsheet (xlsx, ods, Google Sheets) to read, by the name on its tab. Empty: the first one."
                  },
                  "http_headers": {
                    "type": "string",
                    "example": "Header1: Value1\nHeader2: Value2",
                    "description": "Custom headers to send"
                  },
                  "rejectUnauthorized": {
                    "type": "boolean",
                    "description": "Set to false to ignore invalid certificates: of the HTTPS server (url/any), or of a Microsoft SQL Server (database/mysql with db = ms, for a self-signed certificate). Default true."
                  },
                  "sdp_enabled": {
                    "type": "boolean",
                    "description": "Set to true to enable stored data parameter in the Query. Any instances of ${SDP} will be replaced."
                  },
                  "sdp_name": {
                    "type": "string",
                    "description": "Name of the field to use for SDP"
                  },
                  "sdp_dir": {
                    "type": "string",
                    "description": "Sorting direction to calc the SDP",
                    "enum": [
                      "desc",
                      "asc"
                    ]
                  },
                  "database": {
                    "type": "string",
                    "description": "Name of the database or the S3 bucket."
                  },
                  "user": {
                    "type": "string",
                    "description": "User / Access key ID"
                  },
                  "password": {
                    "type": "string",
                    "description": "Password / Secret key"
                  },
                  "table": {
                    "type": "string",
                    "description": "Name of the table / collection"
                  },
                  "query": {
                    "type": "string",
                    "description": "Database Query. For mongo, this is a JSON."
                  },
                  "sort": {
                    "type": "string",
                    "description": "For MongoDB. Sorting",
                    "example": "{\"field\": 1}"
                  },
                  "project": {
                    "type": "string",
                    "description": "MongoDB project.",
                    "example": "{\"field\": 1, \"field2\": 1}"
                  },
                  "limit": {
                    "type": "number",
                    "format": "int32",
                    "description": "Limit of results"
                  },
                  "db": {
                    "type": "string",
                    "description": "Database type (for relational)",
                    "enum": [
                      "mysql",
                      "pg",
                      "oracle",
                      "ms"
                    ]
                  },
                  "host": {
                    "type": "string",
                    "description": "Database host. For Microsoft SQL Server (db = ms) it can also be server\\INSTANCE (a named instance, found through the SQL Server Browser), server,port or tcp:server,port."
                  },
                  "port": {
                    "type": "number",
                    "format": "int32",
                    "description": "Port number"
                  },
                  "topics": {
                    "type": "string",
                    "description": "For MQTT, list of topics split by commas."
                  },
                  "fields_expected": {
                    "type": "array",
                    "description": "List of expected fields for MQTT",
                    "items": {
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Name of the field"
                        },
                        "type": {
                          "type": "string",
                          "description": "Field type",
                          "enum": [
                            "numeric",
                            "nominal",
                            "text",
                            "date",
                            "logic"
                          ]
                        },
                        "dateFormat": {
                          "type": "string",
                          "description": "Date format"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_URL"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/features": {
      "post": {
        "description": "Transforms the source features. If you change the types, all the instances will be casted to the selected types.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "shuffled": {
                    "type": "boolean",
                    "description": "True to add a hidden feature to shuffle instances"
                  },
                  "features": {
                    "type": "array",
                    "description": "List of features mapped to the previous features",
                    "items": {
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Feature name (max 120 characters)",
                          "example": "Field_0"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "nominal",
                            "logic",
                            "numeric",
                            "date",
                            "text",
                            "unknown"
                          ]
                        },
                        "date_format": {
                          "type": "string",
                          "example": "YYYY-MM-DD hh:mm:ss"
                        },
                        "indexed": {
                          "type": "boolean"
                        },
                        "computed": {
                          "type": "boolean",
                          "description": "True if the field is computed"
                        },
                        "computed_exp": {
                          "type": "string",
                          "description": "Expression to compute the field (for computed fields).",
                          "example": "$1 + $2 * $3"
                        },
                        "mapped_to": {
                          "type": "integer",
                          "format": "int32",
                          "description": "Intex of the feature to map the existing data. You can specify -1 for no mapping."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_FEATURES"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/analyze": {
      "post": {
        "description": "Talk to your data: exact figures over ALL the rows of a source, computed by AIR-Core on the server (never by a language model). Counts, distinct values, sums, averages, minimums, maximums and medians, grouped by up to 2 fields (dates by hour, day, week, month, quarter or year in the time zone of the question), with filters, relative periods resolved on the server, top N, share of the total and comparison with the previous period or the same period a year before. Reads at most the rows of the installation limit (2,000,000 by default) for a limited time (25 s by default): read.partial says whether the figures cover only part of the rows. Changes nothing. Requires the read_sources permission. On the free plan it needs the organization's own AI key (403 TALK_PLAN_REQUIRED).",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "metric": {
                    "type": "string",
                    "description": "What is computed. count (default) counts rows, or the non-empty values of field; sum, avg and median need a numeric field; min and max a numeric or date field.",
                    "enum": [
                      "count",
                      "count_distinct",
                      "sum",
                      "avg",
                      "min",
                      "max",
                      "median"
                    ],
                    "example": "sum"
                  },
                  "field": {
                    "description": "Field measured, by name or index.",
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "integer"
                      }
                    ],
                    "example": "Importe"
                  },
                  "group_by": {
                    "type": "array",
                    "maxItems": 2,
                    "description": "Up to 2 fields to group by, by name or index, or as {field, bucket}. Date fields are grouped by bucket: hour, day, week (from Monday), month (default), quarter or year.",
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "integer"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "field": {
                              "oneOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "integer"
                                }
                              ]
                            },
                            "bucket": {
                              "type": "string",
                              "enum": [
                                "hour",
                                "day",
                                "week",
                                "month",
                                "quarter",
                                "year"
                              ]
                            }
                          }
                        }
                      ]
                    },
                    "example": [
                      "Región"
                    ]
                  },
                  "filters": {
                    "type": "array",
                    "description": "Conditions that must all hold: {field, op, value}. op: eq (default), not_eq, in (value is a list), gt, gte, lt, lte, cn, cni, sw, swi, ew, ewi or null. A category value written with other capitals or accents is matched to the value of the data, and the answer says so in notes.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "field": {
                          "oneOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "integer"
                            }
                          ]
                        },
                        "op": {
                          "type": "string"
                        },
                        "value": {}
                      }
                    },
                    "example": [
                      {
                        "field": "Canal",
                        "op": "eq",
                        "value": "online"
                      }
                    ]
                  },
                  "where": {
                    "description": "Advanced filter (QueryTree, as in the queries of instances), combined with filters. left may also be a field name.",
                    "type": "object"
                  },
                  "period": {
                    "type": "object",
                    "description": "Period of a date field (by default, the first date field), resolved on the server in the time zone: a preset (today, yesterday, this_week, last_week, this_month, last_month, this_quarter, last_quarter, this_year, last_year, last_7_days, last_30_days, last_90_days, last_12_months or last_N_days, weeks, months or years; this_* runs up to now), last N units (the current one included), or from and to, both included (YYYY, YYYY-Qn, YYYY-MM, YYYY-MM-DD or YYYY-MM-DDTHH:mm).",
                    "properties": {
                      "field": {
                        "oneOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "integer"
                          }
                        ]
                      },
                      "preset": {
                        "type": "string",
                        "example": "last_month"
                      },
                      "last": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "unit": {
                        "type": "string",
                        "enum": [
                          "hour",
                          "day",
                          "week",
                          "month",
                          "quarter",
                          "year"
                        ]
                      },
                      "from": {
                        "type": "string",
                        "example": "2026-03"
                      },
                      "to": {
                        "type": "string",
                        "example": "2026-03"
                      }
                    }
                  },
                  "compare": {
                    "type": "string",
                    "description": "Compare with the previous period (of the same length; this_* with the same stretch of the previous unit) or with the same period a year before. Needs period. Adds previous, change and change_pct.",
                    "enum": [
                      "previous_period",
                      "previous_year"
                    ]
                  },
                  "order": {
                    "type": "string",
                    "description": "desc: largest value first (default); asc; label: by name, or in date order (default when grouping by a date); label_desc.",
                    "enum": [
                      "desc",
                      "asc",
                      "label",
                      "label_desc"
                    ]
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200,
                    "description": "Groups returned (top N). 50 by default; the maximum is the installation limit (200 by default)."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA time zone of the question (UTC by default).",
                    "example": "Europe/Madrid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The figures as AIR-Core computed them. columns describes each position of rows: the group values (g0, g1; date groups as keys such as 2026-03, 2026-Q1, 2026-03-02 for the week of that Monday), value, and share, previous, change and change_pct when they apply. total has the value over all the rows that match; groups.other adds up the groups not returned (counts and sums). read says how many rows were read and whether the read was partial. explanation says how it was computed, in English.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "computed_by": {
                      "type": "string",
                      "example": "AIR-Core"
                    },
                    "source": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "rows": {
                          "type": "integer"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "stored",
                            "external",
                            "real_time"
                          ]
                        }
                      }
                    },
                    "question": {
                      "type": "object",
                      "description": "The question as it was understood, with field names, the period resolved to dates and the filter."
                    },
                    "columns": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": {}
                      }
                    },
                    "total": {
                      "type": "object",
                      "properties": {
                        "value": {
                          "type": "number"
                        },
                        "rows": {
                          "type": "integer"
                        },
                        "previous": {
                          "type": "number"
                        },
                        "change": {
                          "type": "number"
                        },
                        "change_pct": {
                          "type": "number"
                        }
                      }
                    },
                    "groups": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "returned": {
                          "type": "integer"
                        },
                        "other": {
                          "type": "object",
                          "nullable": true
                        }
                      }
                    },
                    "read": {
                      "type": "object",
                      "properties": {
                        "rows_read": {
                          "type": "integer"
                        },
                        "partial": {
                          "type": "boolean"
                        },
                        "partial_reason": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "rows",
                            "time",
                            "distinct"
                          ]
                        },
                        "max_rows": {
                          "type": "integer"
                        },
                        "max_seconds": {
                          "type": "integer"
                        },
                        "duration_ms": {
                          "type": "integer"
                        }
                      }
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "explanation": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad question: BAD_REQUEST, BAD_METRIC, BAD_FIELD (details.fields lists the fields), FIELD_REQUIRED, FIELD_NOT_NUMERIC, TOO_MANY_GROUPS, BAD_FILTER, BAD_PERIOD, DATE_FIELD_REQUIRED, DATE_FIELD_NOT_DATE, BAD_COMPARE, COMPARE_NEEDS_PERIOD, TOO_MANY_GROUP_VALUES or EMPTY_SOURCE, with a message."
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission, or TALK_PLAN_REQUIRED: on the free plan it needs the organization's own AI key."
          },
          "404": {
            "description": "Workspace or source not found"
          },
          "429": {
            "description": "Too many questions in a minute (TOO_MANY_REQUESTS)."
          },
          "503": {
            "description": "SOURCE_UNAVAILABLE: the data could not be read now (an external source whose connector does not answer)."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics": {
      "get": {
        "description": "The metric dictionary of the workspace (its semantic layer): each metric with its exact calculation, whether the user follows it and its last value. Needs `read_sources`.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The metrics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricList"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      },
      "post": {
        "description": "Creates a metric, checked against its source (fields that exist, numbers for sums and averages; category values are matched as the data write them and noted in `notes`). Needs `view_create` and a token that can write. Each change keeps a version.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The metric",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetricInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The metric created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                }
              }
            }
          },
          "400": {
            "description": "The definition does not run on the source (BAD_FIELD, FIELD_NOT_NUMERIC, BAD_METRIC, BAD_FILTER, DATE_FIELD_NOT_DATE, BAD_DIMENSION)"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          },
          "409": {
            "description": "A metric with that name exists (NAME_TAKEN)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics/suggestions": {
      "get": {
        "description": "Metrics the sources of the workspace suggest from their fields, without AI (the number of records, totals of amounts, averages of levels).",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "description": "Only this source",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The suggestions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics/{metricId}": {
      "get": {
        "description": "A metric with its targets, versions (who changed what), notices, unusual values found and the forecasts of its source. With `value=true`, also its value now (`value`, as `/value`).",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timezone",
            "description": "IANA time zone of the user (default Europe/Madrid)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "value",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The metric",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      },
      "post": {
        "description": "Changes a metric (what is not sent stays). A new version records who changed what. Needs `view_edit` or being its owner.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "What changes",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetricInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The metric, with `changes`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      },
      "delete": {
        "description": "Deletes a metric with its targets, unusual values, follows and notices. Needs `view_delete` or being its owner.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics/{metricId}/value": {
      "get": {
        "description": "The value of a metric now, computed by AIR-Core over all the rows: against the previous period (same stretch), its series with the usual range of each point, trend, unusual values (each point against its own history: median/MAD, with its weekly or yearly pattern when it has one), targets with their projection, forecast (when a model of «Predict the future» computes the same figure) and why it changed (`why`).",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timezone",
            "description": "IANA time zone of the user (default Europe/Madrid)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The card of the metric",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricValue"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics/{metricId}/explain": {
      "post": {
        "description": "Why a metric changed, computed exactly by AIR-Core: for each dimension the change of each group and the share of the total change it explains (sums and counts add up exactly; averages split into mix and rate). Without a body: the current period against the previous one. With `from`/`to` (and `ref_from`/`ref_to`): those periods. With `anomaly`: one point of the series against the one before or, with `season`, one season before.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "ref_from": {
                    "type": "string"
                  },
                  "ref_to": {
                    "type": "string"
                  },
                  "anomaly": {
                    "type": "string",
                    "description": "Key of a point (2026-10-31, 2026-10)"
                  },
                  "season": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 24
                  },
                  "dimensions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 3
                  },
                  "timezone": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The contribution analysis",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricExplanation"
                }
              }
            }
          },
          "400": {
            "description": "NO_DIMENSIONS, DATE_FIELD_REQUIRED, BAD_POINT"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics/{metricId}/follow": {
      "post": {
        "description": "Follows (or, with `follow: false`, stops following) a metric: it goes into the user's daily or weekly briefing; with `notify`, its unusual values reach them by email at once. Following does not start any email of the briefing: the briefing by email is off until the user turns it on (`email` in `/briefing/preferences`); `briefing_email` in the answer says whether it is on.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "follow": {
                    "type": "boolean"
                  },
                  "notify": {
                    "type": "boolean"
                  },
                  "timezone": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Whether the user follows it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics/{metricId}/targets": {
      "post": {
        "description": "Replaces the targets of a metric: one per period kind (every week, month, quarter or year) or for one period in particular (`period_key`: 2026-11, 2026-Q4, 2026, the Monday of a week).",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "targets": {
                    "type": "array",
                    "maxItems": 6,
                    "items": {
                      "type": "object",
                      "required": [
                        "period",
                        "value"
                      ],
                      "properties": {
                        "period": {
                          "type": "string",
                          "enum": [
                            "week",
                            "month",
                            "quarter",
                            "year"
                          ]
                        },
                        "period_key": {
                          "type": "string"
                        },
                        "value": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The targets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/metrics/{metricId}/dashboard": {
      "post": {
        "description": "Adds the metric to a dashboard (or a new one) as a key figure over the last days of its period.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metricId",
            "description": "Identifier of the metric",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dashboard": {
                    "type": "string"
                  },
                  "dashboard_name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The dashboard and the visualization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/briefing": {
      "get": {
        "description": "The briefing of the metrics the user follows, computed now: a card per metric (as `/value`) and `narrative`, two or three sentences from a template (summaries by AI are made by the daily or weekly briefing where AI is allowed: paid plans, or the free plan with AI credit or its own key; the model only sees aggregated figures, never rows).",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timezone",
            "description": "IANA time zone of the user (default Europe/Madrid)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The briefing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricBriefing"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/briefing/preferences": {
      "get": {
        "description": "When the user receives the briefing: `frequency` (daily, weekly, off), `timezone`, `hour`, `weekday` (1 Monday … 7 Sunday), `email`, `ai`. The briefing by email is off until the user turns it on (`email`: false by default); without it the briefing is only computed when it is opened.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timezone",
            "description": "IANA time zone of the user (default Europe/Madrid)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The preferences",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      },
      "post": {
        "description": "Changes when the user receives the briefing. It is sent once per day or ISO week of their calendar, from that hour in their time zone.",
        "tags": [
          "metrics"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "frequency": {
                    "type": "string",
                    "enum": [
                      "daily",
                      "weekly",
                      "off"
                    ]
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "hour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23
                  },
                  "weekday": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 7
                  },
                  "email": {
                    "type": "boolean"
                  },
                  "ai": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The preferences",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token or the user lacks the permission (ACCESS_DENIED), or a limit (LIMIT)"
          },
          "404": {
            "description": "Workspace, metric or its source not found (NOT_FOUND, SOURCE_NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/instances": {
      "get": {
        "description": "Queries the instances of a data source",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "select",
            "description": "List of features (indexes to fetch). Do not set to get all the features.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "0,1,2,3"
            }
          },
          {
            "name": "where",
            "description": "Conditions to match (filter), as a JSON of QueryTree (see schemas for more information)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order_by",
            "description": "Sorting options. Must be the index of the feature to sort by and 'asc' or 'desc'.",
            "example": "2,desc",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "description": "Number of instances to skip (if you orderred them)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "limit",
            "description": "Max number of instances to fetch. Do not set or set to -1 to get all the instances.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "features": {
                      "type": "array",
                      "description": "Description of the features",
                      "items": {
                        "properties": {
                          "index": {
                            "type": "integer",
                            "format": "int32",
                            "description": "Feature index, starting with 0"
                          },
                          "name": {
                            "type": "string",
                            "description": "Feature name",
                            "example": "Field_0"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "nominal",
                              "logic",
                              "numeric",
                              "date",
                              "text",
                              "unknown"
                            ]
                          },
                          "date_format": {
                            "type": "string",
                            "example": "YYYY-MM-DD hh:mm:ss"
                          }
                        }
                      }
                    },
                    "instances": {
                      "type": "array",
                      "description": "Instances, as a matrix",
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "INVALID_FILTER"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Updates a data source.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "replace": {
                    "type": "boolean",
                    "description": "True in order to replace the dataset with the provided data, false in order to append the provided data."
                  },
                  "pk": {
                    "type": "string",
                    "description": "Private key (optional) to use to orevent duplicates",
                    "example": "_id"
                  },
                  "date_format": {
                    "type": "string",
                    "description": "Date formatting to use. ISO by default",
                    "example": "YYYY-MM-DD hh:mm:ss"
                  },
                  "data": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "description": "Data to provide, as a matrix"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "File to upload",
                    "example": "... (Binary data) ..."
                  },
                  "file_name": {
                    "type": "string",
                    "description": "Name of the file",
                    "example": "data.csv"
                  },
                  "replace": {
                    "description": "Set to 'yes' in order to replace the dataset with the provided data, 'no' in order to append the provided data",
                    "type": "string",
                    "enum": [
                      "yes",
                      "no"
                    ]
                  },
                  "pk": {
                    "type": "string",
                    "description": "Private key (optional) to use to orevent duplicates",
                    "example": "_id"
                  },
                  "date_format": {
                    "type": "string",
                    "description": "Date formatting to use. ISO by default",
                    "example": "YYYY-MM-DD hh:mm:ss"
                  },
                  "separator": {
                    "type": "string",
                    "example": ",",
                    "description": "Separator for CSV files"
                  },
                  "quotes": {
                    "type": "string",
                    "example": "\"",
                    "description": "Quotes for CSV files"
                  },
                  "csv_header": {
                    "type": "string",
                    "description": "Specifies if the CSV file has headers",
                    "enum": [
                      "yes",
                      "no"
                    ]
                  },
                  "json_fields": {
                    "type": "string",
                    "description": "List of fields to parse for JSON files.",
                    "example": "field0,field1,field2"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_PARAM",
                        "NO_FILE"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "delete": {
        "description": "Updates a data source.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "where",
            "description": "Conditions to match (filter), as a JSON of QueryTree (see schemas for more information)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_PARAM",
                        "NO_FILE"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/external/source/update": {
      "post": {
        "description": "Updates an external source, so that its automations run and its cache is cleared. You can include up to 100 instances to analize in the body.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "x-public-key",
            "description": "External source public key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-secret-key",
            "description": "External source secret key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  }
                },
                "description": "Data to provide, as a matrix"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Busy. You will receive this response by trying to update with multiple requests in parallel."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/emails": {
      "get": {
        "description": "Lists the emails to send workspace notifications",
        "tags": [
          "emails"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                      },
                      "email": {
                        "type": "string",
                        "example": "user@example.com"
                      },
                      "validated": {
                        "type": "boolean",
                        "description": "True if the address receives the notices now: a current member of the organization who can read the workspace, or an outside address that confirmed (double opt-in)"
                      },
                      "status": {
                        "type": "string",
                        "enum": [
                          "member",
                          "confirmed",
                          "pending",
                          "unsubscribed",
                          "no_access"
                        ],
                        "description": "member: a member who can read the workspace; confirmed: an outside address that confirmed; pending: an outside address that must still confirm (it receives only the confirmation email); unsubscribed: the person stopped the notices with the link of an email; no_access: an AIR-Core account that cannot read the workspace (it receives nothing and is never asked to confirm)"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Adds new email to send notifications",
        "tags": [
          "emails"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "type": "string",
                    "example": "user@example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "id": {
                      "type": "string",
                      "description": "ID of the email created (or of the one already there, adding an address twice changes nothing)."
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "member",
                        "confirmed",
                        "pending",
                        "unsubscribed",
                        "no_access"
                      ],
                      "description": "What the address receives now. An outside address gets a confirmation email (at most one per address and day) and nothing else until it confirms."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST",
                        "BAD_EMAIL",
                        "TOO_MANY"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/emails/{mailId}": {
      "delete": {
        "description": "Deletes the email from the list",
        "tags": [
          "emails"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mailId",
            "description": "Identifier of the mail",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/visualizations": {
      "get": {
        "description": "Lists the visualizations of a workspace",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "description": "Requested page (starts with 0)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "limit",
            "description": "Max number of items per page (max 500)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "page": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Current page"
                    },
                    "limit": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Max items per page"
                    },
                    "pages_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of pages"
                    },
                    "items_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of items"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                          },
                          "created": {
                            "type": "string",
                            "description": "Creation date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_modified": {
                            "type": "string",
                            "description": "Last modification date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_access": {
                            "type": "string",
                            "description": "Last access date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "name": {
                            "type": "string",
                            "example": "Visualization name"
                          },
                          "description": {
                            "type": "string",
                            "example": "Visualization description"
                          },
                          "type": {
                            "type": "string",
                            "example": "line",
                            "description": "Visualization type"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Creates a visualization",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Visualization name (Max 120 characters)",
                    "example": "Visualization name"
                  },
                  "description": {
                    "type": "string",
                    "example": "Visualization description"
                  },
                  "privacy": {
                    "type": "string",
                    "enum": [
                      "public",
                      "private"
                    ],
                    "description": "Visualization privacy"
                  },
                  "source": {
                    "type": "string",
                    "description": "Visualization data source (ID)",
                    "example": "xxxx-xxxx-xxxx-xxxx"
                  },
                  "configuration": {
                    "$ref": "#/components/schemas/VisualizationConfig"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "visualization_id": {
                      "type": "string",
                      "description": "ID of the new visualization",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_SOURCE",
                        "BAD_CONFIG"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/visualization/{visualizationId}": {
      "get": {
        "description": "Gets visualization data",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "visualizationId",
            "description": "Identifier of the visualization",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "created": {
                      "type": "string",
                      "description": "Creation date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_modified": {
                      "type": "string",
                      "description": "Last modification date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_access": {
                      "type": "string",
                      "description": "Last access date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "name": {
                      "type": "string",
                      "example": "Visualization name"
                    },
                    "description": {
                      "type": "string",
                      "example": "Visualization description"
                    },
                    "type": {
                      "type": "string",
                      "example": "line",
                      "description": "Visualization type"
                    },
                    "public": {
                      "type": "boolean",
                      "description": "True if the visualization is public"
                    },
                    "source": {
                      "type": "string",
                      "description": "ID of the data surce",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "configuration": {
                      "$ref": "#/components/schemas/VisualizationConfig"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "post": {
        "description": "Modifies visualization",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "visualizationId",
            "description": "Identifier of the visualization",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Visualization name (Max 120 characters)",
                    "example": "Visualization name"
                  },
                  "description": {
                    "type": "string",
                    "example": "Visualization description"
                  },
                  "privacy": {
                    "type": "string",
                    "enum": [
                      "public",
                      "private"
                    ],
                    "description": "Visualization privacy"
                  },
                  "source": {
                    "type": "string",
                    "description": "Visualization data source (ID)",
                    "example": "xxxx-xxxx-xxxx-xxxx"
                  },
                  "configuration": {
                    "$ref": "#/components/schemas/VisualizationConfig"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_SOURCE",
                        "BAD_CONFIG"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "delete": {
        "description": "Deletes visualization",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "visualizationId",
            "description": "Identifier of the visualization",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/visualization/{visualizationId}/dependents": {
      "get": {
        "description": "Dependency map of a visualization, to check before editing or deleting it: the dashboards that show it (up to 50, `more` counts the rest). Without `read_dashboards`, the group keeps its count with `hidden: true` and no items.",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "visualizationId",
            "description": "Identifier of the visualization",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VisualizationLineage"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "ACCESS_DENIED"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/visualization/{visualizationId}/clone": {
      "post": {
        "description": "Clones visualization",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "visualizationId",
            "description": "Identifier of the visualization",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Visualization name (Max 120 characters)",
                    "example": "Visualization name"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "visualization_id": {
                      "type": "string",
                      "description": "ID of the new visualization",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_SOURCE"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboards": {
      "get": {
        "description": "Lists the dashboards of a workspace",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "description": "Requested page (starts with 0)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "limit",
            "description": "Max number of items per page (max 500)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "page": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Current page"
                    },
                    "limit": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Max items per page"
                    },
                    "pages_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of pages"
                    },
                    "items_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of items"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                          },
                          "created": {
                            "type": "string",
                            "description": "Creation date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_modified": {
                            "type": "string",
                            "description": "Last modification date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_access": {
                            "type": "string",
                            "description": "Last access date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "name": {
                            "type": "string",
                            "example": "Dashboard name"
                          },
                          "description": {
                            "type": "string",
                            "example": "Dashboard description"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Creates new dashboard",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Dashboard name (Max 120 characters)",
                    "example": "Dashboard name"
                  },
                  "description": {
                    "type": "string",
                    "example": "Dashboard description"
                  },
                  "privacy": {
                    "type": "string",
                    "enum": [
                      "public",
                      "private"
                    ],
                    "description": "Dashboard privacy"
                  },
                  "shareOpt": {
                    "type": "string",
                    "description": "Option for the shared dashboard GUI",
                    "enum": [
                      "",
                      "controls",
                      "clean"
                    ]
                  },
                  "gaId": {
                    "type": "string",
                    "description": "Optional Google Analitycs ID"
                  },
                  "restricted": {
                    "type": "boolean",
                    "description": "True to check for explicit permission forshared dashboards"
                  },
                  "configuration": {
                    "type": "object",
                    "description": "Dashboard configuration"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "dashboard_id": {
                      "type": "string",
                      "description": "ID of the new dashboard",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_CONFIG"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboards/auto": {
      "post": {
        "description": "Builds a dashboard automatically from a source: picks indicators and charts from its columns, creates the visualizations and the dashboard, and returns them. Used by the MCP tool `build_dashboard`.",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "source"
                ],
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "Identifier of the source."
                  },
                  "name": {
                    "type": "string",
                    "description": "Optional name of the dashboard."
                  },
                  "metric": {
                    "type": "string",
                    "description": "Optional column to measure (name)."
                  },
                  "dimension": {
                    "type": "string",
                    "description": "Optional column to break down by (name)."
                  },
                  "date": {
                    "type": "string",
                    "description": "Optional date column (name)."
                  },
                  "sources": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 5 sources, each one in its own section (the first is `source`). A text with the identifiers separated by commas is accepted too."
                  },
                  "lang": {
                    "type": "string",
                    "description": "Language of the texts (es, en, cat).",
                    "example": "es"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dashboard created with its visualizations."
          },
          "400": {
            "description": "Bad request"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied or plan limit"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/catalog": {
      "get": {
        "description": "The catalogue of a data source («Ficha»): what its data mean. The description, the person in charge (steward), tags and provenance (origin and update process written by people, the sources of the workspace it is obtained from, and what AIR-Core knows in `computed`: kind of origin, automatic updates, parent sources and model). Per field, in the order of the source: description, unit, kind of value (semantic_type), allowed values or range (informative) and its personal data, the one found and chosen in the AI governance (never changed here). `ai_withheld` lists the texts an AI would not receive because the detector of personal data finds some in them. An AI application connected through MCP (and the built-in assistant) gets it as an AI may see it: never the person in charge nor who saved it, the flagged texts empty and listed in `withheld_for_ai`, no allowed values nor ranges below the level «aggregates» of the AI data policy, and `personal_data` as not_sent, pseudonymised or allowed. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The catalogue (empty values when the source has none)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceCatalog"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      },
      "put": {
        "description": "Changes the catalogue of a data source. Only the keys sent change: an empty text, null or an empty list clears a value, and null for a field clears its whole entry. `fields` is an object by field name or a list of entries with `name` or `index`. Unknown keys or fields, texts too long and kinds of value that do not exist are refused (400), never cut. `provenance.derived_from` names other sources of the same workspace. The data of the source and its personal data choices are not changed. Needs a token that writes workspaces and permission to edit the source (or to own it). Answers the catalogue as GET does.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SourceCatalogChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The catalogue as it is left",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceCatalog"
                }
              }
            }
          },
          "400": {
            "description": "BAD_REQUEST, UNKNOWN_KEY, UNKNOWN_FIELD (details.fields), BAD_FIELD_ENTRY, BAD_SEMANTIC_TYPE, BAD_RANGE, BAD_DESCRIPTION, BAD_UNIT, BAD_TAGS, BAD_STEWARD, BAD_ORIGIN, BAD_UPDATE_PROCESS, BAD_ALLOWED_VALUES, BAD_DERIVED_FROM or BAD_PROVENANCE"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED: without permission to edit the source), or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sources/join/suggest": {
      "post": {
        "description": "Suggested keys to join a main data source with 1 to 5 other sources of the workspace (for a join of several sources, derived_type join_multi). For each lookup, up to 5 pairs of columns ordered by confidence: by names and types (the join the data advisor proposes, the same name), by the catalogue of both sources when it says something (the same kind of value helps; different kinds of value or units count against and are noted) and by the values in common measured on samples: `overlap` is the share of the first 1000 rows of the main source whose value is in the lookup (up to 30000 rows of it read, compared as the join compares keys), `lookup_unique` how unique the column is in the lookup (1: one row per key). `suggested` is the pair to start with, two pairs when one column alone repeats in the lookup and both together do not. For an AI application connected through MCP below the level «aggregates» of the AI data policy: by names, types and catalogue only, nothing read (`measured` false). Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "main",
                  "lookups"
                ],
                "properties": {
                  "main": {
                    "type": "string",
                    "description": "Identifier of the main source"
                  },
                  "lookups": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 5,
                    "description": "Identifiers of the sources to join with it (the same one may repeat)",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The suggested keys",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JoinKeySuggestions"
                }
              }
            }
          },
          "400": {
            "description": "BAD_REQUEST, NOT_FOUND (a source that is not in the workspace), EXTERNAL (external and real time sources cannot be joined) or TOO_MANY_SOURCES"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/join-report": {
      "get": {
        "description": "The report of the last run (creation or refresh) of a join of several sources (derived_type join_multi), and a short history of the earlier runs (the last 10 are kept). Per lookup: rows of the main source that found a row in it and that did not (`unmatched`, with `unmatched_empty` for empty keys, which never match), the match rate, up to 20 different example keys without a match, rows of the lookup read, keys kept, repeated keys (only the first row of a repeated key is used, rows are never multiplied) with examples, and keys no row used. The names of the sources are the ones they have now. For an AI application connected through MCP, the example keys of key columns with personal data the organization does not share with AI applications are left out (`examples_withheld`, `duplicate_examples_withheld`). Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the source made by the join",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JoinReportView"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found, or NOT_A_JOIN: the source is not a join of several sources"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/recipe": {
      "get": {
        "description": "The recipe of a prepared source («fuente preparada»): its origin (and the origin's columns), the steps (columns named by name), the columns they give, whether they still fit the origin as it is now (`check`: the first step that does not, and why), the version of the recipe, who changed it and when, and what each step did in the last recomputation (`last_report`; or the step that failed, when the prepared source kept its previous data). A prepared source is created with POST .../sources/derived (derived_type recipe) and recomputed each time its origin updates; the origin is never changed. An AI application connected through MCP gets the values written in steps about a column with personal data not sent in clear withheld (`withheld: true` on the step) and, below the level «aggregates» of the AI data policy, no counts of rows. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the prepared source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The recipe",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Recipe"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found, or NOT_A_RECIPE: the source is not prepared with a recipe"
          }
        }
      },
      "post": {
        "description": "Replaces the steps of a prepared source (the whole list, in order) and asks for its recomputation from its origin with them (it runs in the background within seconds). The steps are checked first against the columns of the origin as it is now: when one cannot be used nothing is saved and `details` says which (step from 0, code, column). The origin is not changed. Needs a token that writes workspaces and permission to edit the source (or to own it) and to run tasks. Answers the recipe as GET does.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the prepared source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "steps"
                ],
                "properties": {
                  "steps": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "$ref": "#/components/schemas/RecipeStep"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recipe as it is left (recipe_version + 1, pending true)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Recipe"
                }
              }
            }
          },
          "400": {
            "description": "RECIPE_STEPS_INVALID, RECIPE_TOO_MANY_STEPS, RECIPE_TOO_LONG, RECIPE_COLUMN_MISSING, RECIPE_COLUMN_EXISTS, RECIPE_STEP_TYPE, RECIPE_STEP_INVALID, RECIPE_EXPRESSION_INVALID (with details: step, op, code, column, message) or ORIGIN_MISSING"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED: without permission to edit the source and run tasks), or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found, or NOT_A_RECIPE"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/recipe/preview": {
      "post": {
        "description": "Tries some steps over the first rows of a source (the origin of a recipe) without saving anything: for each step the columns, the rows in and out, the cells changed (or rows removed), the values left empty and the first resulting rows; `error` is the first step that cannot be used (the steps before it are given). The first steps, when they are filters, are applied by the storage when the rows are read. Regular expressions run with a time limit (RECIPE_REGEX_TIMEOUT in `error`). For an AI application connected through MCP: only when the AI data policy lets rows go, each column protected as the strictest rule of the columns of the origin it comes from, and refused (AI_POLICY_PERSONAL_DATA) when a filter, a cleaning of only some rows or a removal of duplicates uses a column with personal data not sent in clear. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the origin source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "steps": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "$ref": "#/components/schemas/RecipeStep"
                    }
                  },
                  "sample": {
                    "type": "integer",
                    "description": "Rows of the origin read (default 200, at most 500)"
                  },
                  "rows": {
                    "type": "integer",
                    "description": "Rows given after each step (default 10, at most 50)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecipePreview"
                }
              }
            }
          },
          "400": {
            "description": "RECIPE_STEPS_INVALID, RECIPE_TOO_MANY_STEPS, RECIPE_TOO_LONG or EXTERNAL (external and real-time sources cannot be prepared)"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/text-analysis": {
      "get": {
        "description": "«Analizar textos»: what the AI module of this installation offers for texts (`available`; the tasks, languages, summaries and topics it advertises: gimodeler 0.21, `methods.text-annotate`, `text-summarize`, `text-topics`; with an older AI module everything is unavailable and nothing else changes), the caps of the plan of the organization (`limits`: texts per analysis, analyses per month, re-application when the data change, entities, topics over time, most topics, own classifiers, texts generative AI labels in one run; -1 = no limit), what it used this month (`usage`) and whether the labels with generative AI can be used (`labels.code` GENAI_PLAN_REQUIRED: a paid plan, AI credit or the organization's own AI key). Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What can be used and the caps of the plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAnalysisInfo"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/text-analysis": {
      "get": {
        "description": "The analysis of texts of a source made with POST .../sources/derived (derived_type text_analysis): its origin and column, the tasks, the language, the column of dates, its topics model and text classifiers, the columns it writes, the last run (`last_report`), whether a run is waiting or running, whether the origin changed and the plan does not apply it by itself (`stale`), the caps of the plan and the «Resumen del análisis» (`overview`: texts analysed and skipped by the cap of the plan, languages, sentiment and its evolution by period, keywords, entities, people, topics with their words, share and examples, labels of each classifier, examples of each sentiment, notes). For any other source: `analysis: null`, whether it can be analysed (`can_create`) and its columns (`text`: a column that can be analysed). For an AI application connected through MCP: the figures, keywords, entities and topics (aggregates); the examples and the people only when the AI data policy lets rows go and the analysed column has no personal data held back; at the level «structure», only the settings. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The analysis, or what can be analysed in the source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAnalysisOf"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/text-analysis/reanalyze": {
      "post": {
        "description": "«Volver a analizar»: asks for a new run of an analysis of texts now (within seconds, in the background), with the rows its origin has now. It counts as an analysis of the month (TEXT_ANALYSIS_LIMIT, 403, when the plan's are used up). Needs a token that writes workspaces and permission to edit the source (or to own it) and to run tasks. Answers the analysis as GET does (pending true).",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the analysis source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, analysis, can_edit}",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string"
                    },
                    "analysis": {
                      "$ref": "#/components/schemas/TextAnalysis"
                    },
                    "can_edit": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "NOT_A_TEXT_ANALYSIS"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, TEXT_ANALYSIS_LIMIT (the analyses of the month of the plan are used; details.offer upgrade) or the AI data policy (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/text-analysis/preview": {
      "post": {
        "description": "The analysis of the first rows of a source (at most 20) without writing or counting anything: for each text its language, sentiment (label, value written in the column, score), keywords and entities (entities only when the plan includes them). `plan` says how many texts a whole analysis would read and whether the cap of the plan would stop it. For an AI application connected through MCP: only when the AI data policy lets rows go, and refused (AI_POLICY_PERSONAL_DATA) when the column has personal data not sent in clear. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "column"
                ],
                "properties": {
                  "column": {
                    "type": "string",
                    "description": "Name of the column of texts (text or nominal)"
                  },
                  "tasks": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "language",
                        "sentiment",
                        "keywords",
                        "entities",
                        "topics"
                      ]
                    },
                    "description": "Default language, sentiment, keywords; topics are found over every text when the analysis runs, never in a preview"
                  },
                  "language": {
                    "type": "string",
                    "description": "auto (default) or es, en, ca, de, fr, it, pt, ja, zh"
                  },
                  "keywords_top": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 20
                  },
                  "rows": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAnalysisPreview"
                }
              }
            }
          },
          "400": {
            "description": "TEXT_COLUMN_MISSING, TEXT_TASKS_INVALID, TEXT_LANGUAGE_INVALID, EXTERNAL or an error of the AI module (TEXT_ENGINE_BAD_REQUEST)"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          },
          "503": {
            "description": "TEXT_ENGINE_OUTDATED (the AI module cannot analyse texts) or TEXT_ENGINE_UNAVAILABLE"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/text-analysis/summarize": {
      "post": {
        "description": "The sentences that best sum up a group of texts of a source (extractive: sentences of the texts themselves, chosen by the AI module with TextRank; no generative AI): the texts of a sentiment, a topic or a keyword of an analysis of texts, or of a value of a column; at most `max_texts` texts (the first ones). For an AI application connected through MCP: only when the AI data policy lets rows go, and refused (AI_POLICY_PERSONAL_DATA) when the column (in the source or in the origin of the analysis) has personal data not sent in clear. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the source (an analysis of texts",
            "or another one with column)": null,
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "column": {
                    "type": "string",
                    "description": "Name of the column of texts (default: the analysed one)"
                  },
                  "group": {
                    "type": "object",
                    "description": "Which texts (none: the first ones of the source)",
                    "properties": {
                      "sentiment": {
                        "type": "string",
                        "enum": [
                          "positive",
                          "neutral",
                          "negative"
                        ]
                      },
                      "topic": {
                        "type": "string",
                        "description": "The topic as its column writes it"
                      },
                      "keyword": {
                        "type": "string"
                      },
                      "column": {
                        "type": "string"
                      },
                      "value": {
                        "description": "A value of that column (null: the empty ones)"
                      }
                    }
                  },
                  "sentences": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10,
                    "description": "Default 3"
                  },
                  "max_texts": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500,
                    "description": "Default 200"
                  },
                  "language": {
                    "type": "string",
                    "description": "auto (the most frequent language of the texts) or a code"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{column, group, texts (texts read), sentences: [{text, score}]}",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "column": {
                      "type": "string"
                    },
                    "group": {
                      "type": "object"
                    },
                    "texts": {
                      "type": "integer"
                    },
                    "sentences": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "text": {
                            "type": "string"
                          },
                          "score": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "TEXT_COLUMN_MISSING, TEXT_GROUP_INVALID (the source has no column for that group), EXTERNAL"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          },
          "503": {
            "description": "TEXT_ENGINE_OUTDATED (the AI module cannot summarize texts) or TEXT_ENGINE_UNAVAILABLE"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/topics-model/{modelId}": {
      "get": {
        "description": "A topics model (model type topics: made by an analysis of texts with the task topics, or by the goal «Temas en textos» of the model wizard): its column of texts and of dates, language, method, number of topics and each topic with the name people gave it (or its first words), its words with their weight, its texts and its share; with a column of dates, the share of each topic by period (`prevalence`). Needs a token that reads workspaces and permission to read the models.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the topics model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The topics model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopicsModel"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace not found, or NOT_FOUND: not a topics model of the workspace"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/rows": {
      "get": {
        "description": "Rows of a data source with their row ids (`ids`, parallel to `instances`), to edit them in place. For an AI application connected through MCP, rows only when the AI data policy of the organization allows them, with the personal data protected. The routes of `/instances` do not change.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "where",
            "description": "Filter, as a JSON of QueryTree (`filter` is accepted too)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order_by",
            "description": "Index of the feature to sort by and 'asc' or 'desc'",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "2,desc"
            }
          },
          {
            "name": "select",
            "description": "Indexes of the features to return (all by default)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "0,2"
            }
          },
          {
            "name": "offset",
            "description": "Rows to skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "limit",
            "description": "Rows to return (default 100, at most 500)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The rows",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "features": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "index": {
                            "type": "integer"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "date_format": {
                            "type": "string"
                          },
                          "calculated": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "instances": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": {}
                      }
                    },
                    "ids": {
                      "type": "array",
                      "nullable": true,
                      "description": "Row ids (null when the storage does not give them: an older storage, a real-time source)",
                      "items": {
                        "type": "string"
                      }
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "next_offset": {
                      "type": "integer",
                      "nullable": true
                    },
                    "editable": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string",
                      "description": "Why it cannot be edited: PERMISSION, EXTERNAL, REAL_TIME, ARCHIVED, STORAGE_OLD; empty when it can"
                    },
                    "update_effect": {
                      "type": "string",
                      "enum": [
                        "none",
                        "replace",
                        "append",
                        "append_update_keys",
                        "derived"
                      ],
                      "description": "What the next scheduled update does to edited rows"
                    },
                    "undo": {
                      "$ref": "#/components/schemas/SourceUndoState"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_FILTER"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "post": {
        "description": "Edits rows in place, as a spreadsheet: an ordered list of operations (set a cell, insert rows, delete rows by row id), all or nothing, at most 1000 operations or rows. Calculated columns are computed again when their expression only reads values of the row. Needs a token that writes workspaces and permission to edit the source (or to own it) and to run tasks.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "ops"
                ],
                "properties": {
                  "ops": {
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "properties": {
                        "op": {
                          "type": "string",
                          "enum": [
                            "set",
                            "insert",
                            "delete"
                          ]
                        },
                        "rid": {
                          "type": "string",
                          "description": "set: row id"
                        },
                        "feature": {
                          "type": "integer",
                          "description": "set: index of the feature"
                        },
                        "value": {
                          "description": "set: new value (null empties it)"
                        },
                        "rids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "delete: row ids"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "array",
                            "items": {}
                          },
                          "description": "insert: rows, one value per feature"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied ({result: success, applied, inserted: {tempId: rid}, missing, counts, version, instances, calculated?}), or refused with result error and code VALUE, UNIQUE, OPS_LIMIT, LIMIT or STORAGE_OLD"
          },
          "400": {
            "description": "OPS (malformed) or NOT_EDITABLE"
          },
          "403": {
            "description": "Access denied"
          },
          "409": {
            "description": "BUSY: a task or another edit has the source"
          },
          "504": {
            "description": "TIMEOUT: nothing was changed"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/columns/{feature}/transform": {
      "post": {
        "description": "Cleans a column in place (all rows, or those of the filter). With dry_run, only how many cells would change and a sample before and after (nothing is written). The version before the cleaning is kept for 24 hours (it counts in the size of the organization meanwhile) and `undo` restores it. Operations by type of column: text trim {collapse}, lower, upper, capitalize, replace {find, replace, mode contains|exact, case}, regex_replace {pattern (at most 500 characters), replace, case}, prefix|suffix {text}, fill_empty {value}, to_null {value}, merge_values {values: [{from, to}]} (each cell that is exactly `from`, same case and spaces, becomes `to`: the merge of the groups of GET .../columns/{feature}/variants, at most 500 pairs; no `to` may also be a `from`; it is one operation with one undo, its preview counts the rows of each value); numbers round {decimals 0-10}, multiply|add {value}, clip {min, max}, abs, fill_empty {value}; dates shift {ms}, fill_empty {value}; booleans invert, fill_empty {value}.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "feature",
            "description": "Index of the column",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "op"
                ],
                "properties": {
                  "op": {
                    "type": "string",
                    "enum": [
                      "trim",
                      "lower",
                      "upper",
                      "capitalize",
                      "replace",
                      "regex_replace",
                      "prefix",
                      "suffix",
                      "fill_empty",
                      "to_null",
                      "round",
                      "multiply",
                      "add",
                      "clip",
                      "abs",
                      "shift",
                      "invert",
                      "merge_values"
                    ]
                  },
                  "args": {
                    "type": "object",
                    "description": "Arguments of the operation"
                  },
                  "filter": {
                    "$ref": "#/components/schemas/QueryTree"
                  },
                  "dry_run": {
                    "type": "boolean",
                    "description": "Only the preview: {changed, sample: [{rid, before, after}]} (at most 20)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{result: success, changed, version, instances, undo, calculated?} (with dry_run: {dry_run: true, changed, sample}); refused with result error and code STORAGE_OLD, VALUE, UNIQUE or LIMIT"
          },
          "400": {
            "description": "FEATURE, OP, ARGS, INVALID_FILTER, FILTER, UNSUPPORTED or NOT_EDITABLE"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "409": {
            "description": "BUSY"
          },
          "504": {
            "description": "TIMEOUT"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/columns/{feature}/profile": {
      "get": {
        "description": "Profile of a column computed by the storage over every row (or those of the filter): rows, nulls, empty texts, distinct values, the 10 most frequent values and min, max and average (numbers; min and max of dates). With duplicates, also how many rows repeat an earlier row (what `dedupe` would delete).",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "feature",
            "description": "Index of the column",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "where",
            "description": "Filter, as a JSON of QueryTree",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "duplicates",
            "description": "'all' (whole rows) or a JSON list of feature indexes",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The profile",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "feature": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "nulls": {
                      "type": "integer"
                    },
                    "empty": {
                      "type": "integer"
                    },
                    "distinct": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "value": {},
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "min": {},
                    "max": {},
                    "avg": {
                      "type": "number"
                    },
                    "duplicates_rows": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "FEATURE, INVALID_FILTER or UNSUPPORTED (external and real-time sources)"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/columns/{feature}/variants": {
      "get": {
        "description": "«Agrupar variantes», without AI and without credits (free plan too): groups of values of a text column (nominal or text) that are the same thing written differently («Madrid», «madrid », «Mádrid», «Madriz»; «C/ Mayor» and «Calle Mayor»). Values are normalised (case, accents, spaces, punctuation and, with abbreviations, a small list of abbreviations) and compared with a similarity (the mean of Jaro-Winkler and the normalised Levenshtein similarity; texts whose numbers differ never match; texts shorter than 4 characters only match when equal). It works on the DISTINCT values of the column with their counts: the storage says how many there are (`distinct`, column_profile); up to 200 it counts every one of them (`method: histogram`, no row is read); with more, only this column is read by streaming (`method: stream`) up to the rows of the plan (200,000 free, 1,000,000 paid, 2,000,000 without limits; `estimated` only when not every row was read) and the most frequent values are compared, up to the cap of the plan (2,000 free, 10,000 paid, 20,000 without limits; `truncated` when the column has more: `values` of `distinct`). Each group has its proposed canonical value (the most frequent), its values with their rows and similarity to it, and `suggested` for those proposed for the merge. `merge_args` are the arguments of POST .../columns/{feature}/transform with op `merge_values` that merges the suggested values. For an AI application connected through MCP: refused (AI_POLICY_PERSONAL_DATA) on a column, or with a filter, with personal data it may not see.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "feature",
            "description": "Index of the column (nominal or text)",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "threshold",
            "description": "Least similarity to group, from 0.5 to 1 (default 0.85; 1 = only the same normalised form)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0.5,
              "maximum": 1
            }
          },
          {
            "name": "abbreviations",
            "description": "Expand the small list of abbreviations (c/, avda., pza., ctra., ayto., sta.…) before comparing (default true)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "where",
            "description": "Filter, as a JSON of QueryTree",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The groups of variants",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "feature": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "threshold": {
                      "type": "number"
                    },
                    "abbreviations": {
                      "type": "boolean"
                    },
                    "rows": {
                      "type": "integer",
                      "description": "Rows with a value among the values compared"
                    },
                    "values": {
                      "type": "integer",
                      "description": "Distinct values compared"
                    },
                    "distinct": {
                      "type": "integer",
                      "nullable": true,
                      "description": "Distinct non-empty values the column has (of the rows of the filter); null when the storage cannot say"
                    },
                    "method": {
                      "type": "string",
                      "enum": [
                        "histogram",
                        "stream"
                      ],
                      "description": "histogram: the storage counted every value (200 or fewer); stream: only this column was read"
                    },
                    "rows_read": {
                      "type": "integer"
                    },
                    "rows_total": {
                      "type": "integer",
                      "nullable": true
                    },
                    "truncated": {
                      "type": "boolean",
                      "description": "The column has more distinct values than were compared (the cap of the plan): the most frequent were"
                    },
                    "estimated": {
                      "type": "boolean",
                      "description": "Not every row was read (the cap of rows of the plan, or 25 s): the counts are of the rows read"
                    },
                    "partial": {
                      "type": "boolean",
                      "description": "Some candidate pairs were not compared (cap of comparisons of the plan)"
                    },
                    "groups_total": {
                      "type": "integer"
                    },
                    "changes": {
                      "type": "integer",
                      "description": "Rows the suggested merges would change"
                    },
                    "groups": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "canonical": {
                            "type": "string"
                          },
                          "rows": {
                            "type": "integer"
                          },
                          "changes": {
                            "type": "integer"
                          },
                          "values": {
                            "type": "array",
                            "items": {
                              "properties": {
                                "value": {
                                  "type": "string"
                                },
                                "count": {
                                  "type": "integer"
                                },
                                "similarity": {
                                  "type": "number"
                                },
                                "canonical": {
                                  "type": "boolean"
                                },
                                "suggested": {
                                  "type": "boolean"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "merge_args": {
                      "properties": {
                        "values": {
                          "type": "array",
                          "items": {
                            "properties": {
                              "from": {
                                "type": "string"
                              },
                              "to": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "caps": {
                      "properties": {
                        "distinct_values": {
                          "type": "integer"
                        },
                        "rows": {
                          "type": "integer"
                        },
                        "comparisons": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "FEATURE, TYPE (not a text column), ARGS, INVALID_FILTER, UNSUPPORTED (external and real-time sources) or STORAGE_OLD"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/near-duplicates": {
      "get": {
        "description": "«Filas casi duplicadas», without AI and without credits (free plan too): clusters of rows that are almost the same in some columns (the same customer with small differences). Each row is the set of the character 3-grams of the normalised values of those columns (tagged with their column); MinHash with 64 hash functions of fixed seeds (the same answer every time) and LSH banding tuned to the threshold find the candidate pairs, kept when the exact Jaccard similarity of their 3-grams reaches the threshold; every row of a cluster is at the threshold of its first row (a chain A~B~C with A and C apart does not put C with A). Rows are read in pages with their ids from the first one, up to the cap of the plan (10,000 rows free, 100,000 paid, 200,000 without limits) or `max_rows`, and for 25 seconds at most: `estimated` (and `stopped`: cap or time) when not every row was read. Each cluster has its rows (row id, cells of the compared columns, `differs`: positions of the cells that differ from the first row, similarity to it) and a QueryTree `filter` that shows them in a table (null when too long). Nothing is deleted: remove the extra rows with POST .../rows (delete by row id), kept in the version history. For an AI application connected through MCP: rows (the policy must let rows go), refused over columns with personal data it may not see.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "features",
            "description": "Indexes of the columns compared, separated by commas or as a JSON list (default: every column that is not calculated, up to 20)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "threshold",
            "description": "Least estimated Jaccard similarity, from 0.5 to 1 (default 0.8)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0.5,
              "maximum": 1
            }
          },
          {
            "name": "abbreviations",
            "description": "Expand the small list of abbreviations before comparing (default true)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "max_rows",
            "description": "Rows to read at most (never more than the cap of the plan)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The clusters of near-duplicate rows",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "features": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      }
                    },
                    "names": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "threshold": {
                      "type": "number"
                    },
                    "abbreviations": {
                      "type": "boolean"
                    },
                    "rows_read": {
                      "type": "integer"
                    },
                    "rows_total": {
                      "type": "integer"
                    },
                    "estimated": {
                      "type": "boolean"
                    },
                    "stopped": {
                      "type": "string",
                      "enum": [
                        "",
                        "cap",
                        "time"
                      ]
                    },
                    "partial": {
                      "type": "boolean",
                      "description": "Some candidate pairs were not confirmed (cap of the plan)"
                    },
                    "ids": {
                      "type": "boolean",
                      "description": "The rows have their ids (they can be removed with POST .../rows)"
                    },
                    "clusters_total": {
                      "type": "integer"
                    },
                    "rows_in_clusters": {
                      "type": "integer"
                    },
                    "removable": {
                      "type": "integer",
                      "description": "Rows left over keeping the first of each cluster"
                    },
                    "clusters": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "size": {
                            "type": "integer"
                          },
                          "filter": {
                            "$ref": "#/components/schemas/QueryTree"
                          },
                          "rows": {
                            "type": "array",
                            "items": {
                              "properties": {
                                "position": {
                                  "type": "integer"
                                },
                                "rid": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "cells": {
                                  "type": "array",
                                  "items": {}
                                },
                                "differs": {
                                  "type": "array",
                                  "items": {
                                    "type": "integer"
                                  }
                                },
                                "similarity": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "caps": {
                      "properties": {
                        "rows": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "FEATURE, ARGS, UNSUPPORTED (external and real-time sources) or STORAGE_OLD"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Not found"
          },
          "429": {
            "description": "BUSY: other searches of near duplicates are running"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/dedupe": {
      "post": {
        "description": "Removes the rows that repeat the values of some features (whole rows when none are given; nulls equal), keeping the first or the last of each group. With dry_run, only how many rows it would delete. The version before is kept for 24 hours and `undo` restores it.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "features": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "keep": {
                    "type": "string",
                    "enum": [
                      "first",
                      "last"
                    ]
                  },
                  "dry_run": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{result: success, deleted, version, instances, undo} (with dry_run: {dry_run: true, deleted}); refused with result error and code STORAGE_OLD or LIMIT"
          },
          "400": {
            "description": "FEATURE, ARGS, UNSUPPORTED (CrateDB sources) or NOT_EDITABLE"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "409": {
            "description": "BUSY"
          },
          "504": {
            "description": "TIMEOUT"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/undo": {
      "post": {
        "description": "Undoes the last cleaning of a column or removal of duplicates: puts back the version kept before it, within 24 hours and while nothing else changed the source (UNDO_GONE otherwise). The current version is deleted.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, version, instances, undone}"
          },
          "403": {
            "description": "Access denied"
          },
          "409": {
            "description": "UNDO_GONE or BUSY"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/detach": {
      "post": {
        "description": "Turns a derived source (filter, join, merge, extend, aggregate, the predictions of a model, a forecast) into an independent stored source: the data stays, its update configuration stops being derived and its parents no longer refresh it. Needs permission to edit the source (or to own it).",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, update_effect: none, detached: {at, derived_type, derived_from, derived_from2, model}}"
          },
          "400": {
            "description": "NOT_DERIVED"
          },
          "403": {
            "description": "Access denied"
          },
          "409": {
            "description": "BUSY"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/versions": {
      "get": {
        "description": "The version history of the data of the source, the newest first: who made each version, when and how (kind: import, update, delete_rows, update_rows, columns, edit, clean, dedupe, restore, previous), its rows and size, and whether its data is kept (restorable). policy says what the organization keeps: keep (previous versions, 0 = no history), max (of its plan), auto_hours (versions kept for sources that update by themselves; 0 = no limit) and stored (false for sources in a CrateDB database: the history records who and when but keeps no data). Kept versions count in the size of the organization. Needs to read the sources of the workspace.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, policy: {keep, max, auto_hours, stored}, kept_size, held_size, held_over_limit, versions: [{version, created, current, restorable, kind, task, authors: [{uid, name}], counts, note, size, instances, held_by, held_names}]}. A version something still needs (a model learned from it, a version of a model, a comparison of methods, a training running) is never deleted: held_by says how many models need it and held_names names them (the first five); it is kept, restorable and counted in held_size whatever the history keeps, and goes away by itself when nothing needs it. held_over_limit: the organization is over its size limit only because of those versions (updates of the data still work)."
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/versions/{version}/restore": {
      "post": {
        "description": "Restores a kept version of the source: a new version that is a copy of it (its rows and its columns), added to the history as kind restore; nothing is rewritten and the version before stays in the history. Same permission, limits and lock as an edit of the rows (permission to edit the source or to own it, and to run tasks).",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "description": "The version to restore, as the history gives it",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, version, instances, restored}"
          },
          "400": {
            "description": "VERSION or NOT_EDITABLE"
          },
          "403": {
            "description": "Access denied, or LIMIT"
          },
          "409": {
            "description": "VERSION_GONE (the version is not kept) or BUSY"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/visualizations/suggestions": {
      "get": {
        "description": "The visualizations AIR-Core recommends for a source from the types of its fields, the same as «Recommended for this data» in the editor of the web application: trend, breakdown, one figure against another, share, distribution, map, a heat map of two categories, the trend of each category, the weight of many categories, a key figure and the table (up to 9, the most useful first). Each one carries the configuration that draws it, ready for `POST /visualizations`. No AI and no cost. Real-time sources get none. Needs to read the sources of the workspace (`read_sources`, or a permission that makes something from them). Used by the MCP tool `suggest_visualizations`.",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "description": "Language of the names and reasons (es, en, cat); by default, the one of the request.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en",
                "cat"
              ]
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The recommendations",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "source": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/VisualizationSuggestion"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization (INVALID_AUTH_TOKEN)"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED), or the AI data policy of the organization refuses it to a connected AI application"
          },
          "404": {
            "description": "Workspace or source not found (NOT_FOUND)"
          }
        }
      },
      "post": {
        "description": "Creates, private, the recommended visualization of a key. The recommendation is computed again with the current fields of the source, so the configuration does not travel. Needs `view_create` and a token that can write, within the limits of the plan. Used by the MCP tool `create_suggested_visualization`.",
        "tags": [
          "visualizations"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string",
                    "description": "The key of the recommendation (from the GET).",
                    "example": "trend"
                  },
                  "name": {
                    "type": "string",
                    "description": "Name of the visualization (max 120); by default, the one of the recommendation."
                  },
                  "description": {
                    "type": "string",
                    "description": "Description (max 300)."
                  },
                  "lang": {
                    "type": "string",
                    "description": "Language of the default name (es, en, cat)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Visualization created",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "visualization_id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Name or description too long (BAD_NAME, BAD_DESCRIPTION)"
          },
          "401": {
            "description": "Invalid authorization (INVALID_AUTH_TOKEN)"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED) or plan limit (LIMIT)"
          },
          "404": {
            "description": "Workspace or source not found (NOT_FOUND), or no recommendation with that key for this source (SUGGESTION_NOT_FOUND; the message lists the keys)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboards/proposal": {
      "get": {
        "description": "The dashboard AIR-Core proposes for the whole workspace, to see before creating it (nothing is written), as «Proposal with the data of the project» in the web application: one section per source (up to 8, the most recently used first, archived ones left out) with the visualizations already made of it, without repeating the same chart, and, where there are few, recommended ones; on top, the name and description of the project; at the end, the metrics of the trained classifiers and regressors of those sources (only for a member who reads the models). No AI and no cost. Needs to read the sources of the workspace. Used by the MCP tool `propose_dashboard`.",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "exclude",
            "description": "Sources to leave out, separated by commas.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "models",
            "description": "`no` leaves out the metrics of the models.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "yes",
                "no"
              ]
            }
          },
          {
            "name": "lang",
            "description": "Language of the titles (es, en, cat); by default, the one of the request.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The proposal",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "proposal": {
                      "$ref": "#/components/schemas/DashboardProposal"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization (INVALID_AUTH_TOKEN)"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED), or the AI data policy of the organization refuses it to a connected AI application"
          },
          "404": {
            "description": "Workspace not found (NOT_FOUND)"
          }
        }
      },
      "post": {
        "description": "Creates, private, the proposed dashboard with the same choices as the GET, and the recommended visualizations it includes (the existing ones are reused). Needs `dashboard_create` (and `view_create` when it creates visualizations) and a token that can write, within the limits of the plan. Used by the MCP tool `create_proposed_dashboard`.",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "exclude": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Sources to leave out."
                  },
                  "models": {
                    "type": "string",
                    "description": "`no` leaves out the metrics of the models.",
                    "enum": [
                      "yes",
                      "no"
                    ]
                  },
                  "name": {
                    "type": "string",
                    "description": "Name of the dashboard (max 80); by default, the proposed one."
                  },
                  "lang": {
                    "type": "string",
                    "description": "Language of the titles (es, en, cat)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dashboard created",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "dashboard_id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "visualizations_created": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "counts": {
                      "$ref": "#/components/schemas/DashboardProposalCounts"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Name too long (BAD_NAME), or no source with data to propose (NO_SOURCES)"
          },
          "401": {
            "description": "Invalid authorization (INVALID_AUTH_TOKEN)"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED) or plan limit (LIMIT)"
          },
          "404": {
            "description": "Workspace not found (NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboard/{dashboardId}": {
      "get": {
        "description": "Gets dashboard data",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "created": {
                      "type": "string",
                      "description": "Creation date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_modified": {
                      "type": "string",
                      "description": "Last modification date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_access": {
                      "type": "string",
                      "description": "Last access date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "name": {
                      "type": "string",
                      "example": "Dashboard name"
                    },
                    "description": {
                      "type": "string",
                      "example": "Dashboard description"
                    },
                    "privacy": {
                      "type": "string",
                      "enum": [
                        "public",
                        "private"
                      ],
                      "description": "Dashboard privacy"
                    },
                    "shareOpt": {
                      "type": "string",
                      "description": "Option for the shared dashboard GUI",
                      "enum": [
                        "",
                        "controls",
                        "clean"
                      ]
                    },
                    "gaId": {
                      "type": "string",
                      "description": "Optional Google Analitycs ID"
                    },
                    "restricted": {
                      "type": "boolean",
                      "description": "True to check for explicit permission forshared dashboards"
                    },
                    "configuration": {
                      "type": "object",
                      "description": "Dashboard configuration"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "post": {
        "description": "Modifies dashboard",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Dashboard name (Max 120 characters)",
                    "example": "Dashboard name"
                  },
                  "description": {
                    "type": "string",
                    "example": "Dashboard description"
                  },
                  "privacy": {
                    "type": "string",
                    "enum": [
                      "public",
                      "private"
                    ],
                    "description": "Dashboard privacy"
                  },
                  "shareOpt": {
                    "type": "string",
                    "description": "Option for the shared dashboard GUI",
                    "enum": [
                      "",
                      "controls",
                      "clean"
                    ]
                  },
                  "gaId": {
                    "type": "string",
                    "description": "Optional Google Analitycs ID"
                  },
                  "restricted": {
                    "type": "boolean",
                    "description": "True to check for explicit permission forshared dashboards"
                  },
                  "configuration": {
                    "type": "object",
                    "description": "Dashboard configuration"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "BAD_CONFIG"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "delete": {
        "description": "Deletes dashboard",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "delete_visualizations",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "yes",
                "no"
              ]
            },
            "description": "Set it to yes to delete all associated visualizations"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboard/{dashboardId}/clone": {
      "post": {
        "description": "Clones a dashboard and its visualizations. With source_mapping, the copy reads from other sources of the workspace.",
        "tags": [
          "dashboards"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Dashboard name (Max 120 characters)",
                    "example": "Dashboard name"
                  },
                  "source_mapping": {
                    "type": "object",
                    "description": "Optional. Sources to replace in the copy: ID of a source read by the dashboard (visualizations, filters, filter widgets, variable inputs and monitors) -> ID of another source of the same workspace. Columns are matched by name (exact, then ignoring case) and every column index of the visualizations, dashboard filters and filter widgets is translated.",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "example": {
                      "SOURCE_2025_ID": "SOURCE_2026_ID"
                    }
                  },
                  "force": {
                    "type": "boolean",
                    "description": "Only with source_mapping. Clone even if some visualizations or filters use columns that the new source does not have: those columns are removed from them. Without it, the request is refused with 409 and the report.",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "dashboard_id": {
                      "type": "string",
                      "description": "ID of the new dashboard",
                      "example": "xxxx-xxxxx-xxxx-xxxx"
                    },
                    "source_mapping_report": {
                      "$ref": "#/components/schemas/SourceMappingReport"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_SOURCE_MAPPING",
                        "SOURCE_MAPPING_NOT_FOUND"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The source mapping would remove columns from some visualizations or filters. Send force=true to clone anyway.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "SOURCE_MAPPING_BREAKS"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "report": {
                      "$ref": "#/components/schemas/SourceMappingReport"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/models/methods": {
      "get": {
        "description": "Lists the methods that can be used to create models in this installation, by type of model and in the recommended order (the first ones are good defaults). They depend on the version of the AI module: `source` is 'ai-module' when the module advertises them and 'default' when it does not (an earlier module, or one that cannot be reached right now), and then they are the usual ones. Any valid token can call it, also one limited to a workspace.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "methods": {
                      "type": "object",
                      "description": "Methods by type of model ('classifier', 'regressor', 'clustering', 'outlier', 'associations', 'lda', 'similarity'), in the recommended order.",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "example": {
                        "classifier": [
                          "forest",
                          "hist-gradient",
                          "xgboost",
                          "gradient",
                          "logistic"
                        ],
                        "regressor": [
                          "forest",
                          "hist-gradient",
                          "linear",
                          "ridge"
                        ],
                        "clustering": [
                          "kmeans",
                          "dbscan"
                        ],
                        "outlier": [
                          "isolation-forest",
                          "local-outlier-factor"
                        ],
                        "associations": [
                          "default"
                        ],
                        "lda": [
                          "default"
                        ],
                        "similarity": [
                          "default"
                        ]
                      }
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "ai-module",
                        "default"
                      ],
                      "description": "'ai-module': advertised by the AI module; 'default': the usual methods (AI module without the list, or not reachable)."
                    },
                    "forecast": {
                      "type": "boolean",
                      "description": "Whether the AI module forecasts time series (POST /api/v2/workspace/{workspaceId}/forecasts), with gimodeler 0.16 or later."
                    },
                    "inputs": {
                      "type": "boolean",
                      "description": "Whether `inputs` can choose the columns a model learns from when it is created (POST /api/v2/workspace/{workspaceId}/models), with gimodeler 0.19 or later."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models": {
      "get": {
        "description": "Lists the models of a workspace",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "description": "Requested page (starts with 0)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "limit",
            "description": "Max number of items per page (max 500)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response. Paginated result.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "page": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Current page"
                    },
                    "limit": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Max items per page"
                    },
                    "pages_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of pages"
                    },
                    "items_count": {
                      "type": "integer",
                      "format": "int32",
                      "description": "Total number of items"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                          },
                          "created": {
                            "type": "string",
                            "description": "Creation date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_modified": {
                            "type": "string",
                            "description": "Last modification date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "last_access": {
                            "type": "string",
                            "description": "Last access date",
                            "example": "2020-01-27T10:34:41.702Z"
                          },
                          "name": {
                            "type": "string",
                            "example": "Model name"
                          },
                          "description": {
                            "type": "string",
                            "example": "Model description"
                          },
                          "type": {
                            "type": "string",
                            "description": "Type of model",
                            "example": "classifier"
                          },
                          "size_bytes": {
                            "type": "integer",
                            "format": "int64",
                            "description": "Size (in bytes) of the model."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Creates a new artificial intelligence model. This may require advanced knowledge if you want to use specific configurations. Please refer to AIR-Core documentation on how to create models using this API.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Model name (max 80 characters)",
                    "example": "Example name"
                  },
                  "description": {
                    "type": "string",
                    "description": "Model description (max 300 characters)",
                    "example": "Example description."
                  },
                  "type": {
                    "type": "string",
                    "description": "Model type: 'classifier' (nominal or logic target) and 'regressor' (numeric target) are supervised; 'clustering' and 'outlier' (anomaly detection) are unsupervised (`target` is ignored, but it must be a valid index).",
                    "enum": [
                      "classifier",
                      "regressor",
                      "clustering",
                      "outlier"
                    ]
                  },
                  "method": {
                    "type": "string",
                    "description": "Method to build the model with. The methods offered depend on the version of the AI module of the installation: `GET /api/v2/models/methods` lists them by type, in the recommended order. With an AI module that does not advertise them they are: classifier 'bayes', 'forest', 'gradient', 'logistic', 'mlp', 'neighbors', 'sv', 'tree' and 'xgb'; regressor 'forest', 'gradient', 'linear', 'mlp', 'neighbors', 'sv', 'tree' and 'xgb'; clustering 'dbscan' and 'kmeans'; outlier 'elliptic-envelope', 'isolation-forest' and 'one-class-svm'. An AI module that advertises them (gimodeler 0.14) may add 'hist-gradient' (histogram-based gradient boosting, handles missing values), 'xgboost' (XGBoost gradient boosting; 'xgb' is XGBoost's random forest mode), 'lightgbm', 'extra-trees' and 'rgf' (classifier and regressor), 'multinomial-nb' and 'complement-nb' (classifier; non-negative inputs only), 'ridge', 'lasso' and 'elastic-net' (regressor), 'gaussianmixture', 'agglomerative' and 'spectral' (clustering) and 'local-outlier-factor' (outlier), and leave out a method whose library is not installed. A known method the AI module does not offer is refused with 400 METHOD_NOT_AVAILABLE, and an unknown one with 400 UNKNOWN_METHOD; the message lists the methods available.",
                    "enum": [
                      "forest",
                      "hist-gradient",
                      "xgboost",
                      "lightgbm",
                      "gradient",
                      "extra-trees",
                      "logistic",
                      "linear",
                      "ridge",
                      "lasso",
                      "elastic-net",
                      "tree",
                      "bayes",
                      "multinomial-nb",
                      "complement-nb",
                      "neighbors",
                      "sv",
                      "mlp",
                      "xgb",
                      "rgf",
                      "kmeans",
                      "gaussianmixture",
                      "agglomerative",
                      "dbscan",
                      "spectral",
                      "isolation-forest",
                      "local-outlier-factor",
                      "elliptic-envelope",
                      "one-class-svm"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "description": "Identifier of the source to use for training.",
                    "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                  },
                  "target": {
                    "type": "integer",
                    "format": "int32",
                    "description": "Index of the feature to use as target (if applicable)."
                  },
                  "configuration": {
                    "type": "object",
                    "description": "Dictionary of configuration attributes for the model (Advanced)."
                  },
                  "training_configuration": {
                    "description": "Training configuration (if applicable).",
                    "properties": {
                      "test_size": {
                        "description": "Proportion of dataset to use for testing.",
                        "example": 0.3,
                        "type": "number",
                        "format": "double"
                      },
                      "shuffle": {
                        "type": "boolean",
                        "description": "Set to true in order to suffle the instances"
                      },
                      "random_state": {
                        "type": "integer",
                        "format": "int64",
                        "description": "Custom seed for RNG"
                      }
                    }
                  },
                  "second_attempt": {
                    "type": "boolean",
                    "description": "Quality guarantee (classifiers and regressors). When the trained model is not better than the naive prediction (always answering the most frequent class, or always predicting the mean), AIR-Core trains a few other methods with their default settings on the same data (2 on the free plan, 3 on the paid ones, inside the same task and its time) and keeps the best one that beats it; the model then has that method, and `quality.second_attempt` of the model says what happened. `false` always keeps the method asked for. Default: `true`."
                  },
                  "hyper_search_configuration": {
                    "type": "object",
                    "description": "Hyperparameter search (advanced). `{\"auto\": true}` searches a small grid of the main settings of the method with 3-fold cross-validation (settings fixed in `configuration` are not searched); the chosen values are returned in the evaluation of the model (`hyperparameters`). Otherwise a gimodeler search configuration: `method` (grid or random), `cv`, `shuffle`, `random_state`, `number_models` and `grid.estimator` (lists of values per setting)."
                  },
                  "inputs": {
                    "type": "array",
                    "description": "Optional: the columns the model learns from, as indexes of the training source (the target cannot be one of them; repetitions are refused). Without it, every column but the target, as always. Only for 'classifier', 'regressor', 'clustering' and 'outlier', and only with an AI module that trains on chosen columns (gimodeler 0.19 or later; `GET /api/v2/models/methods` says so in `inputs`). The model keeps them in `configuration.inputs`: `inputs` of the model, predict, batch-predict, predict-1d, apply and the explanations then take exactly these columns, in the order of the source. A list with every column but the target is the same as leaving it out. With `nlp_config.text_attribute`, the column of text must be one of them. Errors (400): BAD_INPUTS (not a list of indexes, empty or repeated), INPUT_NOT_FOUND, INPUT_IS_TARGET, INPUTS_NOT_SUPPORTED (another type of model), INPUTS_WITHOUT_TEXT and INPUTS_NOT_AVAILABLE (the AI module of the installation cannot yet; nothing is created).",
                    "items": {
                      "type": "integer",
                      "format": "int32",
                      "minimum": 0
                    },
                    "example": [
                      0,
                      2,
                      3
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string",
                      "description": "ID of the task created.",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_CONFIGURATION",
                        "BAD_NAME",
                        "BAD_DESCRIPTION",
                        "SOURCE_EXTERNAL",
                        "UNKNOWN_METHOD",
                        "METHOD_NOT_AVAILABLE",
                        "BAD_INPUTS",
                        "INPUT_NOT_FOUND",
                        "INPUT_IS_TARGET",
                        "INPUTS_NOT_SUPPORTED",
                        "INPUTS_WITHOUT_TEXT",
                        "INPUTS_NOT_AVAILABLE"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "LIMIT"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND",
                        "SOURCE_NOT_FOUND",
                        "TARGET_NOT_FOUND"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}": {
      "get": {
        "description": "Gets the information about a model (attributes, metrics, etc).",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "name": {
                      "type": "string",
                      "example": "Model name"
                    },
                    "description": {
                      "type": "string",
                      "example": "Model description"
                    },
                    "type": {
                      "type": "string",
                      "description": "Type of model",
                      "example": "classifier"
                    },
                    "method": {
                      "type": "string",
                      "description": "Method used to build the model",
                      "example": "bayes"
                    },
                    "created": {
                      "type": "string",
                      "description": "Creation date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_modified": {
                      "type": "string",
                      "description": "Last modification date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "last_access": {
                      "type": "string",
                      "description": "Last access date",
                      "example": "2020-01-27T10:34:41.702Z"
                    },
                    "source_train": {
                      "description": "Identifier of the source used for training (may not exists)",
                      "type": "string",
                      "example": "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
                    },
                    "configuration": {
                      "description": "Configuration used for the model build process",
                      "type": "object"
                    },
                    "inputs": {
                      "description": "Input fields of the model, in the order predict and batch-predict take them: every field but the target, or the ones chosen when the model was created (`configuration.inputs`, indexes of the training source)",
                      "type": "array",
                      "items": {
                        "properties": {
                          "name": {
                            "type": "string",
                            "example": "Field_Name"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "nominal",
                              "logic",
                              "date",
                              "numeric",
                              "text"
                            ]
                          }
                        }
                      }
                    },
                    "output": {
                      "description": "Output (target) of the model",
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "Field_Name"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "nominal",
                            "logic",
                            "date",
                            "numeric",
                            "text"
                          ]
                        }
                      }
                    },
                    "quality": {
                      "$ref": "#/components/schemas/ModelQuality"
                    },
                    "size_bytes": {
                      "type": "integer",
                      "format": "int64",
                      "description": "Size (in bytes) of the model."
                    },
                    "health": {
                      "type": "object",
                      "description": "Health of the model («Salud del modelo»): the last check of its monitoring. status: stable, watch, alert (data or quality with real outcomes), pending (before its first check), off, unsupported. drift_verdict from the largest PSI of the inputs: stable (under psi_warning, 0.10 by default), moderate_change (from psi_warning), strong_change (from psi_alert, 0.25 by default), unknown. top_drift: the inputs that moved most. quality: the main metric when trained and now, on the new rows with a real outcome.",
                      "properties": {
                        "supported": {
                          "type": "boolean"
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "stable",
                            "watch",
                            "alert",
                            "pending",
                            "off",
                            "unsupported",
                            "error",
                            "unknown"
                          ]
                        },
                        "drift_verdict": {
                          "type": "string",
                          "enum": [
                            "stable",
                            "moderate_change",
                            "strong_change",
                            "unknown"
                          ]
                        },
                        "checked_at": {
                          "type": "integer",
                          "format": "int64",
                          "nullable": true
                        },
                        "max_psi": {
                          "type": "number",
                          "nullable": true
                        },
                        "thresholds": {
                          "type": "object",
                          "properties": {
                            "psi_warning": {
                              "type": "number"
                            },
                            "psi_alert": {
                              "type": "number"
                            }
                          }
                        },
                        "top_drift": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "source": {
                                "type": "string"
                              },
                              "psi": {
                                "type": "number"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "watch",
                                  "alert"
                                ]
                              }
                            }
                          }
                        },
                        "quality": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "metric": {
                              "type": "string"
                            },
                            "training": {
                              "type": "number"
                            },
                            "current": {
                              "type": "number"
                            },
                            "rows": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "post": {
        "description": "Modifies the name and description of a model",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Model name (max 80 characters)",
                    "example": "Example name"
                  },
                  "description": {
                    "type": "string",
                    "description": "Model description (max 300 characters)",
                    "example": "Example description."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_DESCRIPTION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      },
      "delete": {
        "description": "Deletes a model.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Result of the transaction.",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/dependents": {
      "get": {
        "description": "Dependency map of a model, to check before deleting it. `sources`, the sources made with its predictions (`from` is the source it was applied to), and `dashboards`, the dashboards with widgets of the model. Up to 50 of each; `more` counts the rest. Groups the user of the token cannot read keep their count, with `hidden: true` and no items.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelLineage"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION",
                        "ACCESS_DENIED"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/evaluation": {
      "get": {
        "description": "Gets the evaluation of a model.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "evaluation": {
                      "type": "object",
                      "description": "Key-value dictionary with the evaluation metrics."
                    },
                    "op-diagram": {
                      "description": "Diagram observed-predicted",
                      "properties": {
                        "observed": {
                          "type": "array",
                          "items": {
                            "type": "number",
                            "format": "double"
                          }
                        },
                        "predicted": {
                          "type": "array",
                          "items": {
                            "type": "number",
                            "format": "double"
                          }
                        }
                      }
                    },
                    "confusion": {
                      "description": "Confusion matrix",
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "number",
                          "format": "double"
                        }
                      }
                    },
                    "classes": {
                      "description": "Names of the classes for the confusion matrix",
                      "type": "array",
                      "items": {
                        "type": "string",
                        "example": "setosa"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/predict": {
      "get": {
        "description": "Uses a model to predict a value given the inputs.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inputs",
            "description": "Input values given as JSON array. Example: [0.2, 0.1, -0.5, 0.9]",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "quality": {
                      "$ref": "#/components/schemas/ModelQualityBrief"
                    },
                    "output": {
                      "type": "number",
                      "format": "double",
                      "description": "Model output value. It can be numeric (for regressors), boolean or string (for classifiers).",
                      "example": 0.54
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_INPUTS"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          },
          "500": {
            "description": "Internal server error or model error."
          },
          "501": {
            "description": "The model does not support prediction."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/batch-predict": {
      "post": {
        "description": "Uses a model to predict a value given the inputs.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "data": {
                    "description": "Array of instances to predict. Max 25 instances in a single request.",
                    "type": "array",
                    "items": {
                      "properties": {
                        "inputs": {
                          "type": "array",
                          "description": "Array of input values to provide the model with.",
                          "items": {
                            "type": "number",
                            "example": 0.8
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "quality": {
                      "$ref": "#/components/schemas/ModelQualityBrief"
                    },
                    "outputs": {
                      "description": "Array of outputs",
                      "items": {
                        "type": "number",
                        "format": "double",
                        "example": 0.54
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_INPUTS",
                        "TOO_MANY_REQUESTS"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          },
          "500": {
            "description": "Internal server error or model error."
          },
          "501": {
            "description": "The model does not support prediction."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/apply": {
      "post": {
        "description": "Applies a model to a source: a task creates a new source with the rows of the source and a column with the prediction of each row. Without `mapping`, each input of the model takes the column of the source with the same name (case-insensitive).",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "source",
                  "name"
                ],
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "Identifier of the source with the data to predict (not external or real-time)."
                  },
                  "name": {
                    "type": "string",
                    "description": "Name of the new source (max 120 characters).",
                    "example": "Sales with forecast"
                  },
                  "mapping": {
                    "type": "array",
                    "description": "Optional. Column index of the source for each input of the model, in the order of the model inputs (all its fields but the target).",
                    "items": {
                      "type": "integer"
                    },
                    "example": [
                      0,
                      2,
                      3
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task created; poll GET /workspace/{workspaceId}/task/{taskId}: its result is the ID of the new source.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string"
                    },
                    "task": {
                      "type": "string"
                    },
                    "mapping": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      },
                      "description": "Mapping used."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_NAME",
                        "BAD_MAPPING",
                        "EXTERNAL",
                        "NOT_APPLICABLE"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied or plan limit",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCESS_DENIED",
                        "LIMIT",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workspace, model or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/predict-1d": {
      "post": {
        "description": "Unidimensional predict. Keep all the input variables with the same value and vary one of them.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "inputs": {
                    "description": "Array of input values to provide the model with. You must provide the variable you want to vary, event it is not used, to keep the order of the variables.",
                    "type": "array",
                    "items": {
                      "type": "number",
                      "example": 0.8
                    }
                  },
                  "vary": {
                    "type": "integer",
                    "format": "int32",
                    "example": 3,
                    "description": "Index of the input variable you want to vary"
                  },
                  "values": {
                    "type": "array",
                    "items": {
                      "type": "number",
                      "example": 0.9
                    },
                    "description": "Array of values for the input variable you want to vary. You must provide at least one value. Max values in a single request are 255."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "quality": {
                      "$ref": "#/components/schemas/ModelQualityBrief"
                    },
                    "outputs": {
                      "description": "Array of outputs",
                      "items": {
                        "type": "number",
                        "format": "double",
                        "example": 0.54
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_INPUTS",
                        "TOO_MANY_REQUESTS"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACESS_DENIED",
                        "NO_ORGANIZATION"
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Error message."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Requested resource was not found"
          },
          "500": {
            "description": "Internal server error or model error."
          },
          "501": {
            "description": "The model does not support prediction."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation": {
      "get": {
        "description": "Global explanation of a classification or regression model: weight of each input in its predictions (mean absolute SHAP value over a sample of the training data). Computed by the explainability module; cached until the model changes. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the text: es or en",
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          },
          {
            "name": "stored",
            "in": "query",
            "required": false,
            "description": "Only what is already stored: true answers the stored explanation for this version of the model, or 204 when there is none. Explanations are kept per model version (also those computed after training); the explainability module is never called.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "shap-kernel"
                    },
                    "base_value": {
                      "type": "number"
                    },
                    "importances": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "feature": {
                            "type": "string"
                          },
                          "importance": {
                            "type": "number"
                          },
                          "signed_mean": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "n_rows": {
                      "type": "integer"
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "No explanation stored yet (only with stored=true)"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: the model type cannot be explained (only classifiers and regressors) or its training data no longer exists",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/prediction": {
      "post": {
        "description": "Explains one prediction: contribution of each input value (SHAP). For classifiers it explains the predicted class. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "inputs"
                ],
                "properties": {
                  "inputs": {
                    "type": "array",
                    "description": "Input values, in the order of the model inputs (all model fields except the target)",
                    "items": {},
                    "example": [
                      5.1,
                      3.5,
                      1.4,
                      0.2
                    ]
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "es",
                      "en"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "prediction": {},
                    "output": {
                      "type": "string",
                      "enum": [
                        "probability_of_predicted_class",
                        "value"
                      ]
                    },
                    "base_value": {
                      "type": "number"
                    },
                    "contributions": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "feature": {
                            "type": "string"
                          },
                          "value": {},
                          "contribution": {
                            "type": "number",
                            "format": "double"
                          }
                        }
                      }
                    },
                    "text": {
                      "type": "string"
                    },
                    "quality_checks": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/rules": {
      "get": {
        "description": "Rules that describe what a classification or regression model predicts («if … then …»; for regressors, ranges of the value), learned from its predictions over a random sample of up to 1000 rows of its training data (the same rows every time), with the coverage and precision of each rule and the fidelity of the rule list to the model. Computed by the explainability module; cached until the model changes. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the text: es or en",
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          },
          {
            "name": "stored",
            "in": "query",
            "required": false,
            "description": "Only what is already stored: true answers the stored explanation for this version of the model, or 204 when there is none. Explanations are kept per model version (also those computed after training); the explainability module is never called.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "ripper"
                    },
                    "output": {
                      "type": "string",
                      "enum": [
                        "class",
                        "value_range"
                      ]
                    },
                    "classes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "label": {},
                          "share": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "rules": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "class": {},
                          "conditions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "feature": {
                                  "type": "string"
                                },
                                "operator": {
                                  "type": "string",
                                  "enum": [
                                    "<=",
                                    ">",
                                    "==",
                                    "!="
                                  ]
                                },
                                "value": {
                                  "description": "Value of the input (number, category, ISO date or boolean)"
                                },
                                "text": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "text": {
                            "type": "string"
                          },
                          "coverage": {
                            "type": "number"
                          },
                          "precision": {
                            "type": "number"
                          },
                          "support": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "default_class": {},
                    "fidelity": {
                      "type": "number",
                      "description": "Share of the predictions of the model the rules reproduce"
                    },
                    "fidelity_holdout": {
                      "type": "number"
                    },
                    "n_rows": {
                      "type": "integer"
                    },
                    "quality_checks": {
                      "type": "object",
                      "description": "Quality checks of the explanation"
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "No explanation stored yet (only with stored=true)"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the workspace or the model was not found",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: only classifiers and regressors are supported, or the training data of the model no longer exists",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS: too many explanation requests; wait a minute",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/prototypes": {
      "get": {
        "description": "Representative cases (prototypes) of a random sample of up to 1000 rows of the training data of a model (the same rows every time), overall and per group: per class (classifiers), range (regressors), cluster (clustering) or anomaly / normal (anomaly detection), with how each group differs from the whole. The values of the cases are rows of the training source: they are left out (`rows_hidden`: true) unless the user has the read_sources permission in the workspace. Cached until the model changes. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the text: es or en",
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          },
          {
            "name": "stored",
            "in": "query",
            "required": false,
            "description": "Only what is already stored: true answers the stored explanation for this version of the model, or 204 when there is none. Explanations are kept per model version (also those computed after training); the explainability module is never called.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "protodash"
                    },
                    "grouping": {
                      "type": "string",
                      "enum": [
                        "class",
                        "range",
                        "cluster",
                        "anomaly"
                      ]
                    },
                    "overall": {
                      "type": "object",
                      "properties": {
                        "label": {
                          "description": "Class, range, cluster, or `anomaly` / `normal`; null for the whole"
                        },
                        "size": {
                          "type": "integer"
                        },
                        "share": {
                          "type": "number"
                        },
                        "prototypes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "row": {
                                "type": "integer",
                                "description": "Index of the row in the sample of the training data"
                              },
                              "weight": {
                                "type": "number"
                              },
                              "values": {
                                "type": "array",
                                "items": {},
                                "description": "The row, in the order of `inputs`. Left out when the user cannot read the sources of the workspace (`rows_hidden`)"
                              },
                              "prediction": {}
                            }
                          }
                        },
                        "summary": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "feature": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string"
                              },
                              "group_value": {},
                              "overall_value": {},
                              "score": {
                                "type": "number"
                              },
                              "text": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "text": {
                          "type": "string"
                        }
                      }
                    },
                    "groups": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "label": {
                            "description": "Class, range, cluster, or `anomaly` / `normal`; null for the whole"
                          },
                          "size": {
                            "type": "integer"
                          },
                          "share": {
                            "type": "number"
                          },
                          "prototypes": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "row": {
                                  "type": "integer",
                                  "description": "Index of the row in the sample of the training data"
                                },
                                "weight": {
                                  "type": "number"
                                },
                                "values": {
                                  "type": "array",
                                  "items": {},
                                  "description": "The row, in the order of `inputs`. Left out when the user cannot read the sources of the workspace (`rows_hidden`)"
                                },
                                "prediction": {}
                              }
                            }
                          },
                          "summary": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "feature": {
                                  "type": "string"
                                },
                                "kind": {
                                  "type": "string"
                                },
                                "group_value": {},
                                "overall_value": {},
                                "score": {
                                  "type": "number"
                                },
                                "text": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "n_rows": {
                      "type": "integer"
                    },
                    "quality_checks": {
                      "type": "object",
                      "description": "Quality checks of the explanation"
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    },
                    "inputs": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Names of the inputs, the order of `values`"
                    },
                    "rows_hidden": {
                      "type": "boolean",
                      "description": "True when the values of the cases were left out (no read_sources permission)"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "No explanation stored yet (only with stored=true)"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the workspace or the model was not found",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: only classifiers, regressors, clustering and anomaly detection models are supported, or the training data of the model no longer exists",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS: too many explanation requests; wait a minute",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/counterfactuals": {
      "post": {
        "description": "Counterfactual explanation of one case: the smallest changes of its input values that would make the model give the desired class (classifiers) or a value in the desired range (regressors), keeping the locked inputs. Up to 5 alternatives, each verified with the model. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "inputs"
                ],
                "properties": {
                  "inputs": {
                    "type": "array",
                    "description": "Input values, in the order of the model inputs (all model fields except the target)",
                    "items": {},
                    "example": [
                      42,
                      "basic",
                      3
                    ]
                  },
                  "locked": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Names of inputs that may not change",
                    "example": [
                      "age"
                    ]
                  },
                  "desired_class": {
                    "description": "Classifiers: the wanted class (optional; any other class by default)"
                  },
                  "desired_range": {
                    "type": "object",
                    "description": "Regressors (required): the wanted range of the prediction; null for no bound, at least one bound",
                    "properties": {
                      "min": {
                        "type": "number",
                        "nullable": true
                      },
                      "max": {
                        "type": "number",
                        "nullable": true
                      }
                    }
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 5,
                    "default": 3,
                    "description": "Alternatives to find"
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "es",
                      "en"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "counterfactual-search"
                    },
                    "prediction": {
                      "description": "Prediction of the model for the case"
                    },
                    "target": {
                      "description": "The desired class, the desired range {min, max}, or null (any other class)"
                    },
                    "counterfactuals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "changes": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "feature": {
                                  "type": "string"
                                },
                                "from": {},
                                "to": {}
                              }
                            }
                          },
                          "prediction": {},
                          "distance": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "locked": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "quality_checks": {
                      "type": "object",
                      "description": "Quality checks of the explanation"
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "BAD_INPUTS: the input values, the locked inputs or the desired class or range are not valid",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the workspace or the model was not found",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: only classifiers and regressors are supported, or the training data of the model no longer exists",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS: too many explanation requests; wait a minute",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/compare": {
      "get": {
        "description": "Where two models of the same workspace disagree (interpretable model differencing): share of disagreement over a random sample of up to 1000 rows of the training data of the first model, and regions of the inputs, as readable conditions, where they differ most. Both models must be classifiers or both regressors, with the same inputs. Cached until either model changes. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "other",
            "in": "query",
            "required": true,
            "description": "Identifier of the other model, of the same workspace",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the text: es or en",
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          },
          {
            "name": "stored",
            "in": "query",
            "required": false,
            "description": "Only what is already stored: true answers the stored comparison (with other, that one; without other, the one stored last for this version of the model, whose other_model says which) or 204 when there is none. The explainability module is never called.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "imd-joint-surrogate"
                    },
                    "other_model": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    },
                    "disagreement_rate": {
                      "type": "number"
                    },
                    "n_rows": {
                      "type": "integer"
                    },
                    "regions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "conditions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "feature": {
                                  "type": "string"
                                },
                                "operator": {
                                  "type": "string",
                                  "enum": [
                                    "<=",
                                    ">",
                                    "==",
                                    "!="
                                  ]
                                },
                                "value": {
                                  "description": "Value of the input (number, category, ISO date or boolean)"
                                },
                                "text": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "text": {
                            "type": "string"
                          },
                          "coverage": {
                            "type": "number"
                          },
                          "disagreement_rate": {
                            "type": "number"
                          },
                          "share_of_disagreements": {
                            "type": "number"
                          },
                          "prediction": {},
                          "other_prediction": {}
                        }
                      }
                    },
                    "fidelity": {
                      "type": "number"
                    },
                    "quality_checks": {
                      "type": "object",
                      "description": "Quality checks of the explanation"
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "No explanation stored yet (only with stored=true)"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the workspace or the model was not found, or `other` is not a model of the workspace",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: the models are not both classifiers or both regressors, do not have the same inputs, or the training data no longer exists",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS: too many explanation requests; wait a minute",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/forecast": {
      "get": {
        "description": "What weighs in a forecast (a model of type forecast): which past periods of a series move most what it forecasts for the next periods. The explainability module treats the forecast as a black box and forecasts again from perturbed copies of the last periods (through the AI module, gimodeler 0.17 or later) with three methods ported from IBM AIX360: TS-Saliency (integrated gradients estimated by Monte Carlo), TS-LIME (a local linear surrogate) and TS-ICE (how the forecast changes when the values of one stretch go up or down), combined in equal parts. When the chosen method is naive or seasonal naive the explanation is exact and nothing is computed. Cached until the forecast is trained again. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "series",
            "in": "query",
            "required": false,
            "description": "The series to explain (its value of the series field); the first one when left out",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the text: es or en",
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          },
          {
            "name": "stored",
            "in": "query",
            "required": false,
            "description": "Only what is already stored: true answers the stored explanation for this version of the model, or 204 when there is none. Explanations are kept per model version (also those computed after training); the explainability module is never called.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "enum": [
                        "ts-saliency+ts-lime+ts-ice",
                        "exact"
                      ]
                    },
                    "series_key": {
                      "type": "string",
                      "nullable": true
                    },
                    "forecast_method": {
                      "type": "string",
                      "enum": [
                        "naive",
                        "seasonal-naive",
                        "ets",
                        "gbm-lags"
                      ]
                    },
                    "frequency": {
                      "type": "string",
                      "enum": [
                        "H",
                        "D",
                        "W",
                        "M",
                        "Q",
                        "Y"
                      ]
                    },
                    "horizon": {
                      "type": "integer"
                    },
                    "forecast_dates": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "window": {
                      "type": "object",
                      "description": "The last periods explained (4 to 192; twice the season by default)",
                      "properties": {
                        "dates": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "values": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "forecast_mean": {
                      "type": "number",
                      "description": "Mean of the forecast over the horizon (what is explained)"
                    },
                    "flat_window_forecast_mean": {
                      "type": "number",
                      "nullable": true,
                      "description": "The same when the explained periods are flat (their mean): the starting point of the saliency"
                    },
                    "segments": {
                      "type": "array",
                      "description": "Stretches of the window (at most 12), with their weight and the result of each method",
                      "items": {
                        "type": "object",
                        "properties": {
                          "start": {
                            "type": "string",
                            "description": "First period (YYYY-MM-DD, or YYYY-MM-DDTHH:00:00 for hours)"
                          },
                          "end": {
                            "type": "string",
                            "description": "Last period"
                          },
                          "start_index": {
                            "type": "integer",
                            "description": "Position of the first period in `window`"
                          },
                          "end_index": {
                            "type": "integer",
                            "description": "Position of the last period in `window`"
                          },
                          "importance": {
                            "type": "number",
                            "description": "Share of the weight, from 0 to 1 (the weights of all segments add up to 1)"
                          },
                          "text": {
                            "type": "string",
                            "description": "The period in words, with how long before the forecast it is"
                          },
                          "lag_start": {
                            "type": "integer",
                            "description": "Periods before the forecast of the first period (1: the last one)"
                          },
                          "lag_end": {
                            "type": "integer"
                          },
                          "saliency": {
                            "type": "number",
                            "nullable": true
                          },
                          "lime_weight": {
                            "type": "number",
                            "nullable": true,
                            "description": "Coefficient of the linear surrogate: what the actual values of the stretch add to the mean forecast"
                          },
                          "ice": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "signed_impact": {
                                "type": "number"
                              },
                              "total_impact": {
                                "type": "number"
                              },
                              "shifts": {
                                "type": "array",
                                "items": {
                                  "type": "number"
                                }
                              },
                              "forecast_mean": {
                                "type": "array",
                                "items": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "importance": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      },
                      "description": "Weight of each period of `window` (adds up to 1)"
                    },
                    "saliency": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    "top_periods": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "start": {
                            "type": "string",
                            "description": "First period (YYYY-MM-DD, or YYYY-MM-DDTHH:00:00 for hours)"
                          },
                          "end": {
                            "type": "string",
                            "description": "Last period"
                          },
                          "start_index": {
                            "type": "integer",
                            "description": "Position of the first period in `window`"
                          },
                          "end_index": {
                            "type": "integer",
                            "description": "Position of the last period in `window`"
                          },
                          "importance": {
                            "type": "number",
                            "description": "Share of the weight, from 0 to 1 (the weights of all segments add up to 1)"
                          },
                          "text": {
                            "type": "string",
                            "description": "The period in words, with how long before the forecast it is"
                          }
                        }
                      },
                      "description": "Up to 3 periods that weigh most"
                    },
                    "quality_checks": {
                      "type": "object",
                      "properties": {
                        "exact": {
                          "type": "boolean"
                        },
                        "lime_r2": {
                          "type": "number",
                          "nullable": true
                        },
                        "low_fit_flag": {
                          "type": "boolean"
                        },
                        "saliency_stability": {
                          "type": "number",
                          "nullable": true
                        },
                        "unstable_flag": {
                          "type": "boolean"
                        },
                        "methods_agreement": {
                          "type": "number",
                          "nullable": true
                        }
                      }
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "No explanation stored yet (only with stored=true)"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the workspace, the model or the series was not found",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "FORECAST_NOT_READY: the forecast is still being trained",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: the model is not a forecast, or the AI module cannot forecast from a window (gimodeler before 0.17)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS: too many explanation requests; wait a minute",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/ai/activity": {
      "get": {
        "description": "AI activity log of the organization: actions of the assistant, of MCP clients and agents and of the explainability module, with user, tool, model, result, duration and cost, filtered by user, channel, result and dates. Organization administrators only.",
        "tags": [
          "ai"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "assistant",
                "mcp",
                "xai"
              ]
            }
          },
          {
            "name": "user",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Unix time in milliseconds",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Unix time in milliseconds",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "result",
            "in": "query",
            "required": false,
            "description": "blocked: stopped by the safeguards; error: the other failures",
            "schema": {
              "type": "string",
              "enum": [
                "success",
                "error",
                "blocked"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "workspace": {
                            "type": "string"
                          },
                          "user": {
                            "type": "string"
                          },
                          "user_name": {
                            "type": "string"
                          },
                          "channel": {
                            "type": "string"
                          },
                          "tool": {
                            "type": "string"
                          },
                          "params": {
                            "type": "string"
                          },
                          "result": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          },
                          "duration_ms": {
                            "type": "integer"
                          },
                          "model": {
                            "type": "string"
                          },
                          "tokens_in": {
                            "type": "integer"
                          },
                          "tokens_out": {
                            "type": "integer"
                          },
                          "cost_eur": {
                            "type": "number"
                          },
                          "timestamp": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter is not valid (code INVALID_FILTER): a date that is not Unix milliseconds or comes after the other, an unknown channel or result, or a user that is not an identifier",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "description": "Records an action performed by an MCP client or agent on behalf of the token owner. Used by the AIR-Core MCP server. The record is always attributed to the owner of the token; parameters are stored with credentials redacted.",
        "tags": [
          "ai"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "mcp",
                      "assistant"
                    ]
                  },
                  "tool": {
                    "type": "string"
                  },
                  "workspace": {
                    "type": "string"
                  },
                  "params": {
                    "type": "object"
                  },
                  "result": {
                    "type": "string",
                    "enum": [
                      "success",
                      "error"
                    ]
                  },
                  "error": {
                    "type": "string"
                  },
                  "duration_ms": {
                    "type": "integer"
                  },
                  "model": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/organization/value-report": {
      "get": {
        "description": "Value report of the organization («What AIR-Core did for you this month»): what the platform did on its own in a month (notices of the automations and the channels they reached, automatic updates and rows, predictions and anomalies, models trained, dashboard views, questions answered by the assistant, AI cost), the month before to compare (changes only for months that ended), the highlights of the month as sentences, and an estimate of the hours saved with the minutes it assumes for each thing (an estimate, not a measurement). Months start at midnight in the time zone of the organization. Organization administrators only. Read only.",
        "tags": [
          "organization"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "month",
            "in": "query",
            "required": false,
            "description": "YYYY-MM, from 2020-01 up to the current month, or 'current' (default)",
            "schema": {
              "type": "string",
              "example": "2026-10"
            }
          },
          {
            "name": "months",
            "in": "query",
            "required": false,
            "description": "Months of the period that ends with `month`: 1 (default), 3, 6 or 12. The period before has as many months; `previous` and `changes` compare with it",
            "schema": {
              "type": "integer",
              "enum": [
                1,
                3,
                6,
                12
              ]
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the sentences, labels and notes (en by default)",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "es",
                "ca",
                "fr",
                "de",
                "zh",
                "ja"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "organization": {
                      "type": "string"
                    },
                    "organization_name": {
                      "type": "string"
                    },
                    "month": {
                      "type": "string",
                      "example": "2026-10"
                    },
                    "month_name": {
                      "type": "string"
                    },
                    "timezone": {
                      "type": "string",
                      "example": "Europe/Madrid"
                    },
                    "from": {
                      "type": "integer",
                      "description": "Start of the month (Unix ms)"
                    },
                    "to": {
                      "type": "integer",
                      "description": "End of the month (Unix ms, excluded)"
                    },
                    "in_progress": {
                      "type": "boolean",
                      "description": "The month has not ended: its figures go up to now"
                    },
                    "generated": {
                      "type": "integer"
                    },
                    "lang": {
                      "type": "string"
                    },
                    "metrics": {
                      "type": "object",
                      "description": "The figures of the month. null: not counted yet in that month (emails, rows, predictions, anomalies, dashboard views and summaries are counted since the version that added the value report).",
                      "properties": {
                        "alerts_fired": {
                          "type": "integer",
                          "nullable": true
                        },
                        "alert_records": {
                          "type": "integer",
                          "nullable": true
                        },
                        "alert_stalls": {
                          "type": "integer",
                          "nullable": true
                        },
                        "notices_email": {
                          "type": "integer",
                          "nullable": true
                        },
                        "notices_slack": {
                          "type": "integer",
                          "nullable": true
                        },
                        "notices_teams": {
                          "type": "integer",
                          "nullable": true
                        },
                        "notices_other": {
                          "type": "integer",
                          "nullable": true
                        },
                        "notices_failed": {
                          "type": "integer",
                          "nullable": true
                        },
                        "refreshes": {
                          "type": "integer",
                          "nullable": true
                        },
                        "refreshes_failed": {
                          "type": "integer",
                          "nullable": true
                        },
                        "rows_auto": {
                          "type": "integer",
                          "nullable": true
                        },
                        "rows_live": {
                          "type": "integer",
                          "nullable": true
                        },
                        "predictions": {
                          "type": "integer",
                          "nullable": true
                        },
                        "predictions_interactive": {
                          "type": "integer",
                          "nullable": true
                        },
                        "predictions_batch": {
                          "type": "integer",
                          "nullable": true
                        },
                        "predictions_applied": {
                          "type": "integer",
                          "nullable": true
                        },
                        "anomalies": {
                          "type": "integer",
                          "nullable": true
                        },
                        "model_applications": {
                          "type": "integer",
                          "nullable": true
                        },
                        "models_trained": {
                          "type": "integer",
                          "nullable": true
                        },
                        "models_retrained": {
                          "type": "integer",
                          "nullable": true
                        },
                        "forecasts_trained": {
                          "type": "integer",
                          "nullable": true
                        },
                        "dashboard_views": {
                          "type": "integer",
                          "nullable": true
                        },
                        "dashboard_public_views": {
                          "type": "integer",
                          "nullable": true
                        },
                        "assistant_answers": {
                          "type": "integer",
                          "nullable": true
                        },
                        "mcp_calls": {
                          "type": "integer",
                          "nullable": true
                        },
                        "explanations": {
                          "type": "integer",
                          "nullable": true
                        },
                        "ai_calls": {
                          "type": "integer",
                          "nullable": true
                        },
                        "ai_cost_eur": {
                          "type": "number",
                          "nullable": true
                        },
                        "ai_topup_eur": {
                          "type": "number",
                          "nullable": true
                        },
                        "summaries_sent": {
                          "type": "integer",
                          "nullable": true
                        }
                      }
                    },
                    "previous": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "month": {
                          "type": "string"
                        },
                        "month_name": {
                          "type": "string"
                        },
                        "metrics": {
                          "type": "object",
                          "description": "The figures of the month. null: not counted yet in that month (emails, rows, predictions, anomalies, dashboard views and summaries are counted since the version that added the value report).",
                          "properties": {
                            "alerts_fired": {
                              "type": "integer",
                              "nullable": true
                            },
                            "alert_records": {
                              "type": "integer",
                              "nullable": true
                            },
                            "alert_stalls": {
                              "type": "integer",
                              "nullable": true
                            },
                            "notices_email": {
                              "type": "integer",
                              "nullable": true
                            },
                            "notices_slack": {
                              "type": "integer",
                              "nullable": true
                            },
                            "notices_teams": {
                              "type": "integer",
                              "nullable": true
                            },
                            "notices_other": {
                              "type": "integer",
                              "nullable": true
                            },
                            "notices_failed": {
                              "type": "integer",
                              "nullable": true
                            },
                            "refreshes": {
                              "type": "integer",
                              "nullable": true
                            },
                            "refreshes_failed": {
                              "type": "integer",
                              "nullable": true
                            },
                            "rows_auto": {
                              "type": "integer",
                              "nullable": true
                            },
                            "rows_live": {
                              "type": "integer",
                              "nullable": true
                            },
                            "predictions": {
                              "type": "integer",
                              "nullable": true
                            },
                            "predictions_interactive": {
                              "type": "integer",
                              "nullable": true
                            },
                            "predictions_batch": {
                              "type": "integer",
                              "nullable": true
                            },
                            "predictions_applied": {
                              "type": "integer",
                              "nullable": true
                            },
                            "anomalies": {
                              "type": "integer",
                              "nullable": true
                            },
                            "model_applications": {
                              "type": "integer",
                              "nullable": true
                            },
                            "models_trained": {
                              "type": "integer",
                              "nullable": true
                            },
                            "models_retrained": {
                              "type": "integer",
                              "nullable": true
                            },
                            "forecasts_trained": {
                              "type": "integer",
                              "nullable": true
                            },
                            "dashboard_views": {
                              "type": "integer",
                              "nullable": true
                            },
                            "dashboard_public_views": {
                              "type": "integer",
                              "nullable": true
                            },
                            "assistant_answers": {
                              "type": "integer",
                              "nullable": true
                            },
                            "mcp_calls": {
                              "type": "integer",
                              "nullable": true
                            },
                            "explanations": {
                              "type": "integer",
                              "nullable": true
                            },
                            "ai_calls": {
                              "type": "integer",
                              "nullable": true
                            },
                            "ai_cost_eur": {
                              "type": "number",
                              "nullable": true
                            },
                            "ai_topup_eur": {
                              "type": "number",
                              "nullable": true
                            },
                            "summaries_sent": {
                              "type": "integer",
                              "nullable": true
                            }
                          }
                        },
                        "hours": {
                          "type": "number"
                        }
                      }
                    },
                    "changes": {
                      "type": "object",
                      "nullable": true,
                      "description": "Change of each figure against the month before (0.25 = +25 %), null when there is nothing to compare; only for months that ended",
                      "additionalProperties": {
                        "type": "number",
                        "nullable": true
                      }
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "hours": {
                          "type": "number"
                        },
                        "minutes": {
                          "type": "integer"
                        },
                        "previous_hours": {
                          "type": "number",
                          "nullable": true
                        },
                        "text": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "count": {
                                "type": "integer"
                              },
                              "minutes": {
                                "type": "integer"
                              },
                              "total": {
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    },
                    "assumptions": {
                      "type": "array",
                      "description": "Minutes assumed for each thing, editable by the administrators within min and max",
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string",
                            "enum": [
                              "refresh",
                              "alert",
                              "report",
                              "answer",
                              "model",
                              "application"
                            ]
                          },
                          "label": {
                            "type": "string"
                          },
                          "minutes": {
                            "type": "integer"
                          },
                          "default": {
                            "type": "integer"
                          },
                          "min": {
                            "type": "integer"
                          },
                          "max": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "highlights": {
                      "type": "array",
                      "description": "Up to three moments of the month, only from what the records show",
                      "items": {
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "code": {
                            "type": "string",
                            "enum": [
                              "in_progress",
                              "counters_partial",
                              "counters_none",
                              "tasks_partial"
                            ]
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "labels": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "months": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "period": {
                      "type": "object",
                      "description": "The months of the report and of the period before (YYYY-MM), with their names",
                      "properties": {
                        "months": {
                          "type": "integer"
                        },
                        "first": {
                          "type": "string"
                        },
                        "last": {
                          "type": "string"
                        },
                        "from": {
                          "type": "integer"
                        },
                        "to": {
                          "type": "integer"
                        },
                        "name": {
                          "type": "string"
                        },
                        "previous_name": {
                          "type": "string"
                        },
                        "previous_first": {
                          "type": "string"
                        },
                        "previous_last": {
                          "type": "string"
                        }
                      }
                    },
                    "headline": {
                      "$ref": "#/components/schemas/ValueHeadline"
                    },
                    "headline_previous": {
                      "$ref": "#/components/schemas/ValueHeadline"
                    },
                    "headline_changes": {
                      "type": "object",
                      "nullable": true,
                      "description": "Change of each figure of the headline against the period before (0.16 = +16 %); null for a period that has not ended, and null for a figure with nothing to compare with",
                      "additionalProperties": {
                        "type": "number",
                        "nullable": true
                      }
                    },
                    "headline_labels": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "methods": {
                      "type": "object",
                      "description": "How each figure of the headline is computed, in words",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "series": {
                      "type": "array",
                      "description": "The evolution, month by month: the last twelve months up to the end of the period (from the month the organization was created)",
                      "items": {
                        "type": "object",
                        "properties": {
                          "month": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "hours": {
                            "type": "number"
                          },
                          "alerts": {
                            "type": "integer"
                          },
                          "questions": {
                            "type": "integer"
                          },
                          "predictions": {
                            "type": "integer",
                            "nullable": true
                          },
                          "views": {
                            "type": "integer",
                            "nullable": true
                          },
                          "cost": {
                            "type": "number"
                          },
                          "people": {
                            "type": "integer",
                            "nullable": true
                          },
                          "in_progress": {
                            "type": "boolean"
                          },
                          "partial": {
                            "type": "boolean",
                            "description": "Some figures of the month were not kept"
                          },
                          "in_period": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "top": {
                      "type": "array",
                      "description": "The most useful objects of the period that still exist: the automation that warned most, the dashboard seen most, the model that predicted most and the source that updated itself most",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "alert",
                              "dashboard",
                              "model",
                              "source"
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "ws": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "n": {
                            "type": "integer"
                          },
                          "records": {
                            "type": "integer"
                          },
                          "stalls": {
                            "type": "integer"
                          },
                          "publicViews": {
                            "type": "integer"
                          },
                          "title": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "by_workspace": {
                      "type": "array",
                      "description": "What each workspace did and the hours it saved; the last row (ws empty) is what cannot be told by workspace",
                      "items": {
                        "type": "object",
                        "properties": {
                          "ws": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "hours": {
                            "type": "number"
                          },
                          "alerts": {
                            "type": "integer"
                          },
                          "refreshes": {
                            "type": "integer"
                          },
                          "predictions": {
                            "type": "integer"
                          },
                          "views": {
                            "type": "integer"
                          },
                          "questions": {
                            "type": "integer"
                          },
                          "models": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "by_feature": {
                      "type": "object",
                      "properties": {
                        "hours": {
                          "type": "array",
                          "description": "Where the hours come from",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "count": {
                                "type": "integer"
                              },
                              "minutes": {
                                "type": "integer"
                              },
                              "hours": {
                                "type": "number"
                              }
                            }
                          }
                        },
                        "ai": {
                          "type": "array",
                          "description": "Calls to the AI and their cost (euros of credit) by feature",
                          "items": {
                            "type": "object",
                            "properties": {
                              "feature": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "n": {
                                "type": "integer"
                              },
                              "cost_eur": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "credits": {
                      "type": "object",
                      "description": "AI cost against what the AI did",
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "own_key": {
                          "type": "boolean"
                        },
                        "available": {
                          "type": "number",
                          "nullable": true
                        },
                        "spent_eur": {
                          "type": "number"
                        },
                        "topup_eur": {
                          "type": "number"
                        },
                        "calls": {
                          "type": "integer"
                        },
                        "questions": {
                          "type": "integer"
                        },
                        "per_question_eur": {
                          "type": "number",
                          "nullable": true
                        },
                        "ai_hours": {
                          "type": "number"
                        }
                      }
                    },
                    "empty": {
                      "type": "boolean",
                      "description": "Nothing to tell yet in any month of the evolution (a new organization)"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The month is not valid (code INVALID_MONTH)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The token cannot read or the user does not manage the organization (code ACCESS_DENIED)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/organization/palette": {
      "get": {
        "description": "The colours of the brand of the organization: every chart without colours of its own is drawn with them and their shades (also on shared dashboards), heat maps take a scale of the first one and the reports take it as accent. Organization administrators only.",
        "tags": [
          "organization"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "palette": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "example": "#2e7d32"
                      },
                      "description": "The colours of the brand, #rrggbb, in the order the series take them"
                    },
                    "shades": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The colours the charts take: the palette and its shades, up to 10"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Not an administrator of the organization, or a token without the permission"
          }
        }
      },
      "post": {
        "description": "Sets the colours of the brand of the organization: up to 12, as #rrggbb (#rgb is accepted). An empty list goes back to the default colours of AIR-Core. The visualizations with colours of their own keep them. Organization administrators only; needs a token that can write.",
        "tags": [
          "organization"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "palette": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "#2e7d32",
                      "#8f4b95",
                      "#009f98"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "palette": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "example": "#2e7d32"
                      },
                      "description": "The colours of the brand, #rrggbb, in the order the series take them"
                    },
                    "shades": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The colours the charts take: the palette and its shades, up to 10"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A colour is not valid or there are more than 12 (INVALID_PALETTE)"
          },
          "403": {
            "description": "Not an administrator of the organization, or a token without the permission"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/effects": {
      "get": {
        "description": "Effect of each input of a classification or regression model: one curve per input (ranges of numbers and dates, the 20 most frequent categories and «Otros») and up to 3 pairs of inputs that act together, from an Explainable Boosting Machine (InterpretML) fitted to the predictions of the model over a random sample of up to 2000 rows of its training data, with its fidelity on rows it did not see (accuracy for classification, R² for regression). For a classifier one class is explained against the rest and the effects are percentage points of its probability; for a regressor, units of the target. Computed by the explainability module; cached until the model changes. Requires the model_use permission.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "class",
            "in": "query",
            "required": false,
            "description": "Classification: the class explained against the rest. By default the positive class of a binary task (1, true, yes, sí…) or, otherwise, the class the model predicts least often among those it predicts for at least 5 % of the rows.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the text: es or en",
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          },
          {
            "name": "stored",
            "in": "query",
            "required": false,
            "description": "Only what is already stored: true answers the stored explanation for this version of the model, or 204 when there is none. Explanations are kept per model version (also those computed after training); the explainability module is never called.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "ebm-surrogate"
                    },
                    "task": {
                      "type": "string",
                      "enum": [
                        "classification",
                        "regression"
                      ]
                    },
                    "class": {
                      "description": "The class explained (null for a regressor)"
                    },
                    "unit": {
                      "type": "string",
                      "description": "pp (percentage points of probability) for a classifier; empty for a regressor (units of the target)"
                    },
                    "base_value": {
                      "type": "number",
                      "description": "Probability of the class in % at the base (classifier) or the base value of the target (regressor)"
                    },
                    "class_share": {
                      "type": "number",
                      "nullable": true,
                      "description": "Share of the rows the model predicts the class for"
                    },
                    "sample_rows": {
                      "type": "integer"
                    },
                    "fidelity": {
                      "type": "object",
                      "properties": {
                        "metric": {
                          "type": "string",
                          "enum": [
                            "accuracy",
                            "r2"
                          ]
                        },
                        "value": {
                          "type": "number"
                        },
                        "baseline": {
                          "type": "number",
                          "description": "Classification: accuracy of always saying the majority answer"
                        },
                        "holdout_rows": {
                          "type": "integer"
                        },
                        "low": {
                          "type": "boolean",
                          "description": "Fidelity below 0.8 (or not better than the baseline): the curves are approximate"
                        }
                      }
                    },
                    "terms": {
                      "type": "array",
                      "description": "One per input, most important first",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "numeric",
                              "nominal"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "description": "Type of the input: numeric, date, nominal, logic or text"
                          },
                          "importance": {
                            "type": "number",
                            "description": "Share of the total importance (terms and interactions add up to 1)"
                          },
                          "points": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "x": {
                                  "description": "Center of the range (number), ISO date or category"
                                },
                                "x_from": {
                                  "type": "number",
                                  "nullable": true
                                },
                                "x_to": {
                                  "type": "number",
                                  "nullable": true
                                },
                                "effect": {
                                  "type": "number"
                                },
                                "low": {
                                  "type": "number",
                                  "nullable": true
                                },
                                "high": {
                                  "type": "number",
                                  "nullable": true
                                },
                                "count": {
                                  "type": "integer"
                                },
                                "label": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "interactions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "names": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "importance": {
                            "type": "number"
                          },
                          "x": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "y": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "z": {
                            "type": "array",
                            "description": "z[i][j]: effect for x[i] and y[j]",
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "quality_checks": {
                      "type": "object",
                      "description": "Quality checks of the explanation"
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "No explanation stored yet (only with stored=true)"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED, or XAI_DISABLED: the explainability module is not enabled for the organization of the workspace (it is enabled per organization by a global administrator)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the workspace or the model was not found",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: only classifiers and regressors are supported, the model does not predict the class asked for (or too few rows of it), or the training data of the model no longer exists",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS: too many explanation requests; wait a minute",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/explanation/fairness": {
      "post": {
        "description": "Bias audit (group fairness) of a classification or regression model by a sensitive field of a source (by default its training source): over a random sample of up to 5000 rows, the predictions of the model are compared with the real value of the target per group of the field (categories, or readable ranges for numbers). The field need not be an input of the model: a model that does not use it can still treat its groups differently through other inputs (indirect bias). Groups with fewer than 30 rows are reported with small: true and left out of the gaps. Verdict: concern with any flag of severity high, review with any warning (or fewer than two groups to compare), ok otherwise; the thresholds are documented in the explainability module (disparate impact below 0.8 is a warning and below 0.6 high; gaps of rates of 0.1 a warning and 0.2 high; a ratio of mean errors of 1.25 a warning and 1.5 high). Cached for an hour per model, source version, field and class. Requires the model_use and read_sources permissions.",
        "tags": [
          "models",
          "ai"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sensitive": {
                    "type": "string",
                    "description": "Name of the sensitive field in the source (required unless stored is true)"
                  },
                  "source": {
                    "type": "string",
                    "description": "Identifier of a source of the workspace with the inputs and the target of the model (by name); the training source by default"
                  },
                  "favorable": {
                    "type": "string",
                    "description": "Classification: the favorable class. By default the positive class of a binary task or, otherwise, the least frequent real class among those with at least 5 % of the rows."
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "es",
                      "en"
                    ]
                  },
                  "stored": {
                    "type": "boolean",
                    "description": "Only what is already stored: true answers the stored audit (with sensitive, that one; without it, the one stored last for this version of the model while its source has not changed) or 204 when there is none. The explainability module is never called."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normal response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "group-fairness"
                    },
                    "task": {
                      "type": "string",
                      "enum": [
                        "classification",
                        "regression"
                      ]
                    },
                    "sensitive": {
                      "type": "string"
                    },
                    "favorable": {
                      "description": "The favorable class (null for a regressor)"
                    },
                    "rows": {
                      "type": "integer"
                    },
                    "rows_without_target": {
                      "type": "integer"
                    },
                    "min_group_size": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    },
                    "groups": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "group": {
                            "type": "string"
                          },
                          "n": {
                            "type": "integer"
                          },
                          "share": {
                            "type": "number"
                          },
                          "small": {
                            "type": "boolean"
                          },
                          "actual_rate": {
                            "type": "number",
                            "nullable": true
                          },
                          "predicted_rate": {
                            "type": "number",
                            "nullable": true
                          },
                          "accuracy": {
                            "type": "number",
                            "nullable": true
                          },
                          "tpr": {
                            "type": "number",
                            "nullable": true
                          },
                          "fpr": {
                            "type": "number",
                            "nullable": true
                          },
                          "precision": {
                            "type": "number",
                            "nullable": true
                          },
                          "mean_actual": {
                            "type": "number",
                            "nullable": true
                          },
                          "mean_prediction": {
                            "type": "number",
                            "nullable": true
                          },
                          "mae": {
                            "type": "number",
                            "nullable": true
                          }
                        }
                      }
                    },
                    "metrics": {
                      "type": "object",
                      "properties": {
                        "demographic_parity_difference": {
                          "type": "number",
                          "nullable": true
                        },
                        "disparate_impact_ratio": {
                          "type": "number",
                          "nullable": true
                        },
                        "equal_opportunity_difference": {
                          "type": "number",
                          "nullable": true
                        },
                        "equalized_odds_difference": {
                          "type": "number",
                          "nullable": true
                        },
                        "accuracy_gap": {
                          "type": "number",
                          "nullable": true
                        },
                        "mae_ratio": {
                          "type": "number",
                          "nullable": true
                        },
                        "actual_rate_difference": {
                          "type": "number",
                          "nullable": true
                        },
                        "false_positive_rate_difference": {
                          "type": "number",
                          "nullable": true
                        },
                        "mean_prediction_difference": {
                          "type": "number",
                          "nullable": true
                        },
                        "mean_actual_difference": {
                          "type": "number",
                          "nullable": true
                        }
                      }
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "severity": {
                            "type": "string",
                            "enum": [
                              "info",
                              "warning",
                              "high"
                            ]
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "review",
                        "concern"
                      ]
                    },
                    "text": {
                      "type": "string",
                      "description": "Natural language explanation"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "No explanation stored yet (only with stored=true)"
          },
          "400": {
            "description": "BAD_SENSITIVE: the sensitive field is missing, not in the source or the target of the model; BAD_CLASS: the favorable class is not one value; MODEL_NOT_SUPPORTED: only classifiers and regressors can be audited",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "ACCESS_DENIED (the audit reads the rows of a source: it needs read_sources), XAI_DISABLED, or a refusal of the AI data policy for an AI application connected through MCP (the groups are values of the field: never sent refuses the audit, pseudonymised gives them as tokens)",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the workspace, the model or the source was not found",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "XAI_UNSUPPORTED: the source does not have every input of the model and its target, has no rows, or the favorable class is not a class of the target",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS: too many explanation requests; wait a minute",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "XAI_UNAVAILABLE: the explainability module is not enabled or not available",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/card": {
      "get": {
        "tags": [
          "models",
          "ai"
        ],
        "description": "Automatic model card: training data (source, rows, inputs and types, target, missing values), method and configuration, evaluation metrics, limitations detected with heuristics (class imbalance, small sample, low metric, missing values), intended use, out-of-scope uses, creation date and author. JSON by default; format=markdown returns a Markdown document. Requires the read_models permission.",
        "parameters": [
          {
            "description": "Identifier of the workspace",
            "in": "path",
            "name": "workspaceId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Identifier of the model",
            "in": "path",
            "name": "modelId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Autentication token",
            "in": "header",
            "name": "x-auth-token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Response format: json (default) or markdown",
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "markdown"
              ]
            }
          },
          {
            "description": "Language of the texts: es (default) or en",
            "in": "query",
            "name": "lang",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Model card",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schema_version": {
                      "type": "string",
                      "example": "1.0"
                    },
                    "language": {
                      "type": "string"
                    },
                    "model": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "created": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "last_modified": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "author": {
                          "type": "object",
                          "properties": {
                            "uid": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "training_source": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "available": {
                              "type": "boolean"
                            },
                            "rows": {
                              "type": "integer",
                              "nullable": true
                            }
                          }
                        },
                        "training_version": {
                          "type": "object",
                          "description": "The version of the source the model was trained on (models made since the version history; absent otherwise): when it was made, whether it is the current one and whether its data is kept",
                          "properties": {
                            "version": {
                              "type": "integer"
                            },
                            "at": {
                              "type": "string"
                            },
                            "current": {
                              "type": "boolean"
                            },
                            "kept": {
                              "type": "boolean"
                            },
                            "note": {
                              "type": "string"
                            }
                          }
                        },
                        "inputs": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "missing_values": {
                                "type": "integer",
                                "nullable": true
                              }
                            }
                          }
                        },
                        "target": {
                          "type": "object",
                          "nullable": true
                        },
                        "missing_values": {
                          "type": "object",
                          "properties": {
                            "total": {
                              "type": "integer"
                            },
                            "fields_with_missing": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "method": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string"
                        },
                        "type_label": {
                          "type": "string"
                        },
                        "method": {
                          "type": "string"
                        },
                        "method_label": {
                          "type": "string"
                        },
                        "hyperparameters": {
                          "type": "object"
                        },
                        "training": {
                          "type": "object"
                        },
                        "scaling": {
                          "type": "object"
                        },
                        "feature_selection": {
                          "type": "object"
                        },
                        "hyper_search": {
                          "type": "object"
                        }
                      }
                    },
                    "metrics": {
                      "type": "object",
                      "properties": {
                        "available": {
                          "type": "boolean"
                        },
                        "primary": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "value": {
                              "type": "number"
                            }
                          }
                        },
                        "values": {
                          "type": "object"
                        },
                        "test_class_distribution": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "count": {
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    },
                    "quality": {
                      "$ref": "#/components/schemas/ModelQuality"
                    },
                    "limitations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string",
                            "example": "class_imbalance"
                          },
                          "severity": {
                            "type": "string",
                            "enum": [
                              "info",
                              "warning"
                            ]
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "intended_use": {
                      "type": "string"
                    },
                    "out_of_scope": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/forecasts": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "Creates a forecast of a time series: a model of type `forecast` that predicts the next periods of a figure from its history, with a range of likely values. Only the source and its date field are needed; the rest is automatic. It starts a task (poll `GET /api/v2/workspace/{workspaceId}/task/{taskId}`: its result is the ID of the model) and needs an AI module that forecasts (gimodeler 0.16; `GET /api/v2/models/methods` says `forecast: true`). If the task fails, its message is `FORECAST_NOT_ENOUGH_HISTORY` (fewer periods than needed, which the error description says), `FORECAST_NO_DATES`, `FORECAST_CONSTANT` or `FORECAST_INTERNAL`. Requires the model_create and task permissions; same plan limits as other models.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "name",
                  "source",
                  "date"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Name of the forecast (max 120 characters).",
                    "example": "Sales of the next 12 weeks"
                  },
                  "description": {
                    "type": "string",
                    "description": "Description (max 300 characters)."
                  },
                  "source": {
                    "type": "string",
                    "description": "Identifier of the source with the history (not external or real-time)."
                  },
                  "date": {
                    "description": "Date field of the source, by name or index.",
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "integer"
                      }
                    ],
                    "example": "fecha"
                  },
                  "target": {
                    "description": "Numeric field to forecast, by name or index. Empty or missing to forecast the number of records.",
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "integer"
                      }
                    ],
                    "example": "ventas"
                  },
                  "series": {
                    "description": "Optional field with categories to make one forecast per value (the 20 most frequent).",
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "integer"
                      }
                    ],
                    "example": "tienda"
                  },
                  "aggregation": {
                    "type": "string",
                    "description": "How the records of a period are combined. 'auto' (default): sum when the figure adds up by its name, else mean; count without a target.",
                    "enum": [
                      "auto",
                      "sum",
                      "mean",
                      "count"
                    ]
                  },
                  "frequency": {
                    "type": "string",
                    "description": "Period of the forecast: 'auto' (default, the rhythm of the data), H hours, D days, W weeks, M months, Q quarters, Y years.",
                    "enum": [
                      "auto",
                      "H",
                      "D",
                      "W",
                      "M",
                      "Q",
                      "Y"
                    ]
                  },
                  "horizon": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 500,
                    "description": "Periods ahead; 0 (default) is automatic: 48 hours, 30 days, 12 weeks, 12 months, 8 quarters or 5 years.",
                    "example": 12
                  },
                  "level": {
                    "type": "number",
                    "description": "Coverage of the range of likely values.",
                    "enum": [
                      0.8,
                      0.95
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task created; its result is the ID of the forecast model.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string"
                    },
                    "task": {
                      "type": "string"
                    },
                    "settings": {
                      "type": "object",
                      "description": "The settings checked, with field names."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request: FORECAST_NOT_AVAILABLE (the AI module does not forecast), BAD_NAME, BAD_DESCRIPTION, SOURCE_EXTERNAL, DATE_FIELD_MISSING, DATE_FIELD_NOT_FOUND, DATE_FIELD_NOT_DATE, TARGET_NOT_FOUND, TARGET_NOT_NUMERIC, SERIES_NOT_FOUND, SERIES_NOT_CATEGORY, BAD_AGGREGATION, BAD_FREQUENCY, BAD_HORIZON or BAD_LEVEL, with a message."
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission (ACCESS_DENIED) or a limit of the plan (LIMIT)."
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/forecast": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "The forecast of a model of type `forecast`, as the AI module has it: for each series (one without a series field), the next periods with the forecast value and its range, the chosen method, the seasonal pattern (in periods), the trend and the errors of the test on past data (rolling-origin backtest). `history=1` adds the history (last 1,000 periods) and the test of each series. Requires the read_models permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the forecast model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "history",
            "description": "1 to include the history and the test of each series",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "series",
            "description": "Only the series with this value of the series field",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The forecast (status 'ready'), or status 'training' or 'error' (with code and description; for NOT_ENOUGH_HISTORY, history.available and history.needed when the description says them).",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ready",
                        "training",
                        "error"
                      ]
                    },
                    "settings": {
                      "type": "object",
                      "description": "Settings of the forecast (date, target, series, aggregation, frequency, horizon, level)."
                    },
                    "frequency": {
                      "type": "string",
                      "example": "D"
                    },
                    "horizon": {
                      "type": "integer",
                      "example": 30
                    },
                    "level": {
                      "type": "number",
                      "example": 0.8
                    },
                    "aggregation": {
                      "type": "string",
                      "example": "sum"
                    },
                    "series_field": {
                      "type": "string"
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "example": [
                        "Filled 3 missing days with 0"
                      ]
                    },
                    "series_count": {
                      "type": "integer"
                    },
                    "series": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string",
                            "nullable": true,
                            "description": "Value of the series field, or null without one."
                          },
                          "method": {
                            "type": "string",
                            "description": "Method chosen: naive, seasonal-naive, ets or gbm-lags."
                          },
                          "season": {
                            "type": "integer",
                            "nullable": true,
                            "description": "Detected seasonal period, in periods (7 is weekly on daily data)."
                          },
                          "trend": {
                            "type": "string",
                            "enum": [
                              "up",
                              "down",
                              "flat"
                            ]
                          },
                          "metrics": {
                            "type": "object",
                            "description": "Errors of the test: mae, rmse, smape, mape (null with zeros), mase, baseline, baseline_mae, improvement (1 - mae / baseline_mae) and coverage (share of real values inside the range)."
                          },
                          "forecast": {
                            "type": "object",
                            "description": "dates (ISO, start of each period), values, lower and upper."
                          },
                          "history": {
                            "type": "object",
                            "description": "With history=1: dates and values of the history."
                          },
                          "backtest": {
                            "type": "object",
                            "description": "With history=1: dates, values, lower and upper of the test window."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The model is not a forecast (NOT_A_FORECAST)."
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission"
          },
          "404": {
            "description": "Workspace or model not found, or the AI module does not have the forecast (FORECAST_NOT_FOUND)."
          },
          "503": {
            "description": "The AI module is not available (AI_MODULE_UNAVAILABLE)."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/forecast/retrain": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "Trains the forecast again with the same settings and the data the source has now. The model keeps its ID, page, dashboards and saved sources; the sources made with it are updated when the new forecast is ready. Starts a task. Requires the model_edit permission (or being its owner) and the task permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the forecast model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Task created.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string"
                    },
                    "task": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "FORECAST_NOT_AVAILABLE, NOT_A_FORECAST, SOURCE_NOT_FOUND (the source was deleted) or a settings code when the columns of the source changed."
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission (ACCESS_DENIED) or a limit of the plan (LIMIT)."
          },
          "404": {
            "description": "Workspace or model not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/forecast/source": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "Saves the forecast as a data source with the columns date, series (only with a series field), forecast, lower and upper. It is a derived source of the model: it is updated each time the forecast is trained again. Starts a task (its result is the ID of the source). Requires the model_use, source_create and task permissions; counts towards the sources of the plan.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the forecast model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Name of the new source (max 120 characters).",
                    "example": "Sales forecast"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task created.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string"
                    },
                    "task": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "NOT_A_FORECAST or BAD_NAME."
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission (ACCESS_DENIED) or a limit of the plan (LIMIT)."
          },
          "404": {
            "description": "Workspace or model not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/genai-models": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "Lists the models with generative AI of a workspace: the user described what to predict from one to five sources, and generative AI predicts it row by row. Requires the read_models permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The models (the cases of their checks left out).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/GenAIModel"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          }
        }
      },
      "post": {
        "tags": [
          "models"
        ],
        "description": "Plans a model with generative AI from a description and one to five sources. The model only sees a profile of each source (schema, statistics and at most 30 sample rows, long texts cut): a small fixed cost (`plan_estimate_eur` of the config), whatever the size of the data; nothing is spent on the rows. The plan is kept only as far as it fits the sources (`dropped` says what was left out) and can be corrected with POST .../genai-models/{genaiModelId}. Requires the model_create permission. On the free plan only the cost-free model of the platform or the organization's own key can be used (403 GENAI_PLAN_REQUIRED).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "description",
                  "sources"
                ],
                "properties": {
                  "description": {
                    "type": "string",
                    "maxLength": 4000,
                    "description": "What to predict, in the user's words.",
                    "example": "Which support tickets are urgent"
                  },
                  "sources": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 5,
                    "items": {
                      "type": "string"
                    },
                    "description": "Identifiers of the sources (the first one is a good main source)."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120,
                    "description": "Name; otherwise the AI proposes one."
                  },
                  "lang": {
                    "type": "string",
                    "description": "Language of the plan and of the reasons (es, en, cat, fr...)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The model and its plan.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "model": {
                      "$ref": "#/components/schemas/GenAIModel"
                    },
                    "dropped": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "item": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "spent_eur": {
                      "type": "number"
                    },
                    "tokens_in": {
                      "type": "integer"
                    },
                    "tokens_out": {
                      "type": "integer"
                    },
                    "estimate": {
                      "$ref": "#/components/schemas/GenAIEstimate"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "BAD_DESCRIPTION, BAD_SOURCES, or the text was not accepted (REQUEST_NOT_ALLOWED...)."
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "GENAI_PLAN_REQUIRED, LIMIT (models per workspace) or a spending limit of the AI."
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          },
          "422": {
            "description": "NOT_UNDERSTOOD: no plan could be made from the description."
          },
          "429": {
            "description": "Too many requests or a spending limit (SPEND_LIMIT, ORG_SPEND_LIMIT)."
          },
          "503": {
            "description": "ASSISTANT_DISABLED or MODEL_UNAVAILABLE."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/genai-models/config": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "Whether models with generative AI can be used here (`available`, else `code`: ASSISTANT_DISABLED or GENAI_PLAN_REQUIRED), the AI model (cost_free, own_key), the fixed cost of a plan, the default spending limit of a run, the limits and what the user may do. Requires the read_models permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "available": {
                      "type": "boolean"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "model": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        },
                        "local": {
                          "type": "boolean"
                        },
                        "own_key": {
                          "type": "boolean"
                        },
                        "cost_free": {
                          "type": "boolean"
                        }
                      }
                    },
                    "plan_estimate_eur": {
                      "type": "number"
                    },
                    "default_cap_eur": {
                      "type": "number"
                    },
                    "kinds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "limits": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "can": {
                      "type": "object",
                      "properties": {
                        "read": {
                          "type": "boolean"
                        },
                        "create": {
                          "type": "boolean"
                        },
                        "edit": {
                          "type": "boolean"
                        },
                        "check": {
                          "type": "boolean"
                        },
                        "apply": {
                          "type": "boolean"
                        },
                        "delete": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/genai-models/{genaiModelId}": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "A model with generative AI: its plan, its last check (with its result) and its last run (with why it stopped and the source of the predictions). While a check or a run is in progress, read it every few seconds: it catches up with its task. Requires the read_models permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "genaiModelId",
            "description": "Identifier of the model with generative AI",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The model.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenAIModel"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          }
        }
      },
      "post": {
        "tags": [
          "models"
        ],
        "description": "Corrects the plan (only the keys sent; it is checked again against the sources as the plan of the AI), the name or the description. No cost. Requires the model_edit permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "genaiModelId",
            "description": "Identifier of the model with generative AI",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "plan": {
                    "type": "object",
                    "description": "The keys of the plan that change: question, task, answers, inputs, past_answers (or null), guidance, number_range.",
                    "example": {
                      "answers": [
                        "urgent",
                        "normal",
                        "low"
                      ],
                      "past_answers": {
                        "source": "SOURCE_ID",
                        "field": "priority"
                      }
                    }
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The model, what was left out and a new estimate.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "model": {
                      "$ref": "#/components/schemas/GenAIModel"
                    },
                    "dropped": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "estimate": {
                      "$ref": "#/components/schemas/GenAIEstimate"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "BAD_PLAN, BAD_SOURCES or a text that was not accepted."
          },
          "401": {
            "description": "Invalid authorization"
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          }
        }
      },
      "delete": {
        "tags": [
          "models"
        ],
        "description": "Deletes the model; the source of its predictions stays. Requires the model_delete permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "genaiModelId",
            "description": "Identifier of the model with generative AI",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/genai-models/{genaiModelId}/estimate": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "What each paid step would cost, in charged euros, from counts and a small sample (the data is never read whole): the check on up to 100 rows with a known answer, and the apply with the limits of the run. Zero with the cost-free model or the organization's own key. Spends nothing. Requires the read_models permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "genaiModelId",
            "description": "Identifier of the model with generative AI",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "max_eur": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 200,
                    "description": "Spending limit of the run in charged euros (default: what is left of the AI credits or monthly caps of the user and the organization, at most 5)."
                  },
                  "max_rows": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50000,
                    "description": "Maximum rows sent to the model in the run (default 20000)."
                  },
                  "only_missing": {
                    "type": "boolean",
                    "description": "Only the rows without a known answer (default true when the plan has a field of known answers)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The estimate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenAIEstimate"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          },
          "409": {
            "description": "PLAN_NOT_READY or SOURCE_MISSING."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/genai-models/{genaiModelId}/check": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "Checks the plan, as a task: predicts up to 100 rows that already have the answer (stratified by answer, without seeing it), with a few others as examples, and measures the hit rate or the error next to a simple rule. A paid step: it runs only with the `estimate_id` of the check the user accepted, or `confirm_eur`. Requires the model_create or model_edit permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "genaiModelId",
            "description": "Identifier of the model with generative AI",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "estimate_id": {
                    "type": "string",
                    "description": "The `estimate_id` of the step, from the estimate the user accepted."
                  },
                  "confirm_eur": {
                    "type": "number",
                    "description": "Instead of `estimate_id`: an amount in euros the user accepted, at least the `payable_eur` of the step now."
                  },
                  "max_eur": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 200,
                    "description": "Spending limit of the run in charged euros (default: what is left of the AI credits or monthly caps of the user and the organization, at most 5)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task created (poll GET .../genai-models/{genaiModelId}, which catches up with the task).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "task": {
                      "type": "string"
                    },
                    "refresh": {
                      "type": "boolean"
                    },
                    "model": {
                      "$ref": "#/components/schemas/GenAIModel"
                    },
                    "estimate": {
                      "$ref": "#/components/schemas/GenAIEstimate"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "GENAI_PLAN_REQUIRED, LIMIT (task time or parallel tasks) or a spending limit."
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          },
          "409": {
            "description": "ESTIMATE_NOT_CONFIRMED (409): the step was not confirmed or its cost changed; `details.estimate` has the current estimate to show to the user and confirm again. Also NO_PAST_ANSWERS (fewer than 20 known answers), PLAN_NOT_READY, PLAN_OUTDATED, SOURCE_MISSING or RUN_IN_PROGRESS."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/genai-models/{genaiModelId}/apply": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "Applies the model to the rows of the main source, as a task: many rows per call, every answer validated against the plan, answers cached by row content (a refresh pays only for new or changed rows), and the limits of the run checked before every call: it stops cleanly at the first one and keeps what it got. The first run creates a source with the predictions, a one-sentence reason and a status per row; the next ones replace it. A paid step: send the `estimate_id` of the apply the user accepted with the same max_eur, max_rows and only_missing, or `confirm_eur`. Requires the source_create permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "genaiModelId",
            "description": "Identifier of the model with generative AI",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "estimate_id": {
                    "type": "string",
                    "description": "The `estimate_id` of the step, from the estimate the user accepted."
                  },
                  "confirm_eur": {
                    "type": "number",
                    "description": "Instead of `estimate_id`: an amount in euros the user accepted, at least the `payable_eur` of the step now."
                  },
                  "max_eur": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 200,
                    "description": "Spending limit of the run in charged euros (default: what is left of the AI credits or monthly caps of the user and the organization, at most 5)."
                  },
                  "max_rows": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50000,
                    "description": "Maximum rows sent to the model in the run (default 20000)."
                  },
                  "only_missing": {
                    "type": "boolean",
                    "description": "Only the rows without a known answer (default true when the plan has a field of known answers)."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120,
                    "description": "Name of the source of the predictions (first run)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task created (poll GET .../genai-models/{genaiModelId}, which catches up with the task).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "task": {
                      "type": "string"
                    },
                    "refresh": {
                      "type": "boolean"
                    },
                    "model": {
                      "$ref": "#/components/schemas/GenAIModel"
                    },
                    "estimate": {
                      "$ref": "#/components/schemas/GenAIEstimate"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "GENAI_PLAN_REQUIRED, LIMIT (sources, task time or parallel tasks) or a spending limit."
          },
          "404": {
            "description": "Workspace or model not found (NOT_FOUND)"
          },
          "409": {
            "description": "ESTIMATE_NOT_CONFIRMED (409): the step was not confirmed or its cost changed; `details.estimate` has the current estimate to show to the user and confirm again. Also NO_ROWS, PLAN_NOT_READY, PLAN_OUTDATED, SOURCE_MISSING or RUN_IN_PROGRESS."
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/recommendations": {
      "get": {
        "tags": [
          "ai"
        ],
        "description": "«Recommendations without sharing your data»: everything that can be done with a source (or with the workspace) in AIR-Core, worked out WITHOUT AI and without cost from its structure (names and types of the fields) and the statistics the platform already keeps of each source: what can be predicted, a forecast, an automatic dashboard, automations worth having, text columns worth enriching with AI, fields that look like personal data (a privacy warning), likely joins between sources, data quality and example questions. Available on every plan. Each recommendation has its texts in Spanish and English and the action that does it. `preview` is EXACTLY the text the AI would receive with the explanation with AI, without (`structure`) and with (`statistics`) aggregate statistics: names and types, and only rows, share of missing values and number of distinct values; never a value, a category, a sample or a row. Requires read access to the workspace.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "description": "Identifier of a source of the workspace. Without it, the recommendations cover the most recently used sources of the workspace (up to 20) and the joins between them.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "description": "Language of the texts written for the user (es, en, cat...). By default, the one of the request.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The recommendations, the most valuable first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "scope": {
                      "type": "string",
                      "enum": [
                        "source",
                        "workspace"
                      ]
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "rows": {
                            "type": "integer"
                          },
                          "fields": {
                            "type": "integer"
                          },
                          "columns": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "type": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "receives_data": {
                            "type": "string",
                            "enum": [
                              "static",
                              "updates",
                              "real_time",
                              "external",
                              "derived"
                            ]
                          },
                          "statistics": {
                            "type": "string",
                            "enum": [
                              "stored",
                              "sample",
                              "none"
                            ]
                          }
                        }
                      }
                    },
                    "recommendations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "predict",
                              "forecast",
                              "dashboard",
                              "alert_threshold",
                              "alert_no_data",
                              "enrich_text",
                              "genai_model",
                              "personal_data",
                              "join",
                              "quality",
                              "ask"
                            ]
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "high",
                              "medium",
                              "low"
                            ]
                          },
                          "score": {
                            "type": "number"
                          },
                          "source": {
                            "type": "string"
                          },
                          "source_name": {
                            "type": "string"
                          },
                          "fields": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Names of the fields involved (for join: the field of the source, then the field of the other source)."
                          },
                          "basis": {
                            "type": "string",
                            "enum": [
                              "structure",
                              "statistics"
                            ],
                            "description": "Whether it rests on the names and types only, or also on the statistics the platform keeps of the source."
                          },
                          "needs_ai": {
                            "type": "boolean",
                            "description": "Doing it uses generative AI (enrichment, models with generative AI, the assistant)."
                          },
                          "details": {
                            "type": "object",
                            "additionalProperties": true,
                            "description": "What the kind needs: target, model_type and target_index (predict); date and value (forecast); metric, dimension, date and charts (dashboard); field, op and a suggested level (alert_threshold, computed by the platform, never sent to the AI); hours (alert_no_data); field and task (enrich_text); text_field and label_field (genai_model); found, with the category of each field (personal_data); other_source, field and other_field (join); problems (quality); questions (ask)."
                          },
                          "action": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "model_wizard",
                                  "forecast_wizard",
                                  "auto_dashboard",
                                  "alert_wizard",
                                  "enrich",
                                  "genai_wizard",
                                  "ask",
                                  "join_source",
                                  "filter_source",
                                  "none"
                                ]
                              },
                              "payload": {
                                "type": "object",
                                "nullable": true,
                                "additionalProperties": true
                              }
                            },
                            "description": "What does it in the interface, with its values. Built by the platform from the structure, never by an AI."
                          },
                          "text": {
                            "type": "object",
                            "properties": {
                              "es": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "why": {
                                    "type": "string"
                                  }
                                }
                              },
                              "en": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "why": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          },
                          "ai_why": {
                            "type": "string",
                            "description": "Only in the answer of the AI: why, written by it for this data."
                          }
                        }
                      }
                    },
                    "ai": {
                      "type": "object",
                      "description": "Whether the explanation with AI can be used here.",
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "allowed": {
                          "type": "boolean"
                        },
                        "code": {
                          "type": "string",
                          "description": "ASSISTANT_DISABLED, AI_PLAN_REQUIRED or empty."
                        },
                        "message": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "label": {
                              "type": "string"
                            },
                            "local": {
                              "type": "boolean"
                            },
                            "own_key": {
                              "type": "boolean"
                            },
                            "cost_free": {
                              "type": "boolean"
                            }
                          }
                        },
                        "free_plan": {
                          "type": "boolean"
                        },
                        "estimate_eur": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "structure": {
                              "type": "number"
                            },
                            "statistics": {
                              "type": "number"
                            }
                          },
                          "description": "What one explanation would cost, as charged to the AI credits (0 with the organization's own key)."
                        }
                      }
                    },
                    "preview": {
                      "type": "object",
                      "properties": {
                        "structure": {
                          "type": "string"
                        },
                        "statistics": {
                          "type": "string"
                        }
                      },
                      "description": "The exact text sent to the AI, without and with statistics."
                    },
                    "instructions": {
                      "type": "string",
                      "description": "The fixed instructions sent with it; they contain nothing of the data."
                    },
                    "values_sent": {
                      "type": "integer",
                      "description": "Always 0."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "404": {
            "description": "Workspace or source not found (NOT_FOUND)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/recommendations/ai": {
      "post": {
        "tags": [
          "ai"
        ],
        "description": "The recommendations explained and extended by AI. The AI receives ONLY the structure (the `preview` of GET .../recommendations, the same text character by character): names of the sources and fields and their types and, with `statistics`, rows, share of missing values and number of distinct values; never a value, a category, a sample or a row. It answers with a plain-language reading and up to 10 prioritised recommendations with why; the answer is sanitised (only the known kinds, the sources sent and the fields that exist) and the action of each one is built by the platform. Paid plans are charged to their AI credits; the free plan works with AI credit (bought or given by AIR-Core) or the organization's own AI key, and otherwise never with a model of the platform (403 AI_PLAN_REQUIRED). The AI activity log records the call with `sent: structure_only`. The same structure again returns the kept answer at no cost (`cached`). Spending caps, guardrails and the rate limit of the AI apply. Needs a token that can write and read access to the workspace.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "A source of the workspace; without it, the workspace."
                  },
                  "statistics": {
                    "type": "boolean",
                    "description": "Also send aggregate statistics, without values (default false)."
                  },
                  "lang": {
                    "type": "string",
                    "description": "Language of the answer (es, en, cat, fr...)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The explanation of the AI.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "scope": {
                      "type": "string",
                      "enum": [
                        "source",
                        "workspace"
                      ]
                    },
                    "reading": {
                      "type": "string",
                      "description": "What the data seems to be about and what is most worth doing."
                    },
                    "recommendations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "predict",
                              "forecast",
                              "dashboard",
                              "alert_threshold",
                              "alert_no_data",
                              "enrich_text",
                              "genai_model",
                              "personal_data",
                              "join",
                              "quality",
                              "ask"
                            ]
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "high",
                              "medium",
                              "low"
                            ]
                          },
                          "score": {
                            "type": "number"
                          },
                          "source": {
                            "type": "string"
                          },
                          "source_name": {
                            "type": "string"
                          },
                          "fields": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Names of the fields involved (for join: the field of the source, then the field of the other source)."
                          },
                          "basis": {
                            "type": "string",
                            "enum": [
                              "structure",
                              "statistics"
                            ],
                            "description": "Whether it rests on the names and types only, or also on the statistics the platform keeps of the source."
                          },
                          "needs_ai": {
                            "type": "boolean",
                            "description": "Doing it uses generative AI (enrichment, models with generative AI, the assistant)."
                          },
                          "details": {
                            "type": "object",
                            "additionalProperties": true,
                            "description": "What the kind needs: target, model_type and target_index (predict); date and value (forecast); metric, dimension, date and charts (dashboard); field, op and a suggested level (alert_threshold, computed by the platform, never sent to the AI); hours (alert_no_data); field and task (enrich_text); text_field and label_field (genai_model); found, with the category of each field (personal_data); other_source, field and other_field (join); problems (quality); questions (ask)."
                          },
                          "action": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "model_wizard",
                                  "forecast_wizard",
                                  "auto_dashboard",
                                  "alert_wizard",
                                  "enrich",
                                  "genai_wizard",
                                  "ask",
                                  "join_source",
                                  "filter_source",
                                  "none"
                                ]
                              },
                              "payload": {
                                "type": "object",
                                "nullable": true,
                                "additionalProperties": true
                              }
                            },
                            "description": "What does it in the interface, with its values. Built by the platform from the structure, never by an AI."
                          },
                          "text": {
                            "type": "object",
                            "properties": {
                              "es": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "why": {
                                    "type": "string"
                                  }
                                }
                              },
                              "en": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "why": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          },
                          "ai_why": {
                            "type": "string",
                            "description": "Only in the answer of the AI: why, written by it for this data."
                          }
                        }
                      }
                    },
                    "dropped": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string",
                            "enum": [
                              "UNKNOWN_KIND",
                              "UNKNOWN_SOURCE",
                              "UNKNOWN_FIELD",
                              "NO_JOIN",
                              "NOT_POSSIBLE"
                            ]
                          }
                        }
                      },
                      "description": "What the AI proposed that does not fit the data."
                    },
                    "sent": {
                      "type": "string",
                      "description": "Exactly what was sent to the AI."
                    },
                    "statistics": {
                      "type": "boolean"
                    },
                    "model": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        },
                        "local": {
                          "type": "boolean"
                        },
                        "own_key": {
                          "type": "boolean"
                        },
                        "cost_free": {
                          "type": "boolean"
                        }
                      }
                    },
                    "cached": {
                      "type": "boolean"
                    },
                    "values_sent": {
                      "type": "integer",
                      "description": "Always 0."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token cannot write (ACCESS_DENIED), or the explanation with AI is not allowed: AI_PLAN_REQUIRED (free plan without AI credit or the organization's own AI key)."
          },
          "404": {
            "description": "Workspace or source not found (NOT_FOUND)"
          },
          "429": {
            "description": "Too many requests to the AI features (TOO_MANY_REQUESTS), or a spending cap reached (SPEND_LIMIT, ORG_SPEND_LIMIT, GLOBAL_SPEND_LIMIT)."
          },
          "503": {
            "description": "Generative AI is not enabled (ASSISTANT_DISABLED) or the model is not available (MODEL_UNAVAILABLE)."
          }
        }
      }
    },
    "/scim/v2/{organization}/ServiceProviderConfig": {
      "get": {
        "tags": [
          "scim"
        ],
        "summary": "SCIM service provider configuration",
        "description": "Features of the SCIM endpoint: PATCH, filters (up to 200 results) and ETags; no bulk, sorting or password changes.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Configuration",
            "content": {
              "application/scim+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      }
    },
    "/scim/v2/{organization}/ResourceTypes": {
      "get": {
        "tags": [
          "scim"
        ],
        "summary": "SCIM resource types",
        "description": "User and Group.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of resource types",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      }
    },
    "/scim/v2/{organization}/Schemas": {
      "get": {
        "tags": [
          "scim"
        ],
        "summary": "SCIM schemas",
        "description": "The attributes of User and Group that AIR-Core keeps.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of schemas",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      }
    },
    "/scim/v2/{organization}/Users": {
      "get": {
        "tags": [
          "scim"
        ],
        "summary": "List or filter provisioned users",
        "description": "Users provisioned in the organization, filtered and paged.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "SCIM filter (RFC 7644 3.4.2.2): eq, ne, co, sw, ew, gt, ge, lt, le, pr, and, or, not, parentheses and value paths, e.g. userName eq \"ana@example.com\"",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "startIndex",
            "in": "query",
            "required": false,
            "description": "1-based index of the first result",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "count",
            "in": "query",
            "required": false,
            "description": "Results per page (at most 200)",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 200,
              "default": 100
            }
          },
          {
            "name": "attributes",
            "in": "query",
            "required": false,
            "description": "Top-level attributes to return (comma separated)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "excludedAttributes",
            "in": "query",
            "required": false,
            "description": "Top-level attributes to leave out (comma separated), e.g. members",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of users",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid filter (scimType invalidFilter)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "scim"
        ],
        "summary": "Provision a user",
        "description": "The email (primary of emails, or userName) must be of a domain verified by the organization. The AIR-Core account with that email is linked, or a corporate account is created, and it joins the organization with the role of the new members (or of its groups). active false creates it suspended.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimUser"
              },
              "example": {
                "schemas": [
                  "urn:ietf:params:scim:schemas:core:2.0:User"
                ],
                "userName": "ana@example.com",
                "externalId": "8a1c-…",
                "name": {
                  "givenName": "Ana",
                  "familyName": "García"
                },
                "emails": [
                  {
                    "value": "ana@example.com",
                    "type": "work",
                    "primary": true
                  }
                ],
                "active": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created (Location and ETag headers)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                }
              }
            }
          },
          "400": {
            "description": "Invalid value, e.g. an email of a domain that is not verified",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "403": {
            "description": "The organization has no free places for more members",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "409": {
            "description": "userName or externalId already used (scimType uniqueness)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      }
    },
    "/scim/v2/{organization}/Users/{id}": {
      "get": {
        "tags": [
          "scim"
        ],
        "summary": "Read a provisioned user",
        "description": "",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the user",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the copy you have: 304 if unchanged",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The user (ETag header)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                }
              }
            }
          },
          "304": {
            "description": "Not modified"
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "scim"
        ],
        "summary": "Replace a provisioned user",
        "description": "Replaces userName, externalId, name, displayName, emails and active.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the user",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the resource (W/\"<version>\"): the change is refused with 412 if it was modified",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimUser"
              },
              "example": {
                "schemas": [
                  "urn:ietf:params:scim:schemas:core:2.0:User"
                ],
                "userName": "ana@example.com",
                "externalId": "8a1c-…",
                "name": {
                  "givenName": "Ana",
                  "familyName": "García"
                },
                "emails": [
                  {
                    "value": "ana@example.com",
                    "type": "work",
                    "primary": true
                  }
                ],
                "active": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The user",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "412": {
            "description": "ETag does not match",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "scim"
        ],
        "summary": "Update a provisioned user (PatchOp)",
        "description": "add, replace and remove (any case, booleans also as text). active false suspends the membership in the organization (the role is kept to give it back); the account and its data are never deleted. The owner cannot be deactivated. Attributes AIR-Core does not keep are accepted and ignored.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the user",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the resource (W/\"<version>\"): the change is refused with 412 if it was modified",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimPatchOp"
              },
              "example": {
                "schemas": [
                  "urn:ietf:params:scim:api:messages:2.0:PatchOp"
                ],
                "Operations": [
                  {
                    "op": "replace",
                    "path": "active",
                    "value": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The user",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                }
              }
            }
          },
          "400": {
            "description": "Invalid operation",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "412": {
            "description": "ETag does not match",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "scim"
        ],
        "summary": "Deprovision a user",
        "description": "Suspends the membership, takes back what its groups gave and hides the user from SCIM. Nothing is deleted from AIR-Core, and the person cannot come back with the corporate sign-in until provisioned again.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the user",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the resource (W/\"<version>\"): the change is refused with 412 if it was modified",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deprovisioned"
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      }
    },
    "/scim/v2/{organization}/Groups": {
      "get": {
        "tags": [
          "scim"
        ],
        "summary": "List or filter provisioned groups",
        "description": "",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "SCIM filter (RFC 7644 3.4.2.2): eq, ne, co, sw, ew, gt, ge, lt, le, pr, and, or, not, parentheses and value paths, e.g. userName eq \"ana@example.com\"",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "startIndex",
            "in": "query",
            "required": false,
            "description": "1-based index of the first result",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "count",
            "in": "query",
            "required": false,
            "description": "Results per page (at most 200)",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 200,
              "default": 100
            }
          },
          {
            "name": "attributes",
            "in": "query",
            "required": false,
            "description": "Top-level attributes to return (comma separated)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "excludedAttributes",
            "in": "query",
            "required": false,
            "description": "Top-level attributes to leave out (comma separated), e.g. members",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of groups",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid filter",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "scim"
        ],
        "summary": "Provision a group",
        "description": "Members must be users of the same organization (others are ignored). The group rules of the single sign-on settings (by displayName, externalId or id) give a role or workspace permissions to its members.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimGroup"
              },
              "example": {
                "schemas": [
                  "urn:ietf:params:scim:schemas:core:2.0:Group"
                ],
                "displayName": "Analysts",
                "members": [
                  {
                    "value": "<user id>"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "409": {
            "description": "displayName already used",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      }
    },
    "/scim/v2/{organization}/Groups/{id}": {
      "get": {
        "tags": [
          "scim"
        ],
        "summary": "Read a provisioned group",
        "description": "",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the group",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the copy you have: 304 if unchanged",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The group",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                }
              }
            }
          },
          "304": {
            "description": "Not modified"
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "scim"
        ],
        "summary": "Replace a provisioned group",
        "description": "",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the group",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the resource (W/\"<version>\"): the change is refused with 412 if it was modified",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimGroup"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The group",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "412": {
            "description": "ETag does not match",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "scim"
        ],
        "summary": "Update a provisioned group (PatchOp)",
        "description": "Add or remove members (also members[value eq \"<id>\"]), rename it.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the group",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the resource (W/\"<version>\"): the change is refused with 412 if it was modified",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimPatchOp"
              },
              "example": {
                "schemas": [
                  "urn:ietf:params:scim:api:messages:2.0:PatchOp"
                ],
                "Operations": [
                  {
                    "op": "add",
                    "path": "members",
                    "value": [
                      {
                        "value": "<user id>"
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The group",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "412": {
            "description": "ETag does not match",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "scim"
        ],
        "summary": "Delete a provisioned group",
        "description": "Its members lose what the group gave them.",
        "security": [
          {
            "scimBearer": []
          }
        ],
        "parameters": [
          {
            "name": "organization",
            "in": "path",
            "required": true,
            "description": "Identifier of the organization (its SCIM base URL is /scim/v2/{organization})",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the group",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "ETag of the resource (W/\"<version>\"): the change is refused with 412 if it was modified",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "Missing, wrong or revoked token, or a token of another organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this organization",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for the organization, or too many failed authentications from the address (Retry-After: 60)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/comments": {
      "get": {
        "tags": [
          "collaboration"
        ],
        "description": "Lists the comment threads of a dashboard (the whole of it and its cards) or a visualization, with their comments, and how many are open by card. Anyone who can read the dashboard (read_dashboards) or the visualization (read_views) reads and writes its comments. Comments never appear in shared links, public views or embedded views.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "target_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "dashboard",
                "visualization"
              ]
            }
          },
          {
            "name": "target_id",
            "in": "query",
            "required": true,
            "description": "Identifier of the dashboard or the visualization",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "resolved"
              ]
            }
          },
          {
            "name": "card",
            "in": "query",
            "description": "Only the threads of a card of the dashboard: the index of its section and the number (i) of the piece, as in its configuration, e.g. 0:3",
            "schema": {
              "type": "string",
              "example": "0:3"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The threads, the latest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "target": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string"
                        },
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    },
                    "threads": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CommentThread"
                      }
                    },
                    "counts": {
                      "$ref": "#/components/schemas/CommentCounts"
                    },
                    "max_length": {
                      "type": "integer",
                      "example": 2000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          },
          "404": {
            "description": "Workspace, dashboard or visualization not found, or the user cannot read it (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "collaboration"
        ],
        "description": "Starts a thread on a dashboard (the whole of it, or a card with `card`) or on a visualization. Plain text and links, up to 2,000 characters; to mention someone, write @ and their name as the application shows it. Only people who can read what is commented can be mentioned; they are notified in the application and by email (a digest, at most one an hour, if they want it).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "target_type",
                  "target_id",
                  "text"
                ],
                "properties": {
                  "target_type": {
                    "type": "string",
                    "enum": [
                      "dashboard",
                      "visualization"
                    ]
                  },
                  "target_id": {
                    "type": "string"
                  },
                  "card": {
                    "type": "string",
                    "example": "0:3"
                  },
                  "text": {
                    "type": "string",
                    "maxLength": 2000,
                    "example": "@Ana, ¿puedes revisar el pico de marzo?"
                  },
                  "lang": {
                    "type": "string",
                    "description": "Language of the email notices (es, en or ca)",
                    "example": "es"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new thread",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "$ref": "#/components/schemas/CommentThread"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long text (EMPTY, TOO_LONG), a card that is not in the dashboard (CARD_NOT_FOUND) or a wrong target (BAD_TARGET)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          },
          "404": {
            "description": "Not found, or the user cannot read it (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "429": {
            "description": "Too many comments in a short time (RATE_LIMIT)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/comments/{threadId}": {
      "get": {
        "tags": [
          "collaboration"
        ],
        "description": "A thread with its comments.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "threadId",
            "description": "Identifier of the thread",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The thread",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "$ref": "#/components/schemas/CommentThread"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          },
          "404": {
            "description": "Not found, or the user cannot read it (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/comments/{threadId}/replies": {
      "post": {
        "tags": [
          "collaboration"
        ],
        "description": "Replies to a thread. The author of the thread is notified, and the people mentioned. A resolved thread that gets a reply is open again.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "threadId",
            "description": "Identifier of the thread",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "lang": {
                    "type": "string",
                    "example": "es"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new comment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "comment": {
                      "$ref": "#/components/schemas/Comment"
                    },
                    "thread_status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "resolved"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long text (EMPTY, TOO_LONG)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          },
          "404": {
            "description": "Not found, or the user cannot read it (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "429": {
            "description": "Too many comments in a short time (RATE_LIMIT)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/comments/{threadId}/status": {
      "post": {
        "tags": [
          "collaboration"
        ],
        "description": "Resolves or reopens a thread. Anyone who reads it can.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "threadId",
            "description": "Identifier of the thread",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "$ref": "#/components/schemas/CommentThread"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown status (BAD_TARGET)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          },
          "404": {
            "description": "Not found, or the user cannot read it (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/comment/{commentId}": {
      "post": {
        "tags": [
          "collaboration"
        ],
        "description": "Changes the text of a comment. Only its author can; the people mentioned for the first time are notified.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "commentId",
            "description": "Identifier of the comment",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 2000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The comment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "comment": {
                      "$ref": "#/components/schemas/Comment"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long text (EMPTY, TOO_LONG)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Not its author (FORBIDDEN_EDIT), or the token cannot write",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "404": {
            "description": "Not found, or the user cannot read it (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "collaboration"
        ],
        "description": "Deletes a comment: its author or an administrator of the workspace (who manages its permissions). A thread left without comments is deleted too.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "commentId",
            "description": "Identifier of the comment",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "thread_deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Neither its author nor an administrator (FORBIDDEN_DELETE), or the token cannot write",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "404": {
            "description": "Not found, or the user cannot read it (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/annotations": {
      "get": {
        "tags": [
          "collaboration"
        ],
        "description": "The annotations of dates of a visualization (its own and those of the date fields of its source) or of a source, oldest date first, and whether the user can add them.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "visualization",
            "in": "query",
            "description": "Identifier of a visualization",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "in": "query",
            "description": "Identifier of a source",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The annotations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "annotations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Annotation"
                      }
                    },
                    "can_add": {
                      "type": "object",
                      "properties": {
                        "visualization": {
                          "type": "boolean"
                        },
                        "source": {
                          "type": "boolean"
                        }
                      }
                    },
                    "max_length": {
                      "type": "integer",
                      "example": 120
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          },
          "404": {
            "description": "Not found (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "collaboration"
        ],
        "description": "Marks a date or a range with a short text on a visualization (its date axis) or on a date field of a source (every chart over that field, and the forecasts of the source). It needs permission to edit the visualization (view_edit) or the source (source_edit), or to own it. With `shared` it also shows in shared links and embedded views; comments never do.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnnotationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The annotation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "annotation": {
                      "$ref": "#/components/schemas/Annotation"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Wrong date or range (BAD_DATE, BAD_RANGE), not a date field (BAD_FIELD), empty or too long text (EMPTY, TOO_LONG)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission to edit the visualization or the source (FORBIDDEN_ANNOTATE), or the token cannot write",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "404": {
            "description": "Not found (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/annotations/{annotationId}": {
      "post": {
        "tags": [
          "collaboration"
        ],
        "description": "Changes an annotation: only the fields sent. The same permission as adding it.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "annotationId",
            "description": "Identifier of the annotation",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "field": {
                    "oneOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "string"
                      }
                    ]
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "shared": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The annotation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "annotation": {
                      "$ref": "#/components/schemas/Annotation"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Wrong values (BAD_DATE, BAD_RANGE, BAD_FIELD, EMPTY, TOO_LONG)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission (FORBIDDEN_ANNOTATE)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "404": {
            "description": "Not found (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "collaboration"
        ],
        "description": "Deletes an annotation. The same permission as adding it.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "annotationId",
            "description": "Identifier of the annotation",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "No permission (FORBIDDEN_ANNOTATE)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          },
          "404": {
            "description": "Not found (NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollabError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/notifications": {
      "get": {
        "tags": [
          "collaboration"
        ],
        "description": "The latest notifications of the user (someone mentioned them or replied to their thread) that they can still open, and how many are unread.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30
            }
          },
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The notifications",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Notification"
                      }
                    },
                    "unread": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          }
        }
      }
    },
    "/api/v2/notifications/read": {
      "post": {
        "tags": [
          "collaboration"
        ],
        "description": "Marks a notification, or all of them (`all`), as read.",
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "example": "all"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "unread": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "The token lacks the permission to read (or to write) workspaces (ACCESS_DENIED)"
          }
        }
      }
    },
    "/api/v2/ai/policy": {
      "get": {
        "description": "AI data policy of the organization: what its data may show to a language model. Levels: `structure` (names and types of the fields only), `aggregates` (also results computed by AIR-Core, never rows) and `rows` (also rows, texts and documents, only with providers that process the data in the EU or with the organization's own AI key). Workspaces may have a stricter level. Every AI feature checks it before calling a model and refuses what needs more. Any member of the organization may read it.",
        "tags": [
          "ai"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AIPolicy"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Not a member of the organization",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/ai/register": {
      "get": {
        "description": "Register of the AI systems of the organization (Regulation (EU) 2024/1689, AI Act): the built-in AI features of AIR-Core and the organization's own models, with purpose, risk category, prohibited practices reviewed, provider and model, human oversight, transparency, data used, logs, responsible person, last review and the articles that may be relevant. Descriptive, not legal advice. Organization administrators only.",
        "tags": [
          "ai"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The register",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AIRegister"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Only the owner or the administrators of the organization",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/ai/register/report": {
      "get": {
        "description": "Report of the register of AI systems, as a self-contained HTML document or, with `format=pdf`, as a PDF (an installation that cannot make PDFs answers the HTML with the header `X-Report-Format: html`). Organization administrators only.",
        "tags": [
          "ai"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "html",
                "pdf"
              ]
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the report (en, es, cat, fr, de, zh, ja)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Only the owner or the administrators of the organization",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/ai/audit": {
      "get": {
        "description": "Export of the AI of the organization for audits: the AI data policy and the providers that apply, the choices about personal data of each source (field names and kinds, never values), the register of AI systems and the AI activity with «what the AI saw» of every call (level, sources and fields, whether values or rows were sent and how many, fields masked or not sent). Never the data itself. At most 20000 entries of activity, the newest. Organization administrators only.",
        "tags": [
          "ai"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Start date (ISO 8601)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "End date (ISO 8601)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The audit export",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AIAudit"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Only the owner or the administrators of the organization",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/ai/limits": {
      "get": {
        "description": "Limits of the use of AI that the organization set per role and per person (Members and roles), with the use of the month of each member. Modes: `all`, `free` (only AI that spends no credits: the platform's models at no cost or the organization's own key) and `none`. `spend_eur`: most AI credit (charged euros) per month with the platform's models that cost credits; `tokens`: most tokens (input + output) per month of AI that spends no credits; null is no limit of its own (the credits and the caps of the platform still apply). A person's own limits replace those of their role; the owner is never limited. They renew on day 1 and are checked before every call to a model. The AI apps connected through MCP (Claude, ChatGPT…) use their own AI and are not counted. Organization administrators only.",
        "tags": [
          "ai"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Autentication token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-organization",
            "description": "Identifier of the organization (optional, defaults to the first one of the user)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The limits and the use of the month",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AILimits"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Only the owner or the administrators of the organization",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sql/tables": {
      "get": {
        "description": "The tables a read-only SQL query can read in a workspace: one per data source, named after it (lower case, no accents, `_` between words, unique), with its columns (`name` as SQL sees it, `sql` as a query writes it, the field it comes from and its type); the caps of the plan of the organization; and the functions a query may call. Reads no rows. For people with a token that reads workspaces and permission to read the sources of the workspace; AI applications connected through MCP, MCP clients and the assistant get 403 SQL_NOT_FOR_AI_APPS.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tables, the caps and the functions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlTables"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED (the token does not read workspaces) or SQL_NOT_FOR_AI_APPS",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "404": {
            "description": "Workspace not found, or no permission to read its sources"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sql": {
      "post": {
        "description": "Runs a read-only SQL query (SQLite dialect) over one or several data sources of the workspace and answers a page of its result, or the whole result as CSV with `format: csv`. One statement that starts with SELECT, WITH or VALUES; never ATTACH, PRAGMA, writes, extensions, the internals of SQLite, parameters or functions outside the allowed list (see GET .../sql/tables). The tables are the ones of GET .../sql/tables; `sources` gives a source of this workspace another table name (a source of another workspace or organization is refused, SQL_UNKNOWN_SOURCE, without reading it). Only the tables and columns the query names are read, up to the caps of the plan: a read cut by a cap says so in `read.partial`. The query runs in a process of its own, stopped at the time or memory limit of the plan (SQL_TIMEOUT, SQL_MEMORY_LIMIT). One query at a time per person. For people with a token that reads workspaces and permission to read the sources of the workspace (the same rows and columns they see on the page of each source); AI applications connected through MCP, MCP clients and the assistant get 403 SQL_NOT_FOR_AI_APPS.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SqlQuery"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A page of the result (JSON), or the whole result as CSV (UTF-8 with a byte order mark, at most `max_result_rows` of the plan) with format csv",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlResult"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The query is refused or fails, with its place in the text when known: SQL_EMPTY, SQL_TOO_LONG, SQL_SYNTAX, SQL_MULTIPLE_STATEMENTS, SQL_NOT_A_QUERY, SQL_NOT_READ_ONLY, SQL_FORBIDDEN_STATEMENT, SQL_FORBIDDEN_NAME, SQL_FUNCTION_NOT_ALLOWED, SQL_PARAMETERS, SQL_UNKNOWN_TABLE, SQL_UNKNOWN_COLUMN, SQL_UNKNOWN_FUNCTION, SQL_ERROR, SQL_BAD_ALIAS, SQL_BAD_SOURCES, SQL_TOO_MANY_SOURCES, SQL_TOO_MANY_COLUMNS, SQL_TIMEOUT or SQL_MEMORY_LIMIT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED (the token does not read workspaces) or SQL_NOT_FOR_AI_APPS",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "404": {
            "description": "Workspace not found, no permission to read its sources, or SQL_UNKNOWN_SOURCE (an alias names a source that is not in this workspace)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "429": {
            "description": "SQL_BUSY (a query of the same person, or too many of the server, are running) or TOO_MANY_REQUESTS (30 queries per minute)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "503": {
            "description": "SOURCE_UNAVAILABLE: the data of a table could not be read right now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/sql/source": {
      "post": {
        "description": "Saves a read-only SQL query as a new derived data source (type `sql`) that is computed again whenever one of the sources it reads changes. The query is checked and prepared (its columns are known without reading any row); every table must be a stored source of the workspace and their rows must fit the cap of the plan, because a saved query reads them whole. Each run checks again that its owner can read the sources of the workspace, the query, the caps of the current plan and its columns. Answers the task that creates the source. Needs a token that writes workspaces, permission to read the sources and to create sources and tasks; AI applications connected through MCP, MCP clients and the assistant get 403 SQL_NOT_FOR_AI_APPS.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SqlSaveSource"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The task that creates the source",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "example": "success"
                    },
                    "task_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "BAD_NAME, BAD_DESCRIPTION, SQL_NO_TABLES, EXTERNAL, SQL_TOO_MANY_ROWS or any refusal of the query (see POST .../sql)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED (the token does not write workspaces, or no permission to create sources and tasks), LIMIT (plan) or SQL_NOT_FOR_AI_APPS",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "404": {
            "description": "Workspace not found, no permission to read its sources, or SQL_UNKNOWN_SOURCE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          },
          "429": {
            "description": "SQL_BUSY or TOO_MANY_REQUESTS",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/quality/rules": {
      "get": {
        "description": "The data quality rules of a source («Calidad»): per column (not_empty, unique, range, allowed_values, pattern, not_future) or on the source (row_count, freshness), each with its severity (warning or error) and whether it is enabled. A rule names its field by name; `index` is its position now (-1 and `missing: true` when the field is gone: the rule then fails). With `suggestions=true`, the rules AIR-Core suggests from the catalogue of the source, the statistics of its columns, the names of the columns and its automatic updates, each with its `reason` (nothing is saved until they are sent with PUT). An AI application connected through MCP gets the rules without the values they hold (allowed values, bounds, the text of a pattern) below the level «aggregates» of the AI data policy, or for a field with personal data not allowed (`withheld_for_ai`). Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "suggestions",
            "description": "true: adds the suggested rules",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QualityRules"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      },
      "put": {
        "description": "Replaces the quality rules of a source with the list sent (an empty list removes them) and checks them now: the answer waits up to 20 seconds for the check (`checking: true` when it goes on in the background). A rule keeps its `id` when it sends one of the current list (its history and its alerts follow it); the other ones get a new id. Up to 30 rules. Refused (400), never cut: an unknown kind, key or parameter, a field that does not exist or of a type the kind does not apply to, invalid parameters or a repeated rule. `alert` turns the quality alert of the source on or off, with a threshold of the score (needs permission to edit the workspace). External and real-time sources cannot have rules (UNSUPPORTED_SOURCE). Needs a token that writes workspaces and permission to edit the source (or to own it). Answers the report as GET .../quality does.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QualityRulesChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The report of the source with its new rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QualityReport"
                }
              }
            }
          },
          "400": {
            "description": "BAD_REQUEST, TOO_MANY_RULES, UNKNOWN_KEY, UNKNOWN_KIND, UNKNOWN_FIELD, FIELD_TYPE, BAD_SEVERITY, BAD_PARAMS, DUPLICATE_RULE (details.rule: its position), BAD_THRESHOLD or UNSUPPORTED_SOURCE"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED: without permission to edit the source, or the workspace for `alert`), or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/quality": {
      "get": {
        "description": "The quality report of a source: its rules, the last check (when, why, the score from 0 to 100 and its status, the rows, and per rule its status pass, fail or unknown with the rows that break it, their share, whether the count is an estimate and some failing values for patterns and unique values), whether the data changed after it (`stale`; the watcher checks them again after each update) and the history of the score. Rules never checked yet are checked now. Score: each rule weighs 3 (error) or 1 (warning); a rule that passes counts fully, one on rows that fails counts at most half its weight, less the more rows break it (0.5 × (1 − share)), one on the source that fails or whose field is gone counts nothing; rules that could not be checked are left out; score = round(100 × Σ weight × value / Σ weight). Every rule is counted by the storage over all the rows (one scan for all of them); a pattern the storage cannot test (a preset or a regular expression) is checked on a sample of up to 2000 non-empty values spread over the source, and its count is an estimate unless the sample held them all. An AI application connected through MCP needs the level «aggregates» and gets the failing values only when rows may go, never the filter of the failing rows. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report (report null when there are no rules)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QualityReport"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/source/{sourceId}/quality/check": {
      "post": {
        "description": "Checks the quality rules of a source now (the answer waits up to 20 seconds; `checking: true` when the check goes on in the background). Asked again within 15 seconds with nothing changed, it answers the last check. Needs a token that writes workspaces and permission to edit the source (or to own it). Answers the report as GET .../quality does.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "description": "Identifier of the data source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QualityReport"
                }
              }
            }
          },
          "400": {
            "description": "UNSUPPORTED_SOURCE (external and real-time sources)"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or source not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/quality": {
      "get": {
        "description": "The quality score of each source of a workspace that has rules: score (null before its first check), status (ok, warning, error, unknown, or pending before its first check), when it was checked and how many rules it has. Needs a token that reads workspaces and permission to read the sources.",
        "tags": [
          "sources"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The scores, by source id",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "workspace": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "object",
                      "additionalProperties": {
                        "properties": {
                          "score": {
                            "type": "integer",
                            "nullable": true
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "ok",
                              "warning",
                              "error",
                              "unknown",
                              "pending"
                            ]
                          },
                          "checked_at": {
                            "type": "integer"
                          },
                          "rules": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/monitoring": {
      "get": {
        "description": "The monitoring of a model in production («Seguimiento»): whether it is on (on by default for the models trained after the feature existed, off for the older ones until a person turns it on), its settings, the sources it can watch (the training source and the origins of the sources the model is applied to), the reference profile of its training data (`exact`: from the exact version the model was trained on, kept by the version history of the source; `approximate`: that version is gone and the current one was used) with, per input and target, the fixed edges of its bins (numbers and dates: about ten bins with about the same rows, chosen among 200 bins of equal width) or its 20 most frequent values plus «others», and the shares of rows of each bucket; its status (`stable`, `watch`, `alert`, `pending` before its first run, `off`), the last run in full (per source watched and column: the PSI against the reference with the same edges, its status and the shares of each bucket now; and the quality with the real outcomes of the rows added after training: the main metric now against the one of the training, or a `code` saying why it was not measured, e.g. `SCORE_UNAVAILABLE` with a gimodeler without /score) and the summary of the latest runs for the trend. PSI = Σ (a − e) · ln(a / e) over the buckets (empty values, under the first edge, each bin, over the last edge; or empty values, each value, others), shares of 0 taken as 0.0001; a column is `watch` from `psi_warning` (0.10) and `alert` from `psi_alert` (0.25); dates do not count in the status unless `include_dates`. The watcher runs it after the updates of the sources watched, at most once a day. An AI application connected through MCP needs the level «aggregates» and gets the values of the categories and the edges of the bins only for columns without personal data held back (`withheld_for_ai`). Needs a token that reads workspaces and permission to read the models.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The monitoring of the model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelMonitoring"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or model not found"
          }
        }
      },
      "put": {
        "description": "Turns the monitoring of a model on or off and changes its settings (only what is sent changes). Turning it on, or changing what is compared, takes the reference when there is none and runs it now: the answer waits up to 20 seconds (`running: true` when it goes on in the background). `alert` turns the alert of the model on or off (an alert of the workspace of type «model»: it fires when a run newly reaches «alert», never on the first run nor again while it stays; needs permission to edit the workspace). `check: true` runs it now. Classifiers, regressors, clusterings and outlier detectors can be monitored. Needs a token that writes workspaces and permission to edit the model (or to own it). Answers the monitoring as GET does.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModelMonitoringChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The monitoring of the model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelMonitoring"
                }
              }
            }
          },
          "400": {
            "description": "BAD_REQUEST, BAD_SETTINGS, UNKNOWN_KEY, BAD_THRESHOLD, BAD_SOURCES, UNKNOWN_SOURCE, NO_SOURCES or UNSUPPORTED_MODEL"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED: without permission to edit the model, or the workspace for `alert`), or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or model not found"
          },
          "409": {
            "description": "TRAINING_SOURCE_MISSING (an alert for a model without its training source)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/monitoring/check": {
      "post": {
        "description": "Runs the monitoring of a model now (the answer waits up to 20 seconds; `running: true` when it goes on in the background). Asked again within a minute with nothing changed, it answers the last run. Needs a token that writes workspaces and permission to edit the model (or to own it). Answers the monitoring as GET .../monitoring does.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The monitoring of the model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelMonitoring"
                }
              }
            }
          },
          "400": {
            "description": "MONITORING_OFF (turn it on first) or UNSUPPORTED_MODEL"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or model not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/versions": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "The versions of a model, the newest first. A model keeps its ID, page, dashboards and sources while the trained engine behind it can change: `status` says which version is in use (active), waits to be promoted (candidate), was in use and is kept to go back to it (previous: the last 2), failed, or is no longer kept (retired). Each one has its `trigger` (initial: the one the model was created with; manual: retrained by a person; retrain: retrained by AIR-Core), when and who, its `metrics` (numbers only, never the classes), the data it learned from (`training_data`: the source and its version, whether that version is the current one and whether it is kept in the history of the source), how it compared with the version in use when it was trained (`comparison`: `basis` same_rows when both were measured on the same rows, the holdout of the current version of the source, with gimodeler 0.20 and its /score; own_evaluation when each one was measured on its own test rows, indicative only; `metric`, `delta`, `relative`, `better` (at least 1 % better), `baseline`), its note and `can_promote`. `retrain` says whether the model can be retrained now (`problem`: why not, e.g. SOURCE_COLUMNS_CHANGED), whether a retraining is running (`running`: its task) and whether candidates are compared on the same rows (`same_rows`); a forecast is always replaced when retrained (`promotion`: always). Models without stored versions list the one they were created with. Requires the read_models permission. For an AI application connected through MCP, the gate «aggregates» of the AI data policy, and notes in which the detector of personal data finds some are withheld (`note_withheld`).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, model, type, active, keep_previous: 2, min_gain: 0.01, versions: [{version, status, trigger, created, author: {uid, name}, metrics, size, training_data: {source, source_name, version, at, current, kept}, comparison, note, task, promoted, replaced, can_promote}], retrain: {supported, promotion, available, running, problem, same_rows}, can_retrain, can_promote}"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or model not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/retrain": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "Retrains the model with the same configuration (method, settings, chosen columns, train/test split) and the data its source has now (classifiers and regressors; a forecast gets the retraining of POST …/forecast/retrain, which always replaces it). The new version is a candidate, compared with the version in use, and nothing changes until it is promoted; with `auto_promote: true` it is promoted by itself when, measured on the same rows, its main metric (F1 macro or accuracy for a classifier, R² for a regressor) is at least 1 % better. The last 2 versions in use and the newest candidate are kept; their size counts in the workspace. Starts a task (its result is the ID of the model); its time counts like any training. Requires the model_edit permission (or being the owner of the model) and the task permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "auto_promote": {
                    "type": "boolean",
                    "description": "Promote it by itself when it is at least 1 % better on the same rows (default false: it stays a candidate)"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "A note for the history"
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "es",
                      "en"
                    ],
                    "description": "Language of the texts of the task"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{result: success, task, task_id}"
          },
          "400": {
            "description": "BAD_REQUEST, BAD_NOTE, RETRAIN_NOT_SUPPORTED, SOURCE_NOT_FOUND, SOURCE_EXTERNAL, SOURCE_COLUMNS_CHANGED (the columns of the source changed since the model was trained: details.columns), METHOD_NOT_AVAILABLE, INPUTS_NOT_AVAILABLE or a settings code of a forecast"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, or a limit of the plan (LIMIT)"
          },
          "404": {
            "description": "Workspace or model not found"
          },
          "409": {
            "description": "RETRAIN_RUNNING (details.task)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/versions/{version}/promote": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "Makes a version the one in use: a candidate, or a previous one to go back to it. One write of the model (its engine, evaluation, columns, size and version of the source), only if the model did not change meanwhile; the version that was in use is kept to go back to it, and the sources made by applying the model are computed again. Requires the model_edit permission (or being the owner of the model).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "description": "The version to use, as GET …/versions gives it",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, model, active, previous}"
          },
          "400": {
            "description": "VERSION or NOT_PROMOTABLE (forecasts and unsupervised models)"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED"
          },
          "404": {
            "description": "Workspace or model not found, or VERSION_NOT_FOUND"
          },
          "409": {
            "description": "VERSION_ACTIVE, VERSION_GONE (its engine is no longer kept) or CONFLICT (the model changed meanwhile)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/model-experiments": {
      "get": {
        "description": "The comparisons of methods («Comparar métodos») of a workspace, the newest first (at most 50): their status, the methods of their candidates, the recommended candidate, whether a winner can still be picked (`can_choose`) and until when (`expires`), and the model the winner became. With `model`, only those started from that model or won by it; with `source`, only those of that source. `options` says what a comparison can have here: the candidates of the plan (2 to 3 on the free plan, up to 10 on the paid plans), the methods, whether candidates can learn from chosen columns, and who measures the naive prediction (`ai-module` with an AI module that learns it, `platform` otherwise). Needs a token that reads workspaces and permission to read the models.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "model",
            "description": "Only the comparisons started from this model or won by it",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "description": "Only the comparisons of this source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The comparisons and what one can have",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "experiments": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ModelExperimentSummary"
                      }
                    },
                    "options": {
                      "$ref": "#/components/schemas/ModelExperimentOptions"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      },
      "post": {
        "description": "Starts a comparison of methods: several candidates that predict the same target of a source, trained one after the other in one task (one stage per candidate) on the same data and the same split (the same test_size, shuffle and seed for all; when no seed is given, one is drawn and used for all), each one a method with its default settings or the automatic search of its settings, and optionally other input columns. A candidate that fails does not stop the others, and the task stops starting candidates when the task time of the organization runs out. Each candidate is compared with the naive prediction (the most frequent class, or the mean): measured on the same rows by an AI module that learns it, or computed by AIR-Core from the evaluation otherwise. The candidates are not models: when the task ends, read the comparison and pick the winner (POST .../winner); candidates nobody picks are deleted after 7 days. Classifiers and regressors only; 2 to 3 candidates on the free plan, up to 10 on the paid plans. Answers the comparison and its task (the task gives the comparison in `result`). Needs a token that writes workspaces and permission to create models and run tasks.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "name",
                  "source",
                  "target",
                  "candidates"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "The name the winner will have"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "The description the winner will have"
                  },
                  "source": {
                    "type": "string",
                    "description": "Training source"
                  },
                  "target": {
                    "type": "integer",
                    "description": "Index of the target field"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "classifier",
                      "regressor"
                    ],
                    "description": "Without it, regressor for a numeric target and classifier otherwise"
                  },
                  "candidates": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 10,
                    "items": {
                      "$ref": "#/components/schemas/ModelExperimentCandidateRequest"
                    }
                  },
                  "training_configuration": {
                    "description": "The split shared by every candidate",
                    "properties": {
                      "test_size": {
                        "type": "number",
                        "minimum": 0.05,
                        "maximum": 0.6,
                        "description": "Fraction of the rows that test the candidates (default 0.3)"
                      },
                      "shuffle": {
                        "type": "boolean",
                        "description": "Shuffle the rows before splitting (default true)"
                      },
                      "random_state": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Seed of the split; drawn once when absent"
                      }
                    }
                  },
                  "scaling": {
                    "type": "object",
                    "description": "Scaling of the inputs, as in the creation of a model (count-based naive Bayes candidates get minmax instead of standard or robust)"
                  },
                  "feature_selection": {
                    "type": "object",
                    "description": "Feature selection, as in the creation of a model"
                  },
                  "nlp_config": {
                    "type": "object",
                    "description": "Text classifiers: the column of text and its settings, as in the creation of a model"
                  },
                  "from_model": {
                    "type": "string",
                    "description": "The model the comparison starts from («Try other methods with this data»), to link them"
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "es",
                      "en"
                    ],
                    "description": "Language of the explanations of the winner"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The comparison and its task",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "enum": [
                        "success"
                      ]
                    },
                    "experiment": {
                      "type": "string"
                    },
                    "task": {
                      "type": "string"
                    },
                    "task_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "BAD_NAME, BAD_DESCRIPTION, BAD_TYPE, BAD_CANDIDATES, TOO_FEW_CANDIDATES, TOO_MANY_CANDIDATES (details.limit), DUPLICATE_CANDIDATE, UNKNOWN_METHOD, METHOD_NOT_AVAILABLE, BAD_INPUTS, INPUT_NOT_FOUND, INPUT_IS_TARGET, INPUTS_WITHOUT_TEXT, INPUTS_NOT_AVAILABLE, BAD_SPLIT or SOURCE_EXTERNAL"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or LIMIT (size, task time or parallel tasks of the plan)"
          },
          "404": {
            "description": "Workspace, source (SOURCE_NOT_FOUND) or target (TARGET_NOT_FOUND) not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/model-experiments/{experimentId}": {
      "get": {
        "description": "A comparison of methods: its status (pending, running, done = waiting for a choice, chosen, expired, failed, history = imported), the shared split, and per candidate its method and settings, its columns, its status (and the error of one that failed), its metrics (classifier: accuracy and f1, macro average; regressor: r2 and mae), those of the naive prediction (`baseline`, with `source`: ai-module or platform), the gain over it in the main metric, how much smaller its error is (regressors, when known), the training time and the size. `primary_metric` is the figure they are compared by (r2; accuracy, or f1 when the classes of the test rows are unbalanced); `recommended` is the candidate with the best one, ties (less than half a point) going to the simpler method and then to the faster one (`recommended_reason`: best, tie_simpler, tie_faster, only); `beats_baseline` false means no candidate beats the naive prediction. An AI application connected through MCP never gets the class the naive prediction answers. Needs a token that reads workspaces and permission to read the models.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "experimentId",
            "description": "Identifier of the comparison",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The comparison",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelExperiment"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace or comparison not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/model-experiments/{experimentId}/winner": {
      "post": {
        "description": "Picks the winner of a finished comparison (status done): the candidate becomes a normal model, with the identifier it has in the AI module, its configuration, its evaluation and the fields of the source when it was trained, and the other candidates are deleted from the AI module (they were never models). Picking the same candidate again answers the same model. Needs a token that writes workspaces and permission to create models.",
        "tags": [
          "models"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "experimentId",
            "description": "Identifier of the comparison",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "candidate"
                ],
                "properties": {
                  "candidate": {
                    "type": "string",
                    "description": "Key of the candidate (c1, c2...)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The model the winner became",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "enum": [
                        "success"
                      ]
                    },
                    "model": {
                      "type": "string"
                    },
                    "model_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or LIMIT (size of the plan)"
          },
          "404": {
            "description": "Workspace or comparison not found, or CANDIDATE_NOT_FOUND"
          },
          "409": {
            "description": "NOT_FINISHED, ALREADY_CHOSEN (another candidate was picked), CANDIDATE_NOT_TRAINED, CANDIDATES_EXPIRED (not picked in 7 days) or NO_CANDIDATES"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/retrain-schedule": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "The automatic retraining of a classifier or a regressor («Reentrenamiento automático»; a forecast keeps its own retraining: `supported: false`). `mode`: off (never by itself: the default of every model, also the existing ones), schedule (every day, week or month in a window of hours, in the time zone of the organization or its own `timezone`), data (when the training source has at least `min_new_rows` new rows, or `min_growth` more rows as a share, since the data the version in use learned from: its source version), drift (when the monitoring of the model reaches «alert»). `timezone` is the one in use, `next_run` when the window starts next (schedule) or when the condition is looked at again (data, drift), `last_started` and `last_task` the last retraining it started, `last_result` and `history` what happened: started, skipped (`reason`: SOURCE_COLUMNS_CHANGED, RETRAIN_RUNNING, LIMIT, SOURCE_UNCHANGED, ONCE_A_DAY or another code of the retraining; the same skip again is counted in `count`), candidate (the new version waits for a person; `reason` why it was not promoted by itself: auto_off, not_same_rows, not_enough, worse), promoted (by itself, with `version`, `previous` to go back to it with POST …/versions/{previous}/promote, and the `comparison`) or failed; `catch_up` when it ran after the platform missed its window (once, never once per window missed). `state` gives each condition now: `data` (base_rows, rows, new_rows, growth, changed, met) and `monitoring` (enabled, status). At most one retraining by itself a day per model; each one is a task whose time counts like any training, within the limits of the plan. `same_rows` says whether the AI module measures both versions on the same rows (needed to promote by itself). Requires the read_models permission. For an AI application connected through MCP, the gate «aggregates» of the AI data policy, without who set it up.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The schedule of the model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelRetrainSchedule"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or model not found"
          }
        }
      },
      "put": {
        "tags": [
          "models"
        ],
        "description": "Changes the automatic retraining of a classifier or a regressor: only what is sent changes. With `auto_promote: true` a new version is promoted by itself only when it was measured on the same rows as the version in use (gimodeler 0.20 with /score; never on each version's own evaluation) and its main metric (F1 macro or accuracy for a classifier, R² for a regressor) improves at least `min_gain` (a share: 0.01 = 1 %, the default; 0 or more); otherwise it waits as a candidate, with a notice in the bell of the owner and of who set it up, the activity of the workspace and, when the owner has the emails of alerts on, an email. Every automatic promotion is written down with its comparison and can be undone with POST …/versions/{version}/promote. Requires the model_edit permission (or being the owner of the model) and the task permission. Answers the schedule as GET does.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelId",
            "description": "Identifier of the model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModelRetrainScheduleChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The schedule of the model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelRetrainSchedule"
                }
              }
            }
          },
          "400": {
            "description": "BAD_REQUEST, UNKNOWN_KEY, BAD_MODE, BAD_SETTINGS, BAD_EVERY, BAD_WEEKDAY, BAD_DAY, BAD_HOUR, BAD_TIMEZONE, BAD_NEW_ROWS, BAD_GROWTH, NO_CONDITION (mode data without min_new_rows nor min_growth), BAD_AUTO_PROMOTE, BAD_MIN_GAIN or UNSUPPORTED_MODEL (forecasts and unsupervised models)"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or model not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboard/{dashboardId}/reports": {
      "get": {
        "tags": [
          "dashboards"
        ],
        "description": "The scheduled reports of a dashboard («Programar informe»): a summary of the dashboard by email every day, week or month at an hour of a time zone. Each visualization is summarized from exact figures computed by AIR-Core over its source (its filter, the period of the report: the day, the 7 days or the calendar month before the day it goes out, compared with the period before), in sentences written from templates in Spanish, English or Catalan: no generative AI is used. Tables, maps and other charts are listed by name. Each report has `status` (active or paused, with `paused_reason`: by_user, no_access, dashboard_deleted, workspace_deleted, no_share), `settings`, `recipients`, `next_run`, `last_sent` and `last_result`. A report only carries what whoever scheduled it can see: it is checked again every time it goes out, and paused (with an email to them) when they lost the access. Requires the read and read_dashboards permissions of the workspace. For an AI application connected through MCP, the gate «structure» of the AI data policy, without the addresses of the recipients.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, reports, can_send_to_others, can_share_outside, limits}"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or dashboard not found"
          }
        }
      },
      "post": {
        "tags": [
          "dashboards"
        ],
        "description": "Schedules a new report of the dashboard (without recipients: the owner of the token alone). At most 20 recipients, 10 reports per dashboard and 200 per organization. Free on every plan.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "settings": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "Only what is sent changes.",
                    "properties": {
                      "every": {
                        "type": "string",
                        "enum": [
                          "daily",
                          "weekly",
                          "monthly"
                        ]
                      },
                      "weekday": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 7,
                        "description": "weekly: 1 Monday … 7 Sunday"
                      },
                      "day": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 31,
                        "description": "monthly: a shorter month uses its last day"
                      },
                      "hour": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 23
                      },
                      "timezone": {
                        "type": "string",
                        "description": "IANA time zone (Europe/Madrid by default)"
                      },
                      "lang": {
                        "type": "string",
                        "enum": [
                          "es",
                          "en",
                          "ca"
                        ]
                      }
                    }
                  },
                  "recipients": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "members": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "uid of members who read the workspace (others than the owner of the token only if they edit the dashboard)"
                      },
                      "emails": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "outside addresses of the notices list of the workspace that confirmed (only when the plan shares dashboards and the owner of the token edits the dashboard)"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{result: success, report}"
          },
          "400": {
            "description": "BAD_REQUEST, UNKNOWN_KEY, BAD_SETTINGS, BAD_EVERY, BAD_WEEKDAY, BAD_DAY, BAD_HOUR, BAD_TIMEZONE, BAD_LANG, BAD_RECIPIENTS, NO_RECIPIENTS, TOO_MANY_RECIPIENTS, BAD_RECIPIENT, BAD_EMAIL or NOT_CONFIRMED"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, RECIPIENTS_NOT_ALLOWED, OUTSIDE_NOT_ALLOWED, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or dashboard not found"
          },
          "409": {
            "description": "TOO_MANY_REPORTS"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboard/{dashboardId}/reports/{reportId}": {
      "put": {
        "tags": [
          "dashboards"
        ],
        "description": "Changes a scheduled report (only what is sent), pauses it or resumes it (`status`). Only who made it or who edits the dashboard. Resuming checks the recipients again; when whoever made it lost the access, the report then carries what the person resuming it can see.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "reportId",
            "description": "Identifier of the scheduled report",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "settings": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "Only what is sent changes.",
                    "properties": {
                      "every": {
                        "type": "string",
                        "enum": [
                          "daily",
                          "weekly",
                          "monthly"
                        ]
                      },
                      "weekday": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 7,
                        "description": "weekly: 1 Monday … 7 Sunday"
                      },
                      "day": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 31,
                        "description": "monthly: a shorter month uses its last day"
                      },
                      "hour": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 23
                      },
                      "timezone": {
                        "type": "string",
                        "description": "IANA time zone (Europe/Madrid by default)"
                      },
                      "lang": {
                        "type": "string",
                        "enum": [
                          "es",
                          "en",
                          "ca"
                        ]
                      }
                    }
                  },
                  "recipients": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "members": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "uid of members who read the workspace (others than the owner of the token only if they edit the dashboard)"
                      },
                      "emails": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "outside addresses of the notices list of the workspace that confirmed (only when the plan shares dashboards and the owner of the token edits the dashboard)"
                      }
                    }
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "paused"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{result: success, report}"
          },
          "400": {
            "description": "As POST, and BAD_STATUS"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, RECIPIENTS_NOT_ALLOWED, OUTSIDE_NOT_ALLOWED"
          },
          "404": {
            "description": "Workspace, dashboard or report not found"
          }
        }
      },
      "delete": {
        "tags": [
          "dashboards"
        ],
        "description": "Deletes a scheduled report. Only who made it or who edits the dashboard.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "reportId",
            "description": "Identifier of the scheduled report",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success}"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED"
          },
          "404": {
            "description": "Workspace, dashboard or report not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/dashboard/{dashboardId}/reports/{reportId}/test": {
      "post": {
        "tags": [
          "dashboards"
        ],
        "description": "Sends the report now, as a test, only to the address of the owner of the token (marked as a test; at most once a minute per report). The calendar does not change.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dashboardId",
            "description": "Identifier of the dashboard",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "reportId",
            "description": "Identifier of the scheduled report",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{result: success, sent, summarized, skipped}"
          },
          "400": {
            "description": "NO_EMAIL"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED"
          },
          "404": {
            "description": "Workspace, dashboard or report not found"
          },
          "429": {
            "description": "TOO_SOON"
          }
        }
      }
    },
    "/api/v2/search": {
      "get": {
        "description": "Search across the data of the organization («Buscar en tus datos»): sources, columns (with the description, unit and kind of value of their catalogue), recipes, joins of sources, models (name, target and input columns), dashboards, visualizations and metrics (with their other names) found by words. Lexical, without AI and on every plan: accents and case do not matter, a singular finds its plural (Spanish and English), stop words are left out, and each word also finds its synonyms (those of AIR-Core, such as cliente = customer, ventas = sales, importe = amount, and those of the organization) with less weight. Ranked by BM25 with a weight per text (the name counts more than the description). Only the workspaces of the organization (header x-organization, or the first one of the person) where the person may read each kind of object are searched (sources, columns, recipes, joins and metrics need permission to read the sources; models, to read the models; dashboards and visualizations, to read them), and each result is checked against its object: never the name of an object the person cannot see. Each result has the address of the page of its object with the tool that shows what matched (`link.url`; a column opens the columns of its source and highlights it). An AI application connected through MCP (and the built-in assistant) never gets an excerpt of a text written by people where the detector of personal data finds some. Needs a token that reads workspaces.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "q",
            "description": "The words to search for (at most 200 characters); stop words are left out",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "kinds",
            "description": "Only these kinds, separated by commas: source, column, recipe, join, model, dashboard, visualization, metric",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ws",
            "description": "Only this workspace",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "description": "Results (1 to 50, 20 by default)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "name": "prefix",
            "description": "true: the last word also finds the words that begin with it (a question being written)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "x-organization",
            "description": "The organization (the first one of the person without it)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The results, best first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataSearchResult"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_QUERY, QUERY_TOO_LONG, INVALID_KIND or INVALID_LIMIT"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, NO_ORGANIZATION, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "503": {
            "description": "SEARCH_DISABLED: the search is switched off on this platform (search.enabled false)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/search": {
      "get": {
        "description": "The search across the data (GET /api/v2/search) in one workspace: the kinds of object the person may read there. A workspace of another organization, or where the person may read nothing, is not found. Needs a token that reads workspaces.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "description": "The words to search for (at most 200 characters)",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "kinds",
            "description": "Only these kinds, separated by commas: source, column, recipe, join, model, dashboard, visualization, metric",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "description": "Results (1 to 50, 20 by default)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "name": "prefix",
            "description": "true: the last word also finds the words that begin with it",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The results, best first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataSearchResult"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_QUERY, QUERY_TOO_LONG, INVALID_KIND or INVALID_LIMIT"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or the AI data policy refuses it (AI_POLICY_*)"
          },
          "404": {
            "description": "Workspace not found"
          },
          "503": {
            "description": "SEARCH_DISABLED: the search is switched off on this platform (search.enabled false)"
          }
        }
      }
    },
    "/api/v2/search/synonyms": {
      "get": {
        "description": "The synonyms of the search across the data: the groups the organization added (`groups`) and those AIR-Core brings (`defaults`). For the administrators of the organization, also the state of its index (`index`: documents, objects waiting to be indexed again). Needs a token that reads workspaces.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "x-organization",
            "description": "The organization (the first one of the person without it)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The synonyms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchSynonyms"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied or NO_ORGANIZATION"
          },
          "503": {
            "description": "SEARCH_DISABLED: the search is switched off on this platform (search.enabled false)"
          }
        }
      },
      "put": {
        "description": "Replaces the synonyms of the organization (its administrators): `groups`, a list of groups of 2 to 12 different words of at most 40 characters (at most 200 groups), or `text`, one group per line with the words separated by commas. They are used when searching, at once (nothing is indexed again). Needs a token that writes workspaces.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "x-organization",
            "description": "The organization (the first one of the person without it)",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "groups": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "maxLength": 40
                      }
                    }
                  },
                  "text": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The synonyms as they are left",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchSynonyms"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_SYNONYMS, SYNONYM_TOO_LONG, SYNONYM_GROUP_TOO_SMALL, SYNONYM_GROUP_TOO_LARGE or TOO_MANY_SYNONYMS"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED (only the administrators of the organization) or NO_ORGANIZATION"
          },
          "503": {
            "description": "SEARCH_DISABLED: the search is switched off on this platform (search.enabled false)"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/models/{modelId}/trust-report": {
      "get": {
        "tags": [
          "models",
          "ai"
        ],
        "description": "Trust report of a model, to help document it as an AI system (Regulation (EU) 2024/1689): intended purpose (written by the organization), data used (source, version, rows, columns and the personal data found, as field names and kinds, never values), method, evaluation and quality verdict, global importance of the inputs, known limits, monitoring and drift, versions, who changed what, human oversight (written by the organization) and where it runs. The risk category is the one the organization chose in its register of AI systems; the platform does not classify. It does not certify compliance and is not legal advice. JSON by default; format=markdown returns a Markdown document and format=pdf a PDF (an HTML document, with the header X-Report-Format: html, when the installation cannot print PDF). Read only. Requires the read_models permission.",
        "parameters": [
          {
            "description": "Identifier of the workspace",
            "in": "path",
            "name": "workspaceId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Identifier of the model",
            "in": "path",
            "name": "modelId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Autentication token",
            "in": "header",
            "name": "x-auth-token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Response format: json (default), markdown or pdf",
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "markdown",
                "pdf"
              ]
            }
          },
          {
            "description": "Language of the texts: es (default) or en",
            "in": "query",
            "name": "lang",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "es",
                "en"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Trust report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelTrustReport"
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Too many PDF documents are being prepared (PDF_BUSY); try again after Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/flows": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "«Flujos»: the flows of the workspace (decisions that run by themselves: when a source is updated or every N hours, retrain a model when due, predict the new rows, evaluate a condition and act by email, signed webhook or rows written to another source), newest change first, each with `last_outcome` (the status of its last run). Requires the read permission. For an AI application connected through MCP, the gate «structure» of the AI data policy, without who made or changed them.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "flows": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DecisionFlow"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      },
      "post": {
        "tags": [
          "models"
        ],
        "description": "Creates a flow, off unless `enabled: true` (switched on, the rows the source has then do not count as new). `retrain`: never, if_due (when the training source has data the model did not learn from, at most once a day) or always; the retraining is the task of «Versiones» and the new version is used only when its quality verdict is not `not_better_than_naive` and not worse than the version in use (nor worse on the same rows); otherwise the version in use is kept, the new one waits as a candidate, the owner is told and the run ends `guarded` without acting. `condition`: all, rules (on the columns of the source and the columns the model adds, such as `<target>_predicted` and `<target>_predicted_probability`; the operators of the simple notices) or alert (a simple notice of the trigger source). At most 3 actions, one of each type: email (`to`: me, members or list: the notice list of the workspace, all of it or the entries in `recipients`, with the checks of the simple notices), webhook (`url`: https and public only; JSON event `flow.fired` signed with HMAC-SHA256 in `x-signature-256`, as the webhooks of the simple notices) and append (`target`: a source of the workspace that can be edited; columns taken by name, `flow_run_at` gets the time of the run). Limits: 2 flows per workspace on the free plan (20 on paid plans), 4 runs per flow and hour, 10 tests per hour, 5 runs with actions a day on the free plan (48 on paid), 1000 rows predicted per run. Requires the ws_edit and task permissions. Answers the flow; `webhook_secret` only when one was made (shown once).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionFlowInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionFlow"
                }
              }
            }
          },
          "400": {
            "description": "BAD_REQUEST, UNKNOWN_KEY, BAD_NAME, BAD_TRIGGER, BAD_SCHEDULE, BAD_RETRAIN, BAD_CONDITION, BAD_ACTIONS, BAD_RECIPIENTS, LIST_EMPTY, RECIPIENT_NOT_FOUND, SOURCE_NOT_FOUND, MODEL_NOT_FOUND, MODEL_NOT_SUPPORTED, INPUTS_MISSING, ALERT_NOT_FOUND, TARGET_NOT_FOUND, TARGET_NOT_EDITABLE, WEBHOOK_URL_INVALID, WEBHOOK_PRIVATE_ADDRESS, WEBHOOK_PORT_NOT_ALLOWED or WEBHOOK_HOST_NOT_ALLOWED"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, LIMIT (flows of the plan), or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/flows/{flowId}": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "A flow and its latest runs (`runs`: how many, 20 by default, 50 at most), each with what every step did (counts, never rows). The webhook is given by its origin only. Requires the read permission. For an AI application connected through MCP, the gate «aggregates».",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "flowId",
            "description": "Identifier of the flow",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "runs",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flow and its runs",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/DecisionFlow"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "runs": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/DecisionFlowRun"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or flow not found"
          }
        }
      },
      "put": {
        "tags": [
          "models"
        ],
        "description": "Changes a flow: only what is sent changes, and every change is a new `version` (the previous ones are kept in `history`). `rotate_secret: true` makes a new signing secret for the webhook (answered once). Requires the ws_edit and task permissions.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "flowId",
            "description": "Identifier of the flow",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionFlowInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionFlow"
                }
              }
            }
          },
          "400": {
            "description": "The codes of POST …/flows"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or flow not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/flows/{flowId}/runs": {
      "get": {
        "tags": [
          "models"
        ],
        "description": "The runs of a flow, newest first (`limit`, 50 at most; the last 50 are kept). Requires the read permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "flowId",
            "description": "Identifier of the flow",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The runs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "runs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DecisionFlowRun"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or flow not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/flows/{flowId}/test": {
      "post": {
        "tags": [
          "models"
        ],
        "description": "«Probar ahora»: goes through the flow with the new rows of its source (or, when there are none, its last 20 rows) and tells what each step would do (`would_run`, `would_send`, `would_write`), without starting a retraining, sending or writing anything. Recorded as a run with `dry_run: true`. `preview`: the first rows that meet the condition (left out for an AI application). At most 10 tests per flow and hour (429 RATE_LIMIT). Requires the ws_edit and task permissions.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "flowId",
            "description": "Identifier of the flow",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The test",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "run": {
                      "$ref": "#/components/schemas/DecisionFlowRun"
                    },
                    "preview": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "columns": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "array",
                            "items": {}
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace or flow not found"
          },
          "429": {
            "description": "RATE_LIMIT"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/automations": {
      "get": {
        "tags": [
          "automations"
        ],
        "summary": "List the automations",
        "description": "The simple notices (`kind: notice`, with their `type`: update, stall, metric, quality or model; a notice on a metric with its metric and condition in `trigger`) and the flows (`kind: flow`, with the outcome of their last run) of the workspace, by name. Requires the read permission.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "description": "Only `notice` or only `flow`",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "notice",
                "flow"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The automations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationList"
                }
              }
            }
          },
          "400": {
            "description": "BAD_KIND"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, NO_ORGANIZATION, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      },
      "post": {
        "tags": [
          "automations"
        ],
        "summary": "Create an automation",
        "description": "Creates an automation and saves it as a **simple notice** when it is exactly one, as a **flow** otherwise, by the same rule as the application:\n\n- `trigger.type: stall` (no data for `trigger.hours` hours) is always a simple notice;\n- `trigger.type: source_updated` is a simple notice when it has no model, its condition is `all` or rules on columns of the source with the operators eq, gt, gte, lt, lte, null, cn, sw or ew (not cni), `min_rows` is 1, it emails the whole notice list (`{type: email, to: list}` without `recipients`), it writes no rows (`append`), it may call one webhook and it is on;\n- `trigger.type: metric` (a metric and its condition, as «Alert me when…» in Metrics) is always a simple notice on that metric: `trigger.metric`, `measure` (value, change_pct or change), `op` (gt, gte, lt, lte), `threshold`, `period`, `compare` (previous_period or previous_year; not for value) and `filters` (`[{field, value}]` on fields of the source of the metric). It is checked and evaluated by the engine of the metrics as in the application; without `name`, it is named after its condition. It emails the notice list and may call one webhook; it takes no `condition`, model or rows written, and needs the read_sources permission (it reads the figures);\n- anything else (a schedule, a model, `cni`, columns the prediction adds, another recipient, rows written, created off) is a flow.\n\nThe answer says how it was saved and why (`saved_as.reason`: STALL, SIMPLE or METRIC for a notice; SCHEDULE, MODEL, ALERT_CONDITION, OPERATOR, COLUMN, MIN_ROWS, APPEND, NO_EMAIL, EMAIL_NOT_LIST or OFF for a flow). Without `actions`, it emails the notice list; without `enabled`, it is on. A flow has the limits of the flows (2 per workspace on the free plan, 20 on paid plans) and needs the ws_edit and task permissions; a simple notice needs ws_edit. A webhook answers its signing secret once (`webhook_secret`). `warnings: [LIST_EMPTY]` when the notice list has no address yet.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutomationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The automation, how it was saved and why",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationSaved"
                }
              }
            }
          },
          "400": {
            "description": "BAD_REQUEST, UNKNOWN_KEY, BAD_NAME, BAD_TRIGGER, BAD_STALL, BAD_STALL_HOURS, BAD_METRIC, BAD_METRIC_NOTICE, METRIC_NOT_FOUND, BAD_FIELD, BAD_SCHEDULE, BAD_RETRAIN, BAD_CONDITION, BAD_ACTIONS, BAD_RECIPIENTS, LIST_EMPTY (a flow that emails an empty list), SOURCE_NOT_FOUND, MODEL_NOT_FOUND, TARGET_NOT_FOUND, TARGET_NOT_EDITABLE or WEBHOOK_*"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, LIMIT (flows of the plan), or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "Workspace not found"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/automations/{automationId}": {
      "get": {
        "tags": [
          "automations"
        ],
        "summary": "Read an automation",
        "description": "A simple notice or a flow in the same shape: `trigger`, `condition` (a notice made with the editor of conditions of the application answers `{kind: tree, tree}`; the notices of a metric, the quality of a source or the monitoring of a model answer their condition in words, `{kind: text}`, and a notice on a metric its metric and condition in `trigger`) and `actions` (of a webhook only its channel and origin, never its address). A flow also answers its version, model, retraining and history of versions.",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automationId",
            "description": "Identifier of the automation (of a simple notice or of a flow)",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The automation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Automation"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, NO_ORGANIZATION, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "NOT_FOUND"
          }
        }
      },
      "put": {
        "tags": [
          "automations"
        ],
        "summary": "Change an automation",
        "description": "Changes only what is sent. A flow stays a flow (a new version, as `PUT …/flows/{flowId}`). A simple notice of type update or stall stays a simple notice: what would need a flow answers 409 `NOT_A_NOTICE` (create a new automation instead); `actions` replaces its webhook (an action `{type: webhook}` without `url` keeps the saved address; without a webhook action, it is removed). A notice on a metric changes its `name`, `description`, `actions` and, in `trigger`, its metric and any part of its condition (the rest is kept; a new condition is checked again and may fire again in the current period); its trigger stays on a metric (409 `NOTICE_FIXED`). A notice of the quality of a source or of the monitoring of a model only changes its `name` and `description` here (409 `NOTICE_FIXED`).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automationId",
            "description": "Identifier of the automation (of a simple notice or of a flow)",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutomationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The automation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationSaved"
                }
              }
            }
          },
          "400": {
            "description": "As when it is created"
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, NO_ORGANIZATION, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "NOT_A_NOTICE or NOTICE_FIXED"
          }
        }
      },
      "delete": {
        "tags": [
          "automations"
        ],
        "summary": "Delete an automation",
        "description": "Deletes a simple notice (with its webhook) or a flow (with its runs). Requires ws_edit (and task for a flow).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automationId",
            "description": "Identifier of the automation (of a simple notice or of a flow)",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationDeleted"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, NO_ORGANIZATION, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "NOT_FOUND"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/automations/{automationId}/history": {
      "get": {
        "tags": [
          "automations"
        ],
        "summary": "History of an automation",
        "description": "Of a simple notice, when it fired, newest first, with the rows that met its condition (only for those who read the sources; an AI application gets them only when the AI data policy lets rows go, protected), paginated with `page` and `limit`. Of a flow, its runs, newest first (`limit`, 50 at most), with what each step did (counts, never rows).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automationId",
            "description": "Identifier of the automation (of a simple notice or of a flow)",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "description": "Page (starts with 0; simple notices)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "description": "Items per page (simple notices) or runs (flows)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationHistory"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, NO_ORGANIZATION, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "NOT_FOUND"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/automations/{automationId}/test": {
      "post": {
        "tags": [
          "automations"
        ],
        "summary": "Test an automation",
        "description": "What would happen now, with nothing sent, retrained or written. A flow: its test run (as `POST …/flows/{flowId}/test`, at most 10 an hour). A simple notice of type update: its condition on the newest 20 rows of its source (`rows_checked`, `matched`, `would_fire` and, for people who read the sources, up to 5 rows in `preview`). Of type stall: how many hours the source has been without new data (`silent_hours`) against its silence (`after_hours`). The notices of a metric, the quality of a source or the monitoring of a model answer 409 `TEST_NOT_AVAILABLE`. Requires ws_edit (and task for a flow).",
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automationId",
            "description": "Identifier of the automation (of a simple notice or of a flow)",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What would happen",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationTest"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "ACCESS_DENIED, NO_ORGANIZATION, or AI_POLICY_* for an AI application"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "TEST_NOT_AVAILABLE or SOURCE_NOT_FOUND"
          },
          "429": {
            "description": "RATE_LIMIT (tests of a flow)"
          }
        }
      }
    },
    "/api/v2/templates": {
      "get": {
        "description": "The templates by sector («Plantillas por sector»): each one takes a workspace from empty to a complete result in a few minutes. From example data bundled with the platform (synthetic or openly licensed, without personal data) a template creates a data source, trains a model on it, makes a dashboard and sets a simple notice, each one explained. Of each template: what it creates, where its data comes from and under which licence, about how long it takes and `own_data`: the columns a source of your own needs to do the same with your data. Nothing of any workspace is in the answer, and no generative AI is involved.",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "x-auth-token",
            "description": "Authentication token (reads workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "description": "Language of the texts (default: the one of the request)",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "es",
                "cat",
                "de",
                "fr",
                "ja",
                "zh"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The templates",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "templates": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SectorTemplate"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/v2/workspace/{workspaceId}/templates/{templateId}/apply": {
      "post": {
        "description": "Applies a template by sector in a workspace. It starts ONE task that does four steps, one after the other, each with the service that already does it: imports the example source, trains the model (with the quality guarantee of any model), creates the dashboard proposed for that source and its model, and creates a simple notice on new data. What is created counts against the limits of the plan as usual. What was created stays when a later step cannot be done (for example, the plan allows no more dashboards): the task ends well and its summary says which steps were done and why the others were not; the task fails only when the example source could not be imported. Poll `GET /api/v2/workspace/{workspaceId}/task/{taskId}`: `template` carries the summary while the task runs and after it. Requires the permissions to create sources, models, visualizations and dashboards, to run tasks and to edit the workspace (alerts).",
        "tags": [
          "workspaces"
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "description": "Identifier of the workspace",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "templateId",
            "description": "Identifier of the template (see GET /api/v2/templates)",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-auth-token",
            "description": "Authentication token (writes workspaces)",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "lang": {
                    "type": "string",
                    "enum": [
                      "en",
                      "es",
                      "cat",
                      "de",
                      "fr",
                      "ja",
                      "zh"
                    ],
                    "description": "Language of the names and descriptions of what is created (default: the one of the request)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The task that applies the template",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "type": "string",
                      "enum": [
                        "success"
                      ]
                    },
                    "task": {
                      "type": "string"
                    },
                    "task_id": {
                      "type": "string"
                    },
                    "template": {
                      "$ref": "#/components/schemas/SectorTemplate"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid authorization"
          },
          "403": {
            "description": "Access denied (ACCESS_DENIED: a permission to create one of the things is missing), or LIMIT (data sources of the workspace, size, task time or parallel tasks of the plan)"
          },
          "404": {
            "description": "Workspace not found, or TEMPLATE_NOT_FOUND"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JoinMultiLookup": {
        "description": "A source joined to the main one in a join of several sources (derived_type join_multi)",
        "required": [
          "source",
          "keys"
        ],
        "properties": {
          "source": {
            "type": "string",
            "description": "Identifier of the source (of the same workspace; the same one may repeat)"
          },
          "keys": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "description": "Key columns, by name: every pair must match. Keys are compared as normalized values: text without spaces at the ends and without case; numbers by value when a column is numeric («001» = 1); dates by instant; true and false. An empty key never matches.",
            "items": {
              "required": [
                "main",
                "lookup"
              ],
              "properties": {
                "main": {
                  "type": "string",
                  "description": "Column of the main source"
                },
                "lookup": {
                  "type": "string",
                  "description": "Column of this source"
                }
              }
            }
          },
          "kind": {
            "type": "string",
            "enum": [
              "left",
              "inner"
            ],
            "default": "left",
            "description": "left: every row of the main source stays (empty values without a match); inner: only the rows that find a match"
          },
          "prefix": {
            "type": "string",
            "maxLength": 60,
            "description": "Put before the names of its columns that are already taken (default: the name of the source)"
          }
        }
      },
      "JoinMultiColumn": {
        "description": "A column of the source made by a join of several sources",
        "required": [
          "part",
          "field"
        ],
        "properties": {
          "part": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5,
            "description": "0: the main source; 1 to 5: the lookup in that position"
          },
          "field": {
            "type": "string",
            "description": "Name of the column in that source"
          },
          "as": {
            "type": "string",
            "maxLength": 120,
            "description": "Name in the new source (a name already taken gets the prefix of its lookup, then a number)"
          }
        }
      },
      "JoinKeySuggestions": {
        "properties": {
          "main": {
            "properties": {
              "source": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "rows": {
                "type": "integer"
              }
            }
          },
          "measured": {
            "type": "boolean",
            "description": "Whether values were read (false: names, types and catalogue only)"
          },
          "sample_rows": {
            "type": "integer"
          },
          "limits": {
            "properties": {
              "rows": {
                "type": "integer"
              },
              "bytes": {
                "type": "integer"
              }
            },
            "description": "The caps of the plan for the lookups of a join, together (rows and estimated bytes in memory)"
          },
          "lookups": {
            "type": "array",
            "items": {
              "properties": {
                "source": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "rows": {
                  "type": "integer"
                },
                "scanned": {
                  "type": "integer",
                  "description": "Rows of the lookup read to measure"
                },
                "complete": {
                  "type": "boolean",
                  "description": "Whether that is all of them"
                },
                "suggested": {
                  "nullable": true,
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "main": {
                            "type": "string"
                          },
                          "lookup": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "kind": {
                      "type": "string"
                    }
                  }
                },
                "candidates": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "main_field": {
                        "type": "string"
                      },
                      "main_index": {
                        "type": "integer"
                      },
                      "main_type": {
                        "type": "string"
                      },
                      "lookup_field": {
                        "type": "string"
                      },
                      "lookup_index": {
                        "type": "integer"
                      },
                      "lookup_type": {
                        "type": "string"
                      },
                      "mode": {
                        "type": "string",
                        "enum": [
                          "text",
                          "number",
                          "date",
                          "logic"
                        ],
                        "description": "How the values are compared"
                      },
                      "reason": {
                        "type": "string",
                        "enum": [
                          "advisor",
                          "same_name",
                          "catalog",
                          "values"
                        ]
                      },
                      "overlap": {
                        "type": "number",
                        "nullable": true,
                        "description": "Share (0 to 1) of the rows of the sample of the main source whose value is in the lookup"
                      },
                      "matched_rows": {
                        "type": "integer"
                      },
                      "sample_rows": {
                        "type": "integer"
                      },
                      "lookup_unique": {
                        "type": "number",
                        "nullable": true,
                        "description": "Distinct values / rows of the column in what was read of the lookup"
                      },
                      "confidence": {
                        "type": "number"
                      },
                      "notes": {
                        "type": "array",
                        "description": "UNITS_DIFFER, KINDS_DIFFER (catalogue), TYPES_COERCED, TYPES_DIFFER, LOOKUP_NOT_UNIQUE, LOOKUP_PARTLY_READ",
                        "items": {
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "main": {
                              "type": "string"
                            },
                            "lookup": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "JoinRunReport": {
        "properties": {
          "version": {
            "type": "integer"
          },
          "mode": {
            "type": "string",
            "enum": [
              "create",
              "refresh"
            ]
          },
          "started": {
            "type": "integer"
          },
          "finished": {
            "type": "integer"
          },
          "created": {
            "type": "integer"
          },
          "main": {
            "properties": {
              "source": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "rows": {
                "type": "integer"
              },
              "exists": {
                "type": "boolean"
              }
            }
          },
          "output_rows": {
            "type": "integer"
          },
          "dropped_rows": {
            "type": "integer",
            "description": "Rows of the main source left out by inner lookups"
          },
          "memory": {
            "properties": {
              "rows": {
                "type": "integer"
              },
              "bytes": {
                "type": "integer"
              },
              "limit_rows": {
                "type": "integer"
              },
              "limit_bytes": {
                "type": "integer"
              }
            }
          },
          "lookups": {
            "type": "array",
            "items": {
              "properties": {
                "source": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "exists": {
                  "type": "boolean"
                },
                "kind": {
                  "type": "string"
                },
                "keys": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "main": {
                        "type": "string"
                      },
                      "lookup": {
                        "type": "string"
                      }
                    }
                  }
                },
                "rows": {
                  "type": "integer"
                },
                "keys_loaded": {
                  "type": "integer"
                },
                "empty_keys": {
                  "type": "integer"
                },
                "duplicate_keys": {
                  "type": "integer"
                },
                "duplicate_examples": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "unused_keys": {
                  "type": "integer"
                },
                "matched": {
                  "type": "integer"
                },
                "unmatched": {
                  "type": "integer"
                },
                "unmatched_empty": {
                  "type": "integer"
                },
                "match_rate": {
                  "type": "number",
                  "nullable": true
                },
                "examples": {
                  "type": "array",
                  "maxItems": 20,
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "examples_withheld": {
                  "type": "boolean"
                },
                "duplicate_examples_withheld": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "JoinReportView": {
        "properties": {
          "source": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "configuration": {
            "properties": {
              "main": {
                "type": "string"
              },
              "main_name": {
                "type": "string"
              },
              "lookups": {
                "type": "array",
                "items": {
                  "properties": {
                    "source": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "prefix": {
                      "type": "string"
                    },
                    "keys": {
                      "type": "array",
                      "items": {
                        "properties": {
                          "main": {
                            "type": "string"
                          },
                          "lookup": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "last": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/JoinRunReport"
              }
            ]
          },
          "history": {
            "type": "array",
            "items": {
              "properties": {
                "created": {
                  "type": "integer"
                },
                "mode": {
                  "type": "string"
                },
                "main_rows": {
                  "type": "integer"
                },
                "output_rows": {
                  "type": "integer"
                },
                "dropped_rows": {
                  "type": "integer"
                },
                "lookups": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "source": {
                        "type": "string"
                      },
                      "matched": {
                        "type": "integer"
                      },
                      "unmatched": {
                        "type": "integer"
                      },
                      "match_rate": {
                        "type": "number",
                        "nullable": true
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ModelQualityBrief": {
        "type": "object",
        "description": "Quality guarantee, short form (classifiers and regressors only): whether the model beats the naive prediction. Predictions are never blocked: warn the person when the verdict is `not_better_than_naive`.",
        "properties": {
          "verdict": {
            "type": "string",
            "enum": [
              "good",
              "weak",
              "not_better_than_naive",
              "unknown"
            ],
            "description": "`not_better_than_naive`: the gain over the naive prediction is within the noise of the measure (classifiers: one standard error of the naive share on the test rows; regressors: an R² of 0.02 or less). `weak`: better, but it removes less than a fifth of the errors of the naive prediction. `good`: the rest. `unknown`: no stored evaluation to tell."
          },
          "metric": {
            "type": "string",
            "nullable": true,
            "enum": [
              "accuracy",
              "balanced_accuracy",
              "r2"
            ],
            "description": "The figure the verdict is about: the accuracy against the share of the most frequent class of the test rows; with unbalanced classes (the smallest has less than a quarter of the rows of the largest), the balanced accuracy against 1 / classes; the R² of a regressor against 0 (always predicting the mean)."
          },
          "value": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "The figure of the model (0 to 1; R² for regressors)."
          },
          "naive": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "The figure of the naive prediction."
          }
        }
      },
      "ModelQuality": {
        "type": "object",
        "description": "Quality guarantee (classifiers and regressors only): whether the model beats the naive prediction, computed from its stored evaluation, with the likely reasons when it does not and what the automatic second attempt did. It never holds values of the target.",
        "properties": {
          "verdict": {
            "type": "string",
            "enum": [
              "good",
              "weak",
              "not_better_than_naive",
              "unknown"
            ],
            "description": "`not_better_than_naive`: the gain over the naive prediction is within the noise of the measure (classifiers: one standard error of the naive share on the test rows; regressors: an R² of 0.02 or less). `weak`: better, but it removes less than a fifth of the errors of the naive prediction. `good`: the rest. `unknown`: no stored evaluation to tell."
          },
          "metric": {
            "type": "string",
            "nullable": true,
            "enum": [
              "accuracy",
              "balanced_accuracy",
              "r2"
            ],
            "description": "The figure the verdict is about: the accuracy against the share of the most frequent class of the test rows; with unbalanced classes (the smallest has less than a quarter of the rows of the largest), the balanced accuracy against 1 / classes; the R² of a regressor against 0 (always predicting the mean)."
          },
          "value": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "The figure of the model (0 to 1; R² for regressors)."
          },
          "naive": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "The figure of the naive prediction."
          },
          "gain": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "`value` - `naive`."
          },
          "margin": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "The gain that is only noise: at or under it, the model is not better than the naive prediction."
          },
          "skill": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "Share of the errors of the naive prediction the model removes: `gain` / (1 - `naive`)."
          },
          "test_rows": {
            "type": "integer",
            "description": "Test rows of the evaluation (classifiers)."
          },
          "classes": {
            "type": "integer",
            "description": "Classes with test rows (classifiers)."
          },
          "unbalanced": {
            "type": "boolean",
            "description": "Whether the classes of the test rows are unbalanced (classifiers)."
          },
          "reasons": {
            "type": "array",
            "description": "Only when the verdict is `not_better_than_naive`: why it may be, each with what to do. First what is wrong with the data; when nothing is, `no_related_input` first; then what the inputs have that is worth checking (`identifier_input`, `inputs_left_out`).",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "description": "Stable code of the reason: read this, not the text.",
                  "enum": [
                    "inputs_left_out",
                    "identifier_input",
                    "text_not_read",
                    "too_many_categories",
                    "few_rows",
                    "target_almost_constant",
                    "too_many_classes",
                    "no_related_input"
                  ]
                },
                "text": {
                  "type": "string",
                  "description": "Why, in plain words: in the language of the request (Accept-Language), English by default."
                },
                "action": {
                  "type": "string",
                  "description": "What to do, in the same language."
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "The columns it is about, when it is about columns (at most 8)."
                }
              }
            }
          },
          "second_attempt": {
            "type": "object",
            "description": "Only when the model asked for was not better than the naive prediction when it was created: the other methods AIR-Core tried.",
            "properties": {
              "tried": {
                "type": "integer",
                "description": "Methods tried besides the one asked for."
              },
              "methods": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "done",
                        "failed",
                        "skipped"
                      ]
                    },
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "good",
                        "weak",
                        "not_better_than_naive",
                        "unknown"
                      ],
                      "description": "`not_better_than_naive`: the gain over the naive prediction is within the noise of the measure (classifiers: one standard error of the naive share on the test rows; regressors: an R² of 0.02 or less). `weak`: better, but it removes less than a fifth of the errors of the naive prediction. `good`: the rest. `unknown`: no stored evaluation to tell."
                    },
                    "value": {
                      "type": "number",
                      "format": "double",
                      "nullable": true,
                      "description": "Its figure."
                    }
                  }
                }
              },
              "asked": {
                "type": "string",
                "description": "The method asked for."
              },
              "kept": {
                "type": "string",
                "description": "The method the model has."
              },
              "replaced": {
                "type": "boolean",
                "description": "Whether the model is one of the methods tried, not the one asked for."
              }
            }
          }
        }
      },
      "VisualizationSuggestion": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "What it shows: trend, by, scatter, share, dist, map, heat, trendBy, treemap, total, avg, count or table",
            "example": "trend"
          },
          "name": {
            "type": "string",
            "description": "Name the visualization takes when created"
          },
          "reason": {
            "type": "string",
            "description": "Why it is recommended, in a sentence"
          },
          "type": {
            "type": "string",
            "description": "Type of chart",
            "example": "line"
          },
          "configuration": {
            "type": "object",
            "description": "The configuration that draws it (axes and series as indexes of the fields of the source), ready for POST /visualizations"
          }
        }
      },
      "DashboardProposalCounts": {
        "type": "object",
        "properties": {
          "sources": {
            "type": "integer"
          },
          "existing": {
            "type": "integer",
            "description": "Visualizations already made that the dashboard reuses"
          },
          "created": {
            "type": "integer",
            "description": "Recommended visualizations created with it"
          },
          "models": {
            "type": "integer"
          }
        }
      },
      "DashboardProposal": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "sections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "source": {
                  "type": "string",
                  "description": "The source of the section (empty for the models)"
                },
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "existing",
                          "new",
                          "model",
                          "text"
                        ]
                      },
                      "key": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string",
                        "description": "The visualization (existing) or the model (model)"
                      },
                      "configuration": {
                        "type": "object",
                        "description": "The configuration of a recommended one (new)"
                      },
                      "text": {
                        "type": "string"
                      },
                      "x": {
                        "type": "integer"
                      },
                      "y": {
                        "type": "integer"
                      },
                      "w": {
                        "type": "integer"
                      },
                      "h": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "skipped": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "source": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "reason": {
                  "type": "string",
                  "enum": [
                    "empty",
                    "realtime",
                    "limit"
                  ]
                }
              }
            }
          },
          "counts": {
            "$ref": "#/components/schemas/DashboardProposalCounts"
          }
        }
      },
      "AIPolicy": {
        "type": "object",
        "properties": {
          "level": {
            "type": "string",
            "enum": [
              "structure",
              "aggregates",
              "rows"
            ]
          },
          "origin": {
            "type": "string",
            "enum": [
              "migrated",
              "chosen",
              "default"
            ],
            "description": "migrated: kept from before the policy existed; chosen: set by an owner or administrator; default: a new organization (rows)"
          },
          "levels": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "structure",
                "aggregates",
                "rows"
              ]
            }
          },
          "workspaces": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "level": {
                  "type": "string",
                  "enum": [
                    "structure",
                    "aggregates",
                    "rows"
                  ]
                },
                "effective": {
                  "type": "string",
                  "enum": [
                    "structure",
                    "aggregates",
                    "rows"
                  ]
                }
              }
            }
          },
          "providers": {
            "type": "object",
            "properties": {
              "own_key": {
                "type": "boolean"
              },
              "assistant": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "own_key",
                      "platform",
                      "connected_app",
                      "none"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "model": {
                    "type": "string"
                  },
                  "eu": {
                    "type": "boolean",
                    "description": "Processes the data in the EU or on the premises"
                  },
                  "where": {
                    "type": "string",
                    "description": "eu, on_premises, air_institute, a country code or unknown"
                  }
                }
              },
              "data": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "own_key",
                      "platform",
                      "connected_app",
                      "none"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "model": {
                    "type": "string"
                  },
                  "eu": {
                    "type": "boolean",
                    "description": "Processes the data in the EU or on the premises"
                  },
                  "where": {
                    "type": "string",
                    "description": "eu, on_premises, air_institute, a country code or unknown"
                  }
                }
              }
            }
          },
          "features": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "needs": {
                  "type": "string",
                  "enum": [
                    "none",
                    "structure",
                    "aggregates",
                    "rows"
                  ]
                },
                "llm": {
                  "type": "boolean"
                }
              }
            }
          },
          "updated": {
            "type": "integer",
            "description": "Unix time in milliseconds"
          },
          "updated_by": {
            "type": "string"
          }
        }
      },
      "AIRegisterItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "builtin:<feature>, model:<id>, genai:<id> or app:<client id> (an AI application connected through MCP)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "builtin",
              "model",
              "genai_model",
              "connected_app"
            ]
          },
          "name": {
            "type": "string"
          },
          "workspace": {
            "type": "string"
          },
          "workspace_name": {
            "type": "string"
          },
          "generative": {
            "type": "boolean"
          },
          "purpose": {
            "type": "string"
          },
          "risk": {
            "type": "string",
            "enum": [
              "unassessed",
              "minimal",
              "limited",
              "high"
            ]
          },
          "prohibited": {
            "type": "object",
            "additionalProperties": {
              "type": "boolean"
            },
            "description": "Practices of Art. 5(1) marked as possibly involved"
          },
          "prohibited_reviewed": {
            "type": "boolean"
          },
          "provider": {
            "type": "string"
          },
          "oversight": {
            "type": "string"
          },
          "transparency": {
            "type": "string"
          },
          "data": {
            "type": "string"
          },
          "data_level": {
            "type": "string"
          },
          "logs": {
            "type": "string"
          },
          "responsible": {
            "type": "string"
          },
          "last_review": {
            "type": "string",
            "description": "YYYY-MM-DD"
          },
          "notes": {
            "type": "string"
          },
          "articles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "category": {
            "type": "string",
            "enum": [
              "feature",
              "genai_model",
              "model",
              "forecast",
              "connected_app"
            ]
          },
          "risk_reason": {
            "type": "string",
            "description": "Why it has its risk category, in a sentence (high risk only when the organization chose it)"
          },
          "risk_chosen": {
            "type": "boolean"
          },
          "provider_name": {
            "type": "string"
          },
          "model_name": {
            "type": "string"
          },
          "region": {
            "type": "string",
            "description": "Where the data is processed: eu, on_premises, air_institute, a country code, unknown, or inside (in AIR-Core, no language model)"
          },
          "eu": {
            "type": "boolean",
            "nullable": true
          },
          "sees": {
            "type": "string",
            "enum": [
              "none",
              "structure",
              "aggregates",
              "rows",
              "blocked"
            ],
            "description": "What the AI sees of the data under the AI data policy (blocked: the policy does not allow what it needs)"
          },
          "personal_data": {
            "type": "string",
            "enum": [
              "inside",
              "not_sent",
              "protected",
              "allowed"
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "first": {
                "type": "integer",
                "description": "Unix ms (0 unknown)"
              },
              "last": {
                "type": "integer"
              },
              "uses_90d": {
                "type": "integer"
              },
              "in_use": {
                "type": "boolean",
                "description": "Used in the last 90 days"
              }
            }
          },
          "review": {
            "type": "object",
            "description": "Reviewed or pending review, with who and when; pending again when the provider or the model changes or after a year",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "reviewed",
                  "pending"
                ]
              },
              "by": {
                "type": "string"
              },
              "at": {
                "type": "integer"
              },
              "reason": {
                "type": "string",
                "enum": [
                  "",
                  "never",
                  "marked",
                  "provider_changed",
                  "expired"
                ]
              }
            }
          }
        }
      },
      "AIRegister": {
        "type": "object",
        "properties": {
          "level": {
            "type": "string",
            "enum": [
              "structure",
              "aggregates",
              "rows"
            ]
          },
          "generated": {
            "type": "string",
            "format": "date-time"
          },
          "risks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "prohibited_practices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "ref": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "articles": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "ref": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AIRegisterItem"
            }
          },
          "summary": {
            "$ref": "#/components/schemas/AIRegisterSummary"
          },
          "obligations": {
            "type": "array",
            "description": "The state of the organization against what the AI Act asks of those who use AI: guidance, not legal advice",
            "items": {
              "$ref": "#/components/schemas/AIObligation"
            }
          },
          "checklist": {
            "type": "object",
            "properties": {
              "literacy": {
                "type": "boolean",
                "description": "The organization confirmed that the people who use AI received training or guidance (Art. 4)"
              },
              "literacy_at": {
                "type": "integer"
              },
              "literacy_by": {
                "type": "string"
              }
            }
          }
        }
      },
      "AIRegisterSummary": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "in_use": {
            "type": "integer",
            "description": "Used in the last 90 days"
          },
          "by_risk": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "by_risk_in_use": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "providers": {
            "type": "object",
            "properties": {
              "all_eu": {
                "type": "boolean"
              },
              "apps": {
                "type": "integer",
                "description": "Connected AI applications (their provider is chosen by each person)"
              },
              "list": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "model": {
                      "type": "string"
                    },
                    "region": {
                      "type": "string"
                    },
                    "eu": {
                      "type": "boolean"
                    },
                    "own_key": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "evidence": {
            "type": "object",
            "nullable": true,
            "description": "The AI activity log of the last 90 days: calls, calls processed outside the EU (not counting connected applications) and values pseudonymised or not sent",
            "properties": {
              "calls": {
                "type": "integer"
              },
              "outside_eu": {
                "type": "integer"
              },
              "apps": {
                "type": "integer"
              },
              "masked": {
                "type": "integer"
              },
              "omitted": {
                "type": "integer"
              }
            }
          },
          "personal": {
            "type": "object",
            "properties": {
              "level": {
                "type": "string"
              },
              "sources": {
                "type": "integer"
              },
              "fields": {
                "type": "integer"
              },
              "never": {
                "type": "integer"
              },
              "pseudonymise": {
                "type": "integer"
              },
              "allow": {
                "type": "integer"
              }
            }
          },
          "review": {
            "type": "object",
            "properties": {
              "reviewed": {
                "type": "integer"
              },
              "pending": {
                "type": "integer"
              },
              "pending_in_use": {
                "type": "integer"
              },
              "last_at": {
                "type": "integer"
              },
              "last_by": {
                "type": "string"
              }
            }
          },
          "retention_days": {
            "type": "integer"
          }
        }
      },
      "AIObligation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "literacy",
              "prohibited",
              "classified",
              "transparency",
              "oversight",
              "high_risk",
              "logs",
              "review"
            ]
          },
          "ref": {
            "type": "string",
            "description": "Article of Regulation (EU) 2024/1689"
          },
          "status": {
            "type": "string",
            "enum": [
              "done",
              "todo",
              "warning",
              "na"
            ]
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "ValueHeadline": {
        "type": "object",
        "description": "The figures of the top of the value report: estimated hours saved, notices of the automations and the records they found, questions answered by the AI, predictions and the models that made them, people who used the AI and dashboard views (null: not recorded in the period)",
        "properties": {
          "hours": {
            "type": "number"
          },
          "alerts": {
            "type": "integer"
          },
          "alert_records": {
            "type": "integer"
          },
          "questions": {
            "type": "integer"
          },
          "predictions": {
            "type": "integer",
            "nullable": true
          },
          "models_in_use": {
            "type": "integer",
            "nullable": true
          },
          "people": {
            "type": "integer",
            "nullable": true
          },
          "dashboard_views": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "AISeen": {
        "type": "object",
        "description": "What was sent to the model in one call: counts and names, never data",
        "properties": {
          "v": {
            "type": "integer"
          },
          "feature": {
            "type": "string"
          },
          "level": {
            "type": "string",
            "enum": [
              "structure",
              "aggregates",
              "rows"
            ]
          },
          "needs": {
            "type": "string"
          },
          "provider": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "eu": {
                "type": "boolean"
              },
              "where": {
                "type": "string"
              }
            }
          },
          "structure": {
            "type": "boolean"
          },
          "values": {
            "type": "boolean"
          },
          "aggregates": {
            "type": "integer"
          },
          "rows": {
            "type": "integer"
          },
          "texts": {
            "type": "integer"
          },
          "documents": {
            "type": "integer"
          },
          "masked": {
            "type": "integer",
            "description": "Values replaced by tokens"
          },
          "omitted": {
            "type": "integer",
            "description": "Values not sent (personal data never sent)"
          },
          "refused": {
            "type": "string"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "never": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "pseudonymised": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "AIAudit": {
        "type": "object",
        "properties": {
          "format": {
            "type": "string"
          },
          "organization": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "policy": {
            "$ref": "#/components/schemas/AIPolicy"
          },
          "personal_data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "workspace": {
                  "type": "string"
                },
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "kinds": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "detected_by": {
                        "type": "string"
                      },
                      "choice": {
                        "type": "string",
                        "enum": [
                          "never",
                          "pseudonymise",
                          "allow"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "register": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "activity": {
            "type": "object",
            "properties": {
              "entries": {
                "type": "integer"
              },
              "truncated": {
                "type": "boolean"
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "seen": {
                      "$ref": "#/components/schemas/AISeen"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "AILimit": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "all",
              "free",
              "none"
            ],
            "description": "What AI it may use: everything, only AI that spends no credits, or none"
          },
          "spend_eur": {
            "type": "number",
            "nullable": true,
            "description": "Most AI credit per month, in charged euros (null: no limit of its own)"
          },
          "tokens": {
            "type": "integer",
            "nullable": true,
            "description": "Most tokens per month of AI that spends no credits (null: no limit)"
          }
        }
      },
      "AILimits": {
        "type": "object",
        "properties": {
          "month": {
            "type": "string",
            "description": "YYYY-MM (UTC), the month of the use"
          },
          "roles": {
            "type": "array",
            "description": "Every role that can have limits (administrators, custom roles and default users)",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "limit": {
                  "$ref": "#/components/schemas/AILimit"
                }
              }
            }
          },
          "people": {
            "type": "array",
            "description": "The people with their own limits",
            "items": {
              "type": "object",
              "properties": {
                "user": {
                  "type": "string"
                },
                "limit": {
                  "$ref": "#/components/schemas/AILimit"
                }
              }
            }
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "user": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "role": {
                  "type": "string"
                },
                "limits_from": {
                  "type": "string",
                  "enum": [
                    "owner",
                    "person",
                    "role",
                    "none"
                  ],
                  "description": "owner: never limited; person: their own limits; role: those of their role; none: no limits"
                },
                "limit": {
                  "$ref": "#/components/schemas/AILimit"
                },
                "spent_eur": {
                  "type": "number",
                  "description": "AI credit spent this month in the organization (charged euros)"
                },
                "tokens_without_credits": {
                  "type": "integer",
                  "description": "Tokens of AI that spends no credits this month in the organization"
                },
                "percent": {
                  "type": "integer",
                  "nullable": true,
                  "description": "Highest share of a limit used (null: no limit)"
                }
              }
            }
          },
          "tokens_per_request": {
            "type": "integer",
            "description": "Average tokens of a request to the AI in the organization over the last 30 days (5000 without enough history), to explain a token limit"
          },
          "tokens_per_request_from_history": {
            "type": "boolean"
          }
        }
      },
      "Comment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "thread": {
            "type": "string"
          },
          "author": {
            "type": "object",
            "properties": {
              "uid": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "text": {
            "type": "string",
            "description": "Plain text: show it as text, with the http and https links found in it as links. Never HTML."
          },
          "mentions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "uid": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "edited": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "can": {
            "type": "object",
            "properties": {
              "edit": {
                "type": "boolean"
              },
              "delete": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "CommentThread": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "target_type": {
            "type": "string",
            "enum": [
              "dashboard",
              "visualization"
            ]
          },
          "target_id": {
            "type": "string"
          },
          "card": {
            "type": "string",
            "description": "Card of the dashboard (section:item), empty for the whole of it"
          },
          "card_label": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "resolved"
            ]
          },
          "author": {
            "type": "object",
            "properties": {
              "uid": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          },
          "resolved_by": {
            "nullable": true,
            "type": "object",
            "properties": {
              "uid": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "resolved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Comment"
            }
          }
        }
      },
      "CommentCounts": {
        "type": "object",
        "properties": {
          "open": {
            "type": "integer"
          },
          "resolved": {
            "type": "integer"
          },
          "by_card": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Open threads by card (\"\" is the whole dashboard)"
          }
        }
      },
      "Annotation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "target_type": {
            "type": "string",
            "enum": [
              "visualization",
              "source"
            ]
          },
          "target_id": {
            "type": "string"
          },
          "field": {
            "type": "integer",
            "description": "Index of the date field of the source, -1 on a visualization"
          },
          "field_name": {
            "type": "string"
          },
          "date_from": {
            "type": "string",
            "example": "2026-03-12",
            "description": "YYYY-MM-DD or YYYY-MM-DDTHH:mm, in UTC"
          },
          "date_to": {
            "type": "string",
            "description": "End of a range, or empty"
          },
          "text": {
            "type": "string",
            "maxLength": 120,
            "example": "Lanzamos la campaña"
          },
          "shared": {
            "type": "boolean",
            "description": "Shown in shared and embedded views"
          },
          "updated": {
            "type": "integer"
          },
          "can_edit": {
            "type": "boolean"
          }
        }
      },
      "AnnotationInput": {
        "type": "object",
        "required": [
          "target_type",
          "target_id",
          "date_from",
          "text"
        ],
        "properties": {
          "target_type": {
            "type": "string",
            "enum": [
              "visualization",
              "source"
            ]
          },
          "target_id": {
            "type": "string"
          },
          "field": {
            "oneOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ],
            "description": "Date field of the source (index or name); required on a source"
          },
          "date_from": {
            "type": "string",
            "example": "2026-03-12"
          },
          "date_to": {
            "type": "string",
            "example": "2026-03-20"
          },
          "text": {
            "type": "string",
            "maxLength": 120
          },
          "shared": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "Notification": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "mention",
              "reply"
            ]
          },
          "actor": {
            "type": "object",
            "properties": {
              "uid": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "target_type": {
            "type": "string",
            "enum": [
              "dashboard",
              "visualization"
            ]
          },
          "target_id": {
            "type": "string"
          },
          "target_name": {
            "type": "string"
          },
          "card": {
            "type": "string"
          },
          "excerpt": {
            "type": "string"
          },
          "thread": {
            "type": "string"
          },
          "organization": {
            "type": "string"
          },
          "ws": {
            "type": "string"
          },
          "link": {
            "type": "string",
            "description": "Path that opens the dashboard at the card (or the visualization) with the thread open"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "read": {
            "type": "boolean"
          }
        }
      },
      "CollabError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "NOT_FOUND"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "VisualizationConfig": {
        "description": "Visualization configuration, everything is optional",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "table-s",
              "table-rt",
              "scatter",
              "line",
              "datebased",
              "bars",
              "histogram",
              "xy",
              "xy-rt",
              "single-value",
              "kpi",
              "pie",
              "chord",
              "step",
              "radar",
              "table",
              "pareto",
              "wordcloud",
              "map",
              "street-heat",
              "street-heat-time",
              "country-map",
              "am-heat-map",
              "treemap",
              "treemap-voronoi",
              "heat",
              "image",
              "iframe",
              "social",
              "human",
              "custom"
            ]
          },
          "instances": {
            "type": "number",
            "format": "int32",
            "description": "Max number of instances"
          },
          "instOrder": {
            "type": "number",
            "format": "int32",
            "description": "Feature index to use for pre-sort"
          },
          "instDir": {
            "type": "string",
            "description": "Instances order direction",
            "enum": [
              "asc",
              "desc"
            ]
          },
          "filter": {
            "$ref": "#/components/schemas/QueryTree"
          },
          "xAxisType": {
            "type": "string",
            "enum": [
              "value",
              "date",
              "category",
              "count",
              "count_normalize",
              "sum",
              "avg",
              "max",
              "min"
            ]
          },
          "yAxisType": {
            "type": "string",
            "enum": [
              "value",
              "date",
              "category",
              "count",
              "count_normalize",
              "sum",
              "avg",
              "max",
              "min"
            ]
          },
          "zAxisType": {
            "type": "string",
            "enum": [
              "value",
              "date",
              "category",
              "count",
              "count_normalize",
              "sum",
              "avg",
              "max",
              "min"
            ]
          },
          "xAxisFeature": {
            "type": "number",
            "format": "int32",
            "description": "Feature index"
          },
          "yAxisFeature": {
            "type": "number",
            "format": "int32",
            "description": "Feature index"
          },
          "zAxisFeature": {
            "type": "number",
            "format": "int32",
            "description": "Feature index"
          },
          "seriesMaker": {
            "type": "number",
            "format": "int32",
            "description": "Feature index or -1"
          },
          "minValue": {
            "type": "number",
            "format": "double"
          },
          "maxValue": {
            "type": "number",
            "format": "double"
          },
          "units": {
            "type": "string",
            "example": "ms"
          },
          "unitsX": {
            "type": "string",
            "example": "ms"
          },
          "unitsY": {
            "type": "string",
            "example": "ms"
          },
          "unitsZ": {
            "type": "string",
            "example": "ms"
          },
          "unitsS": {
            "type": "string",
            "example": "ms"
          },
          "labelX": {
            "type": "string",
            "example": "X"
          },
          "labelY": {
            "type": "string",
            "example": "Y"
          },
          "labelZ": {
            "type": "string",
            "example": "Z"
          },
          "labelS": {
            "type": "string",
            "example": "X"
          },
          "numericIntervals": {
            "type": "number",
            "format": "int32",
            "description": "Max numeric intervals for numeric series"
          },
          "ranges": {
            "type": "string",
            "example": "0,10,20,30,50,80,100",
            "description": "For some visualizations like the KPI, ranges of values"
          },
          "useRanges": {
            "type": "boolean"
          },
          "tablePrimaryDisplay": {
            "type": "array",
            "description": "Table display data",
            "items": {
              "properties": {
                "index": {
                  "type": "number",
                  "format": "int32",
                  "description": "Feature Index"
                },
                "name": {
                  "type": "string",
                  "description": "Feature name"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "nominal",
                    "text",
                    "logic",
                    "date",
                    "numeric"
                  ]
                }
              }
            }
          },
          "tableMakeGroups": {
            "type": "array",
            "description": "Table groups for complex tables",
            "items": {
              "properties": {
                "index": {
                  "type": "number",
                  "format": "int32",
                  "description": "Feature Index"
                },
                "name": {
                  "type": "string",
                  "description": "Feature name"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "nominal",
                    "text",
                    "logic",
                    "date",
                    "numeric"
                  ]
                },
                "g": {
                  "type": "string",
                  "description": "grouping method",
                  "enum": [
                    "value",
                    "date",
                    "category",
                    "count",
                    "count_normalize",
                    "sum",
                    "avg",
                    "max",
                    "min"
                  ]
                }
              }
            }
          },
          "tableExtraCols": {
            "type": "array",
            "description": "Extra cols for complex tables",
            "items": {
              "properties": {
                "index": {
                  "type": "number",
                  "format": "int32",
                  "description": "Feature Index"
                },
                "name": {
                  "type": "string",
                  "description": "Feature name"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "nominal",
                    "text",
                    "logic",
                    "date",
                    "numeric"
                  ]
                },
                "g": {
                  "type": "string",
                  "description": "grouping method",
                  "enum": [
                    "value",
                    "date",
                    "category",
                    "count",
                    "count_normalize",
                    "sum",
                    "avg",
                    "max",
                    "min"
                  ]
                }
              }
            }
          },
          "durationValue": {
            "type": "number",
            "format": "int32",
            "description": "Duration for maps with timeline"
          },
          "durationUnits": {
            "type": "string",
            "enum": [
              "s",
              "m",
              "h",
              "d",
              "w",
              "y"
            ]
          },
          "customSeries": {
            "description": "Custom series for XY (custom)",
            "type": "array",
            "items": {
              "properties": {
                "index": {
                  "type": "number",
                  "format": "in32",
                  "description": "Feature index"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "line",
                    "column"
                  ]
                },
                "axisType": {
                  "enum": [
                    "value",
                    "date",
                    "category",
                    "count",
                    "count_normalize",
                    "sum",
                    "avg",
                    "max",
                    "min"
                  ]
                },
                "label": {
                  "type": "string"
                },
                "units": {
                  "type": "string"
                }
              }
            }
          },
          "mapcenter": {
            "type": "string",
            "enum": [
              "last",
              "avg",
              "custom"
            ]
          },
          "lat": {
            "type": "number",
            "format": "double",
            "description": "Map center latitude"
          },
          "lng": {
            "type": "number",
            "format": "double",
            "description": "Map center longitude"
          },
          "zoom": {
            "type": "number",
            "format": "int32",
            "description": "Map initial zoom 0 to 22"
          },
          "maxZoom": {
            "type": "number",
            "format": "int32",
            "description": "Map max zoom 0 to 22"
          },
          "blur": {
            "type": "number",
            "format": "int32",
            "description": "Map blur level (For heat maps)"
          },
          "radious": {
            "type": "number",
            "format": "int32",
            "description": "Map circle radious in px"
          },
          "wordCloudMode": {
            "type": "string",
            "enum": [
              "pre",
              "text"
            ]
          },
          "ignoreSeries": {
            "type": "boolean",
            "description": "True to always use categories for series, even with a numeric feature"
          },
          "social": {
            "type": "string",
            "enum": [
              "twttr"
            ]
          },
          "groupingMethod": {
            "type": "string",
            "description": "Grouping method for values",
            "enum": [
              "none",
              "sum",
              "average",
              "low",
              "high",
              "close",
              "open"
            ]
          },
          "customOrder": {
            "type": "string",
            "description": "Custom order for X axis",
            "example": "Jan,Feb,Mar"
          },
          "customOrderHeat": {
            "type": "string",
            "description": "Custom order for cols for heatmaps",
            "example": "Jan,Feb,Mar"
          },
          "custom_url": {
            "type": "string",
            "description": "URL to the widget for custom visualizations"
          },
          "custom_params": {
            "type": "array",
            "items": {
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          },
          "custom_params_mode": {
            "type": "string",
            "enum": [
              "?",
              "#"
            ]
          },
          "showTitle": {
            "type": "boolean"
          },
          "showScrollbars": {
            "type": "boolean"
          },
          "showLegend": {
            "type": "boolean"
          },
          "showGrid": {
            "type": "boolean"
          },
          "showRaw": {
            "type": "boolean"
          },
          "fillSeries": {
            "type": "boolean"
          },
          "stacked": {
            "type": "boolean"
          },
          "layered": {
            "type": "boolean"
          },
          "mapCluster": {
            "type": "boolean"
          },
          "clusterField": {
            "type": "number",
            "format": "int32",
            "description": "Feature index to use for clustering (maps)"
          },
          "clusterMode": {
            "type": "string",
            "enum": [
              "count",
              "avg",
              "sum",
              "max",
              "min"
            ]
          },
          "showArrows": {
            "type": "boolean"
          },
          "axisTitles": {
            "type": "boolean"
          },
          "hasPadding": {
            "type": "boolean"
          },
          "axisLabels": {
            "type": "boolean"
          },
          "trendLines": {
            "type": "boolean"
          },
          "inversedAxis": {
            "type": "boolean"
          },
          "customMarker": {
            "type": "string",
            "description": "Custom marker icon for maps"
          },
          "useMagnitude": {
            "type": "boolean"
          },
          "avgCoords": {
            "type": "boolean"
          },
          "fontSize": {
            "type": "number",
            "format": "int32"
          },
          "titleFontSize": {
            "type": "number",
            "format": "int32"
          },
          "background": {
            "type": "string",
            "example": "#FFFFFF"
          },
          "xAxisDispStyle": {
            "type": "string",
            "enum": [
              "horizontal",
              "vertical",
              "pitched"
            ]
          },
          "colors": {
            "type": "string",
            "example": "#FFFFFF, #000000, #FEFEFE"
          },
          "useCustomColors": {
            "type": "boolean"
          },
          "useMultipleScales": {
            "type": "boolean"
          },
          "showSeriesLabels": {
            "type": "boolean"
          },
          "tension": {
            "type": "number",
            "format": "double"
          },
          "strokeWidth": {
            "type": "number",
            "format": "int32"
          },
          "bullets": {
            "type": "string",
            "enum": [
              "none",
              "circle",
              "square",
              "triangle"
            ]
          },
          "decimalDigits": {
            "type": "number",
            "format": "int32"
          },
          "dateFormat": {
            "type": "string",
            "example": "YYYY-MM-DD HH:mm:ss"
          },
          "scrollbarSize": {
            "type": "number",
            "format": "int32"
          },
          "legendPos": {
            "type": "string",
            "enum": [
              "up",
              "down",
              "left",
              "right"
            ]
          },
          "noanimations": {
            "type": "boolean"
          },
          "autoreload": {
            "type": "boolean"
          },
          "fillColor": {
            "type": "string",
            "example": "#FFFFF"
          },
          "minColor": {
            "type": "string",
            "example": "#FFFFF"
          },
          "maxColor": {
            "type": "string",
            "example": "#FFFFF"
          },
          "cmc": {
            "description": "Color based on value",
            "type": "array",
            "items": {
              "properties": {
                "from": {
                  "type": "number",
                  "format": "double"
                },
                "to": {
                  "type": "number",
                  "format": "double"
                },
                "fillColor": {
                  "type": "string",
                  "example": "#FFFFFF"
                }
              }
            }
          },
          "categoryMap": {
            "description": "Category map",
            "type": "array",
            "items": {
              "properties": {
                "index": {
                  "type": "number",
                  "format": "int32",
                  "description": "Feature index"
                },
                "name": {
                  "type": "string",
                  "description": "Feature name"
                },
                "map": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "value": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "SourceCatalog": {
        "description": "The catalogue of a data source («Ficha»). Kept apart from the source (table source_catalog), by field name: a field renamed in «Edit features» keeps its entry.",
        "properties": {
          "source": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "description": "What the data are (at most 2000 characters)"
          },
          "steward": {
            "type": "string",
            "description": "Person, team or role in charge (at most 120 characters). Never sent to an AI"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "provenance": {
            "properties": {
              "origin": {
                "type": "string",
                "description": "Where the data come from (written by people)"
              },
              "update_process": {
                "type": "string",
                "description": "How and when they are updated (written by people)"
              },
              "derived_from": {
                "type": "array",
                "items": {
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    }
                  }
                }
              },
              "computed": {
                "description": "What AIR-Core knows, read each time",
                "properties": {
                  "kind": {
                    "type": "string",
                    "description": "Kind of origin: the import type (url/any, database/mysql...), derived, real_time, external or the type of the source"
                  },
                  "derived_type": {
                    "type": "string"
                  },
                  "parents": {
                    "type": "array",
                    "items": {
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "model": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  },
                  "automatic_update": {
                    "type": "boolean"
                  },
                  "update_every_ms": {
                    "type": "integer"
                  },
                  "created": {
                    "type": "integer"
                  },
                  "last_modified": {
                    "type": "integer"
                  }
                }
              }
            }
          },
          "fields": {
            "type": "array",
            "items": {
              "properties": {
                "index": {
                  "type": "integer"
                },
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "unit": {
                  "type": "string"
                },
                "semantic_type": {
                  "type": "string",
                  "enum": [
                    "",
                    "identifier",
                    "category",
                    "amount",
                    "measure",
                    "percentage",
                    "date",
                    "geo",
                    "free_text",
                    "boolean",
                    "other"
                  ]
                },
                "allowed_values": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "range": {
                  "type": "object",
                  "nullable": true,
                  "properties": {
                    "min": {},
                    "max": {}
                  }
                },
                "personal_data": {
                  "nullable": true,
                  "description": "For people: {detected, kinds, choice} or null; for an AI: not_sent, pseudonymised, allowed or null"
                }
              }
            }
          },
          "personal_data_checked": {
            "type": "boolean"
          },
          "ai_withheld": {
            "type": "array",
            "description": "Texts an AI would not receive: {field ('' for the source), key, kinds}",
            "items": {
              "properties": {
                "field": {
                  "type": "string"
                },
                "key": {
                  "type": "string"
                },
                "kinds": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "withheld_for_ai": {
            "type": "array",
            "description": "For an AI: the paths of what was left out",
            "items": {
              "type": "string"
            }
          },
          "can_edit": {
            "type": "boolean"
          },
          "version": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          },
          "updated_by": {
            "type": "string"
          }
        }
      },
      "SourceCatalogChange": {
        "description": "A change of the catalogue of a source: only the keys sent change; null or empty clears a value",
        "properties": {
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 2000
          },
          "steward": {
            "type": "string",
            "nullable": true,
            "maxLength": 120
          },
          "tags": {
            "type": "array",
            "nullable": true,
            "maxItems": 15,
            "items": {
              "type": "string",
              "maxLength": 40
            }
          },
          "provenance": {
            "properties": {
              "origin": {
                "type": "string",
                "nullable": true,
                "maxLength": 500
              },
              "update_process": {
                "type": "string",
                "nullable": true,
                "maxLength": 500
              },
              "derived_from": {
                "type": "array",
                "nullable": true,
                "maxItems": 20,
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "fields": {
            "description": "By field name ({\"importe\": {...}}) or a list of entries with name or index ([{\"index\": 2, ...}])",
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": {
                  "$ref": "#/components/schemas/SourceCatalogFieldChange"
                }
              },
              {
                "type": "array",
                "maxItems": 100,
                "items": {
                  "$ref": "#/components/schemas/SourceCatalogFieldChange"
                }
              }
            ]
          }
        }
      },
      "SourceCatalogFieldChange": {
        "nullable": true,
        "properties": {
          "index": {
            "type": "integer",
            "description": "In a list: the index of the field"
          },
          "name": {
            "type": "string",
            "description": "In a list: the name of the field"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 500
          },
          "unit": {
            "type": "string",
            "nullable": true,
            "maxLength": 40
          },
          "semantic_type": {
            "type": "string",
            "nullable": true,
            "enum": [
              "",
              "identifier",
              "category",
              "amount",
              "measure",
              "percentage",
              "date",
              "geo",
              "free_text",
              "boolean",
              "other"
            ]
          },
          "allowed_values": {
            "type": "array",
            "nullable": true,
            "maxItems": 50,
            "items": {
              "type": "string",
              "maxLength": 120
            }
          },
          "range": {
            "type": "object",
            "nullable": true,
            "properties": {
              "min": {},
              "max": {}
            }
          }
        }
      },
      "SourceUndoState": {
        "description": "The undo of the last whole-column operation of a source",
        "properties": {
          "available": {
            "type": "boolean"
          },
          "until": {
            "type": "integer",
            "description": "Until when it can be undone (ms)"
          },
          "label": {
            "type": "object",
            "nullable": true,
            "description": "What it undoes: kind (transform or dedupe), op, feature, name, count"
          }
        }
      },
      "QueryTree": {
        "description": "Tree used to describe a query. Used in order to query instances of data sources.",
        "properties": {
          "type": {
            "type": "string",
            "description": "Node type (in the tree). single = leaf node, anyof = OR, allof = AND, not = NOT.",
            "enum": [
              "anyof",
              "allof",
              "not",
              "single"
            ]
          },
          "operation": {
            "type": "string",
            "description": "Operation type, determines the condition type. 'null' (The feature value must be NULL), 'eq' (The feature value must be equals to the specified value), 'lt' (Lower than), 'lte' (Lower than or equals), 'gt' (Greater than), 'gte' (Greater than or equals), 'cn' (Contains), 'cni' (Contains, ignore case), 'sw' (Starts with), 'swi' (Starts with, ignore case), 'ew' (Ends with), 'ewi' (Ends with, ignore case)",
            "enum": [
              null,
              "eq",
              "gt",
              "gte",
              "lt",
              "lte",
              "cn",
              "cni",
              "sw",
              "swi",
              "ew",
              "ewi"
            ]
          },
          "left": {
            "type": "integer",
            "format": "int32",
            "description": "Feature index affected by the condition"
          },
          "right": {
            "type": "string",
            "description": "Value to compare"
          },
          "children": {
            "type": "array",
            "description": "Children trees for 'anyof', 'allof' and 'not'.",
            "items": {
              "$ref": "#/components/schemas/QueryTree"
            }
          }
        }
      },
      "SourceMappingReport": {
        "type": "object",
        "description": "What a source mapping changes: the columns each new source lacks and the visualizations, filters and widgets that would lose columns.",
        "properties": {
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "from": {
                  "type": "string",
                  "description": "Original source ID"
                },
                "from_name": {
                  "type": "string"
                },
                "to": {
                  "type": "string",
                  "description": "New source ID"
                },
                "to_name": {
                  "type": "string"
                },
                "missing_columns": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Columns of the original source not found in the new one"
                },
                "type_changes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "from": {
                        "type": "string"
                      },
                      "to": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "broken": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "visualization",
                    "filter",
                    "widget"
                  ]
                },
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "source": {
                  "type": "string",
                  "description": "Original source ID"
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Columns it uses that the new source does not have"
                }
              }
            }
          }
        }
      },
      "LineageRef": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "LineageItem": {
        "type": "object",
        "description": "An item that depends on the one asked for",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "direct": {
            "type": "boolean",
            "description": "It depends on the item itself, not on one of its derived sources"
          },
          "source": {
            "description": "The source it is built on (models, visualizations and simple notices)",
            "allOf": [
              {
                "$ref": "#/components/schemas/LineageRef"
              }
            ]
          },
          "from": {
            "description": "For the sources made with the predictions of a model, the source the model was applied to",
            "allOf": [
              {
                "$ref": "#/components/schemas/LineageRef"
              }
            ]
          },
          "via": {
            "type": "array",
            "description": "For dashboards, what they use",
            "items": {
              "type": "string",
              "enum": [
                "visualization",
                "model",
                "source"
              ]
            }
          },
          "type": {
            "type": "string",
            "description": "Type of chart, of model or of simple notice"
          },
          "archived": {
            "type": "boolean",
            "description": "For sources, archived (it is no longer updated)"
          }
        }
      },
      "LineageGroup": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer",
            "description": "How many there are"
          },
          "direct": {
            "type": "integer",
            "description": "How many depend on the item itself"
          },
          "more": {
            "type": "integer",
            "description": "How many are not listed"
          },
          "partial": {
            "type": "boolean",
            "description": "A safety limit cut the count, which may be approximate"
          },
          "hidden": {
            "type": "boolean",
            "description": "The user of the token cannot read these items; only their count is given"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineageItem"
            }
          }
        }
      },
      "LineageDerivedNode": {
        "type": "object",
        "description": "A derived source and the sources derived from it",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "how": {
            "type": "string",
            "enum": [
              "filter",
              "join",
              "merge",
              "extend",
              "aggregate",
              "model",
              ""
            ]
          },
          "model": {
            "description": "For predictions, the model used",
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/LineageRef"
              }
            ]
          },
          "with": {
            "description": "For joins and merges, the other source it was made from",
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/LineageRef"
              }
            ]
          },
          "alsoWith": {
            "type": "array",
            "description": "Only for a source made from more than two sources, the rest of them after `with`",
            "items": {
              "$ref": "#/components/schemas/LineageRef"
            }
          },
          "archived": {
            "type": "boolean",
            "description": "Archived (it is no longer updated)"
          },
          "depth": {
            "type": "integer",
            "description": "1 for a source made from the item itself"
          },
          "more": {
            "type": "integer",
            "description": "Derived sources below it that are not listed"
          },
          "children": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineageDerivedNode"
            }
          }
        }
      },
      "SourceLineage": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "source"
            ]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "derived": {
            "type": "object",
            "properties": {
              "count": {
                "type": "integer"
              },
              "direct": {
                "type": "integer"
              },
              "more": {
                "type": "integer"
              },
              "deeper": {
                "type": "integer",
                "description": "Derived sources one level beyond the depth limit (not followed)"
              },
              "partial": {
                "type": "boolean"
              },
              "hidden": {
                "type": "boolean"
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LineageDerivedNode"
                }
              }
            }
          },
          "models": {
            "$ref": "#/components/schemas/LineageGroup"
          },
          "visualizations": {
            "$ref": "#/components/schemas/LineageGroup"
          },
          "dashboards": {
            "$ref": "#/components/schemas/LineageGroup"
          },
          "alerts": {
            "$ref": "#/components/schemas/LineageGroup"
          },
          "total": {
            "type": "integer",
            "description": "Items in the map, of every kind"
          },
          "partial": {
            "type": "boolean"
          }
        }
      },
      "VisualizationLineage": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "visualization"
            ]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "dashboards": {
            "$ref": "#/components/schemas/LineageGroup"
          },
          "total": {
            "type": "integer"
          },
          "partial": {
            "type": "boolean"
          }
        }
      },
      "GenAIModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "description": "What the user asked for, in their words."
          },
          "lang": {
            "type": "string"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "plan": {
            "type": "object",
            "properties": {
              "task": {
                "type": "string",
                "enum": [
                  "category",
                  "yes_no",
                  "number",
                  "label"
                ]
              },
              "question": {
                "type": "string",
                "description": "What is answered for each row."
              },
              "guidance": {
                "type": "string"
              },
              "answers": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The allowed answers (category: 2 to 30; yes_no: two, the affirmative first)."
              },
              "number_range": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "min": {
                    "type": "number",
                    "nullable": true
                  },
                  "max": {
                    "type": "number",
                    "nullable": true
                  },
                  "decimals": {
                    "type": "integer"
                  }
                }
              },
              "base": {
                "type": "string",
                "description": "The source with one row per case."
              },
              "sources": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "inputs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "source",
                    "field"
                  ],
                  "properties": {
                    "source": {
                      "type": "string",
                      "description": "Identifier (or name) of the source."
                    },
                    "field": {
                      "type": "string",
                      "description": "Exact name of the field."
                    }
                  }
                },
                "description": "The only fields sent to the model."
              },
              "joins": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "source": {
                      "type": "string"
                    },
                    "field": {
                      "type": "string"
                    },
                    "to_source": {
                      "type": "string"
                    },
                    "to_field": {
                      "type": "string"
                    }
                  }
                }
              },
              "past_answers": {
                "nullable": true,
                "description": "The field of the base source with known answers (never an input).",
                "type": "object",
                "required": [
                  "source",
                  "field"
                ],
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "Identifier (or name) of the source."
                  },
                  "field": {
                    "type": "string",
                    "description": "Exact name of the field."
                  }
                }
              },
              "target_name": {
                "type": "string",
                "description": "Column of the prediction in the output source (with _reason and _status)."
              },
              "summary": {
                "type": "string"
              },
              "questions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "plan_version": {
            "type": "integer"
          },
          "plan_ready": {
            "type": "boolean"
          },
          "plan_problems": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "NO_PLAN",
                "NO_QUESTION",
                "NO_INPUTS",
                "FEW_ANSWERS"
              ]
            }
          },
          "check": {
            "type": "object",
            "nullable": true,
            "description": "The last check: status (running, done, stopped, failed), metrics (hit_rate against baseline.hit_rate of the most frequent answer, or mae and mape against the mean; per_class), cases (up to 10, misses first, with the reason), spent_eur, stop_reason or error, and stale when the plan changed afterwards."
          },
          "run": {
            "type": "object",
            "nullable": true,
            "description": "The last apply: status (running, writing, done, stopped, failed), stop_reason (EUR_CAP, ROWS_CAP, MODEL_UNAVAILABLE or a spending limit such as SPEND_LIMIT), rows_ok, rows_cached (answered before, not paid again), rows_known, rows_invalid, rows_no_answer, rows_pending, spent_eur, cap_eur, cap_rows, output_source."
          },
          "output_source": {
            "type": "string",
            "nullable": true,
            "description": "The source with the predictions: the columns of the base source, the inputs of other sources, the prediction, its reason and its status."
          },
          "created": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          }
        }
      },
      "GenAIEstimate": {
        "type": "object",
        "properties": {
          "model": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "local": {
                "type": "boolean"
              },
              "own_key": {
                "type": "boolean"
              },
              "cost_free": {
                "type": "boolean"
              }
            }
          },
          "rows": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "read": {
                "type": "integer"
              },
              "labelled": {
                "type": "integer"
              },
              "to_predict": {
                "type": "integer"
              },
              "partial_read": {
                "type": "boolean"
              }
            }
          },
          "check": {
            "type": "object",
            "properties": {
              "available": {
                "type": "boolean"
              },
              "rows": {
                "type": "integer"
              },
              "examples": {
                "type": "integer"
              },
              "calls": {
                "type": "integer"
              },
              "tokens_in": {
                "type": "integer"
              },
              "tokens_out": {
                "type": "integer"
              },
              "eur": {
                "type": "number"
              },
              "payable_eur": {
                "type": "number"
              },
              "estimate_id": {
                "type": "string"
              }
            }
          },
          "apply": {
            "type": "object",
            "properties": {
              "rows": {
                "type": "integer"
              },
              "only_missing": {
                "type": "boolean"
              },
              "calls": {
                "type": "integer"
              },
              "tokens_in": {
                "type": "integer"
              },
              "tokens_out": {
                "type": "integer"
              },
              "eur": {
                "type": "number",
                "description": "Cost of every row."
              },
              "cap_eur": {
                "type": "number"
              },
              "cap_rows": {
                "type": "integer"
              },
              "rows_within_cap": {
                "type": "integer"
              },
              "over_cap": {
                "type": "boolean"
              },
              "payable_eur": {
                "type": "number",
                "description": "At most what the run may spend with its limits."
              },
              "estimate_id": {
                "type": "string"
              }
            }
          },
          "suggestion": {
            "type": "object",
            "nullable": true,
            "description": "When a full run goes over the limit: over_cap, or classical_model (model_type, source, target, inputs, inputs_of_other_sources) when a classical model with the same target would cost nothing per row."
          },
          "cached_rows_note": {
            "type": "string"
          }
        }
      },
      "MetricDefinition": {
        "type": "object",
        "description": "The calculation of a metric: a question of the engine of «Habla con tus datos», with the fields by name.",
        "properties": {
          "metric": {
            "type": "string",
            "enum": [
              "count",
              "count_distinct",
              "sum",
              "avg",
              "min",
              "max",
              "median"
            ]
          },
          "field": {
            "type": "string",
            "description": "Measured field (empty to count records)"
          },
          "filters": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "op": {
                  "type": "string",
                  "enum": [
                    "eq",
                    "not_eq",
                    "in",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "cn",
                    "cni",
                    "sw",
                    "swi",
                    "ew",
                    "ewi",
                    "null"
                  ]
                },
                "value": {}
              }
            }
          },
          "match": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ]
          },
          "where": {
            "$ref": "#/components/schemas/QueryTree"
          },
          "group_by": {
            "type": "string",
            "description": "Grouping by default"
          }
        }
      },
      "MetricInput": {
        "type": "object",
        "required": [
          "name",
          "source"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "definition": {
            "$ref": "#/components/schemas/MetricDefinition"
          },
          "date_field": {
            "type": "string"
          },
          "period": {
            "type": "string",
            "enum": [
              "day",
              "week",
              "month",
              "quarter",
              "year"
            ]
          },
          "bucket": {
            "type": "string",
            "enum": [
              "hour",
              "day",
              "week",
              "month"
            ]
          },
          "unit": {
            "type": "string",
            "maxLength": 20
          },
          "format": {
            "type": "string",
            "enum": [
              "number",
              "integer",
              "currency",
              "percent"
            ]
          },
          "decimals": {
            "type": "integer"
          },
          "direction": {
            "type": "string",
            "enum": [
              "up",
              "down",
              "none"
            ],
            "description": "up: more is better; down: more is worse"
          },
          "synonyms": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 20
          },
          "dimensions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 3
          },
          "forecast": {
            "type": "string",
            "description": "Model of «Predict the future»"
          },
          "sensitivity": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high"
            ]
          },
          "owner": {
            "type": "string"
          }
        }
      },
      "Metric": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "owner": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "format": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "definition": {
            "$ref": "#/components/schemas/MetricDefinition"
          },
          "definition_text": {
            "type": "string"
          },
          "date_field": {
            "type": "string"
          },
          "period": {
            "type": "string"
          },
          "bucket": {
            "type": "string"
          },
          "direction": {
            "type": "string"
          },
          "synonyms": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "dimensions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sensitivity": {
            "type": "string"
          },
          "version": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          },
          "updated_by": {
            "type": "string"
          },
          "snapshot": {
            "type": "object",
            "nullable": true
          },
          "followed": {
            "type": "boolean"
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MetricList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Metric"
            }
          },
          "can": {
            "type": "object"
          }
        }
      },
      "MetricValue": {
        "type": "object",
        "description": "Computed by AIR-Core over all the rows.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "value": {
            "type": "number",
            "nullable": true
          },
          "previous": {
            "type": "number",
            "nullable": true
          },
          "change": {
            "type": "number",
            "nullable": true
          },
          "change_pct": {
            "type": "number",
            "nullable": true
          },
          "window": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "current",
                  "latest"
                ]
              },
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              },
              "prev_from": {
                "type": "string"
              },
              "prev_to": {
                "type": "string"
              }
            }
          },
          "series": {
            "type": "object"
          },
          "spark": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "trend": {
            "type": "object"
          },
          "season": {
            "type": "integer"
          },
          "anomalies": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "number"
                },
                "expected": {
                  "type": "number"
                },
                "lower": {
                  "type": "number"
                },
                "upper": {
                  "type": "number"
                },
                "score": {
                  "type": "number"
                },
                "direction": {
                  "type": "string"
                }
              }
            }
          },
          "bands": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "forecast": {
            "type": "object",
            "nullable": true
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "period": {
                  "type": "string"
                },
                "period_key": {
                  "type": "string"
                },
                "target": {
                  "type": "number"
                },
                "value": {
                  "type": "number"
                },
                "progress": {
                  "type": "number"
                },
                "projection": {
                  "type": "number"
                },
                "method": {
                  "type": "string",
                  "enum": [
                    "forecast",
                    "pace",
                    "current",
                    "final",
                    "none"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "reached",
                    "on_track",
                    "at_risk",
                    "off_track",
                    "missed",
                    "pending",
                    "no_data"
                  ]
                }
              }
            }
          },
          "why": {
            "$ref": "#/components/schemas/MetricExplanation"
          },
          "error": {
            "type": "object",
            "nullable": true
          }
        }
      },
      "MetricExplanation": {
        "type": "object",
        "properties": {
          "computed_by": {
            "type": "string"
          },
          "method": {
            "type": "string",
            "enum": [
              "sum",
              "average",
              "largest"
            ]
          },
          "dimension": {
            "type": "string"
          },
          "total": {
            "type": "object"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {},
                "current": {
                  "type": "number"
                },
                "previous": {
                  "type": "number"
                },
                "change": {
                  "type": "number"
                },
                "share": {
                  "type": "number",
                  "nullable": true
                },
                "mix": {
                  "type": "number"
                },
                "rate": {
                  "type": "number"
                }
              }
            }
          },
          "top": {
            "type": "object",
            "nullable": true
          },
          "rest": {
            "type": "number"
          },
          "others": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "window": {
            "type": "object"
          },
          "reference": {
            "type": "object"
          }
        }
      },
      "MetricBriefing": {
        "type": "object",
        "properties": {
          "generated": {
            "type": "integer"
          },
          "timezone": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricValue"
            }
          },
          "attention": {
            "type": "integer"
          },
          "narrative": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "by": {
                "type": "string",
                "enum": [
                  "ai",
                  "template"
                ]
              }
            }
          }
        }
      },
      "ModelLineage": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "model"
            ]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "sources": {
            "$ref": "#/components/schemas/LineageGroup"
          },
          "dashboards": {
            "$ref": "#/components/schemas/LineageGroup"
          },
          "total": {
            "type": "integer"
          },
          "partial": {
            "type": "boolean"
          }
        }
      },
      "ScimUser": {
        "type": "object",
        "required": [
          "userName"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "id": {
            "type": "string",
            "readOnly": true
          },
          "externalId": {
            "type": "string"
          },
          "userName": {
            "type": "string",
            "description": "Usually the work email"
          },
          "displayName": {
            "type": "string"
          },
          "name": {
            "type": "object",
            "properties": {
              "givenName": {
                "type": "string"
              },
              "familyName": {
                "type": "string"
              },
              "formatted": {
                "type": "string"
              }
            }
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "primary": {
                  "type": "boolean"
                }
              }
            }
          },
          "active": {
            "type": "boolean"
          },
          "groups": {
            "type": "array",
            "readOnly": true,
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string"
                },
                "display": {
                  "type": "string"
                }
              }
            }
          },
          "meta": {
            "$ref": "#/components/schemas/ScimMeta"
          }
        }
      },
      "ScimGroup": {
        "type": "object",
        "required": [
          "displayName"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "id": {
            "type": "string",
            "readOnly": true
          },
          "externalId": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string"
                },
                "display": {
                  "type": "string"
                }
              }
            }
          },
          "meta": {
            "$ref": "#/components/schemas/ScimMeta"
          }
        }
      },
      "ScimMeta": {
        "type": "object",
        "readOnly": true,
        "properties": {
          "resourceType": {
            "type": "string"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "lastModified": {
            "type": "string",
            "format": "date-time"
          },
          "location": {
            "type": "string"
          },
          "version": {
            "type": "string",
            "example": "W/\"3\""
          }
        }
      },
      "ScimPatchOp": {
        "type": "object",
        "required": [
          "Operations"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "Operations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "op"
              ],
              "properties": {
                "op": {
                  "type": "string",
                  "enum": [
                    "add",
                    "replace",
                    "remove",
                    "Add",
                    "Replace",
                    "Remove"
                  ]
                },
                "path": {
                  "type": "string"
                },
                "value": {}
              }
            }
          }
        }
      },
      "ScimListResponse": {
        "type": "object",
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "totalResults": {
            "type": "integer"
          },
          "startIndex": {
            "type": "integer"
          },
          "itemsPerPage": {
            "type": "integer"
          },
          "Resources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "ScimError": {
        "type": "object",
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string"
          },
          "scimType": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "SqlLimits": {
        "type": "object",
        "description": "The caps of a SQL query by plan of the organization (free, standard, pro, gold; custom as gold)",
        "properties": {
          "max_sources": {
            "type": "integer",
            "description": "Tables a query may read"
          },
          "max_rows": {
            "type": "integer",
            "description": "Rows read from the sources, all tables together"
          },
          "max_bytes": {
            "type": "integer",
            "description": "Size of what is read (texts by length, other values 8 bytes)"
          },
          "max_columns": {
            "type": "integer",
            "description": "Columns read, all tables together"
          },
          "max_seconds": {
            "type": "number",
            "description": "Seconds for reading and running"
          },
          "max_page_rows": {
            "type": "integer",
            "description": "Rows of one page of results"
          },
          "max_result_rows": {
            "type": "integer",
            "description": "Rows of a whole result (CSV)"
          }
        }
      },
      "SqlTables": {
        "type": "object",
        "properties": {
          "tables": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "The table name in SQL"
                },
                "source": {
                  "type": "string",
                  "description": "Identifier of the data source"
                },
                "source_name": {
                  "type": "string"
                },
                "source_type": {
                  "type": "string"
                },
                "rows": {
                  "type": "integer",
                  "description": "Rows of the source"
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "description": "The column name in SQL (the field name; an empty one is column_N, a repeated one gets _2…)"
                      },
                      "sql": {
                        "type": "string",
                        "description": "How a query writes it (in double quotes when it has spaces, accents or is a keyword)"
                      },
                      "field": {
                        "type": "string",
                        "description": "The name of the field of the source"
                      },
                      "type": {
                        "type": "string",
                        "description": "numeric, nominal, date, logic or text"
                      }
                    }
                  }
                }
              }
            }
          },
          "limits": {
            "$ref": "#/components/schemas/SqlLimits"
          },
          "functions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The functions a query may call"
          }
        }
      },
      "SqlQuery": {
        "type": "object",
        "required": [
          "sql"
        ],
        "properties": {
          "sql": {
            "type": "string",
            "description": "The query (at most 20000 characters)",
            "example": "SELECT c.region, SUM(v.importe) AS total FROM ventas v JOIN ciudades c ON c.ciudad = v.ciudad GROUP BY c.region"
          },
          "sources": {
            "description": "Optional table names of your own for sources of this workspace: {alias: sourceId} or [{alias, source}] (letters, digits and _, not a keyword, at most 20)",
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "alias": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            ]
          },
          "offset": {
            "type": "integer",
            "description": "Rows of the result to skip (default 0)"
          },
          "limit": {
            "type": "integer",
            "description": "Rows of the page (default 100, at most max_page_rows of the plan)"
          },
          "format": {
            "type": "string",
            "enum": [
              "json",
              "csv"
            ],
            "description": "csv: the whole result as a CSV file"
          }
        }
      },
      "SqlResult": {
        "type": "object",
        "properties": {
          "columns": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "description": "numeric, nominal, date, logic, text or unknown"
                },
                "source": {
                  "type": "string",
                  "nullable": true,
                  "description": "The source it comes from when it is a column of a table as it is"
                },
                "field": {
                  "type": "string",
                  "nullable": true,
                  "description": "The field of that source"
                }
              }
            }
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {}
            },
            "description": "The rows of the page, values in the order of the columns (logic columns as true/false, blobs as hexadecimal)"
          },
          "offset": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "more": {
            "type": "boolean",
            "description": "There are rows after this page"
          },
          "cut_values": {
            "type": "integer",
            "description": "Texts of this page longer than 32 KB that were cut"
          },
          "read": {
            "type": "object",
            "description": "What was read from the sources",
            "properties": {
              "tables": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "table": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "rows_read": {
                      "type": "integer"
                    },
                    "rows_total": {
                      "type": "integer"
                    },
                    "columns": {
                      "type": "integer"
                    },
                    "partial": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "rows_read": {
                "type": "integer"
              },
              "bytes_read": {
                "type": "integer"
              },
              "partial": {
                "type": "boolean",
                "description": "A cap of the plan stopped the reading of a table: counts and sums only cover the rows read"
              },
              "partial_reason": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "rows",
                  "bytes",
                  null
                ]
              }
            }
          },
          "ms": {
            "type": "integer",
            "description": "Milliseconds to read and run"
          },
          "limits": {
            "$ref": "#/components/schemas/SqlLimits"
          }
        }
      },
      "SqlError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string",
            "description": "In English; for SQL_ERROR, SQL_SYNTAX and SQL_UNKNOWN_* the message of SQLite"
          },
          "position": {
            "type": "object",
            "description": "Where in the text of the query, when known",
            "properties": {
              "line": {
                "type": "integer"
              },
              "column": {
                "type": "integer"
              }
            }
          },
          "details": {
            "type": "object",
            "description": "The cap or the name concerned (max, max_seconds, function, alias…)"
          }
        }
      },
      "SqlSaveSource": {
        "type": "object",
        "required": [
          "sql",
          "name"
        ],
        "properties": {
          "sql": {
            "type": "string",
            "description": "The query (see SqlQuery)"
          },
          "sources": {
            "description": "Optional table names of your own for sources of this workspace, as in SqlQuery; they are kept with the saved query",
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "alias": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            ]
          },
          "name": {
            "type": "string",
            "description": "Name of the new source (1 to 120 characters)"
          },
          "description": {
            "type": "string",
            "description": "At most 300 characters"
          }
        }
      },
      "QualityRule": {
        "description": "A data quality rule of a source. Kinds and their params: not_empty, unique and not_future {tolerance_pct}; range {min, max, tolerance_pct} (numbers, or dates as ISO 8601 for a date field); allowed_values {values (1 to 200), tolerance_pct}; pattern {mode: preset (value: email, phone, url, postal_code_es, dni_nie, cif, iban, ip, uuid), regex, starts_with, ends_with or contains, value, ignore_case, tolerance_pct}; row_count {min, max}; freshness {max_age_minutes (5 to 525600)}. tolerance_pct (0 to 100): the share of the rows that may break the rule while it still passes. Empty values (null, and the empty text) only break not_empty.",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "not_empty",
              "unique",
              "range",
              "allowed_values",
              "pattern",
              "not_future",
              "row_count",
              "freshness"
            ]
          },
          "field": {
            "type": "string",
            "description": "The field, by name (rules on a column only)"
          },
          "index": {
            "type": "integer",
            "description": "Its position now (-1: the field is gone). In a change, the field can be given by index instead of name"
          },
          "field_type": {
            "type": "string"
          },
          "missing": {
            "type": "boolean"
          },
          "params": {
            "type": "object"
          },
          "severity": {
            "type": "string",
            "enum": [
              "warning",
              "error"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "origin": {
            "type": "string",
            "enum": [
              "person",
              "suggestion"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Only in suggestions: why AIR-Core suggests it (catalog_values, catalog_range, catalog_identifier, catalog_percentage, categories, no_empty_values, name_pattern, past_dates, never_empty, automatic_updates)"
          },
          "withheld_for_ai": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "For an AI: the parameters left out"
          }
        }
      },
      "QualityRules": {
        "properties": {
          "source": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "supported": {
            "type": "boolean",
            "description": "false for external and real-time sources"
          },
          "can_edit": {
            "type": "boolean"
          },
          "version": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          },
          "updated_by": {
            "type": "string"
          },
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QualityRule"
            }
          },
          "suggestions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QualityRule"
            }
          },
          "kinds": {
            "type": "array",
            "items": {
              "properties": {
                "kind": {
                  "type": "string"
                },
                "field_types": {
                  "type": "array",
                  "nullable": true,
                  "items": {
                    "type": "string"
                  }
                },
                "params": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "pattern_presets": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "limits": {
            "properties": {
              "rules": {
                "type": "integer"
              },
              "values": {
                "type": "integer"
              },
              "sample": {
                "type": "integer"
              }
            }
          }
        }
      },
      "QualityRulesChange": {
        "properties": {
          "rules": {
            "type": "array",
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/QualityRule"
            },
            "description": "The whole list: it replaces the current one"
          },
          "check": {
            "type": "boolean",
            "description": "Check them now (default true)"
          },
          "alert": {
            "description": "The quality alert of the source: on or off, and the score under which it also fires (0: only when a rule breaks)",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "threshold": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              }
            }
          }
        }
      },
      "QualityRuleResult": {
        "properties": {
          "rule": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "severity": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "unknown"
            ]
          },
          "failing": {
            "type": "integer",
            "nullable": true,
            "description": "Rows that break it"
          },
          "total": {
            "type": "integer",
            "description": "Rows of the source"
          },
          "share": {
            "type": "number",
            "nullable": true
          },
          "estimated": {
            "type": "boolean",
            "description": "The count comes from a sample"
          },
          "sampled": {
            "type": "integer"
          },
          "examples": {
            "type": "array",
            "items": {},
            "description": "Some failing values (pattern, unique)"
          },
          "measured": {
            "type": "number",
            "description": "rows (row_count), age in ms (freshness), duplicate rows (unique)"
          },
          "error": {
            "type": "string",
            "description": "FIELD_MISSING (the rule fails), FIELD_TYPE, STORAGE_OLD, STORAGE_ERROR, PATTERN_TIMEOUT, UNSUPPORTED"
          },
          "failing_filter": {
            "type": "object",
            "nullable": true,
            "description": "The filter of the rows that break it, in the syntax of the filters of the instances (not for an AI)"
          }
        }
      },
      "QualityReport": {
        "allOf": [
          {
            "$ref": "#/components/schemas/QualityRules"
          },
          {
            "properties": {
              "checking": {
                "type": "boolean",
                "description": "A check goes on in the background"
              },
              "report": {
                "nullable": true,
                "properties": {
                  "checked_at": {
                    "type": "integer"
                  },
                  "trigger": {
                    "type": "string",
                    "enum": [
                      "update",
                      "freshness",
                      "rules",
                      "manual",
                      "api"
                    ]
                  },
                  "score": {
                    "type": "integer",
                    "nullable": true
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "warning",
                      "error",
                      "unknown"
                    ]
                  },
                  "row_count": {
                    "type": "integer"
                  },
                  "stale": {
                    "type": "boolean",
                    "description": "The data or the rules changed after this check"
                  },
                  "results": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/QualityRuleResult"
                    }
                  }
                }
              },
              "history": {
                "type": "array",
                "items": {
                  "properties": {
                    "at": {
                      "type": "integer"
                    },
                    "score": {
                      "type": "integer",
                      "nullable": true
                    },
                    "status": {
                      "type": "string"
                    },
                    "trigger": {
                      "type": "string"
                    }
                  }
                }
              },
              "alert": {
                "properties": {
                  "can_change": {
                    "type": "boolean"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "threshold": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        ]
      },
      "RecipeStep": {
        "description": "A step of a recipe. Columns are named by NAME and each step is checked against the columns there are at that point. clean: a cleaning of the spreadsheet on a column (`operation` and `args` as POST .../columns/{feature}/transform), on every row or on those of `where`; fill_empty: shorthand of clean fill_empty (`field`, `value`); filter: keeps the rows that meet `where` (a QueryTree whose `left` is a column name; SQL semantics: a comparison with an empty value is not true, not even under `not`); dedupe: removes the rows that repeat the values of `fields` ([] = all the columns), keeping the first or the last of each group; rename (`field`, `to`); drop (`fields`); reorder (`fields` go first, the rest after them in their order); retype (`field`, `type`, `date_format`; values that do not convert are left empty); compute: a new column from an `expression` written with the column names, as the calculated columns (no predict); parse_dates: dates written in words in the text column `field` («el próximo trimestre», «hace dos semanas», «15 de marzo de 2026», «Q1 2027», «next quarter»; Spanish and English, with Microsoft Recognizers-Text) as a new date column `to` (the start) and, with `end_to`, another with the last day of a range («Q1 2027»: 2027-01-01 to 2027-03-31); relative expressions are resolved against the date column `reference_field` of the row or, when it is empty or not given, the fixed date `reference_date` (YYYY-MM-DD) kept in the step, never against the moment it runs (one of them is required), so a refresh gives the same result; texts without a date leave the new cells empty and count as `emptied` in the report of the step.",
        "required": [
          "op"
        ],
        "properties": {
          "op": {
            "type": "string",
            "enum": [
              "clean",
              "fill_empty",
              "filter",
              "dedupe",
              "rename",
              "drop",
              "reorder",
              "retype",
              "compute",
              "parse_dates"
            ]
          },
          "field": {
            "type": "string",
            "description": "clean, fill_empty, rename, retype: the column"
          },
          "operation": {
            "type": "string",
            "enum": [
              "trim",
              "lower",
              "upper",
              "capitalize",
              "replace",
              "regex_replace",
              "prefix",
              "suffix",
              "fill_empty",
              "to_null",
              "round",
              "multiply",
              "add",
              "clip",
              "abs",
              "shift",
              "invert",
              "merge_values"
            ],
            "description": "clean: the cleaning (the ones of the type of the column)"
          },
          "args": {
            "type": "object",
            "additionalProperties": true,
            "description": "clean: its arguments (regex_replace: Java pattern and replacement, as the storage runs them)"
          },
          "value": {
            "description": "fill_empty: the value for the empty cells"
          },
          "where": {
            "type": "object",
            "additionalProperties": true,
            "description": "filter, clean, fill_empty: a QueryTree by column names"
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "keep": {
            "type": "string",
            "enum": [
              "first",
              "last"
            ]
          },
          "to": {
            "type": "string",
            "maxLength": 120,
            "description": "rename: the new name; parse_dates: the name of the new date column (the start)"
          },
          "type": {
            "type": "string",
            "enum": [
              "nominal",
              "text",
              "numeric",
              "date",
              "logic"
            ]
          },
          "date_format": {
            "type": "string",
            "maxLength": 80
          },
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "expression": {
            "type": "string",
            "maxLength": 1000
          },
          "end_to": {
            "type": "string",
            "maxLength": 120,
            "description": "parse_dates: the name of a new date column with the last day of a range (optional)"
          },
          "language": {
            "type": "string",
            "enum": [
              "auto",
              "es",
              "en"
            ],
            "description": "parse_dates: the language of the texts (auto: Spanish, and English when Spanish finds less)"
          },
          "reference_field": {
            "type": "string",
            "description": "parse_dates: a date column of the row relative expressions are resolved against"
          },
          "reference_date": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "parse_dates: a fixed date for the rows without a reference"
          }
        }
      },
      "RecipeColumn": {
        "properties": {
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "from": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Columns of the origin its values come from"
          },
          "date_format": {
            "type": "string",
            "description": "The format of a date column that has one (the columns of parse_dates: YYYY-MM-DD, days without time)"
          }
        }
      },
      "TextAnalysisLimits": {
        "description": "The caps of «Analizar textos» in the plan of the organization (keys text_analysis_* of the configuration of the plans; a custom plan has those of gold). -1 = no limit.",
        "properties": {
          "plan": {
            "type": "string"
          },
          "max_texts": {
            "type": "integer",
            "description": "Texts analysed in one analysis (the first ones of the source; the other rows keep their columns empty)"
          },
          "per_month": {
            "type": "integer",
            "description": "Analyses started in a month (creations and «Volver a analizar»; automatic re-applications do not count)"
          },
          "auto_refresh": {
            "type": "boolean",
            "description": "Whether an analysis is applied again by itself when its source updates"
          },
          "entities": {
            "type": "boolean"
          },
          "topics_over_time": {
            "type": "boolean"
          },
          "max_topics": {
            "type": "integer"
          },
          "classifiers": {
            "type": "boolean",
            "description": "Own text classifiers from the organization's labels"
          },
          "hybrid_sample": {
            "type": "integer",
            "description": "Texts generative AI labels in one run"
          }
        }
      },
      "TextAnalysisInfo": {
        "properties": {
          "available": {
            "type": "boolean",
            "description": "Whether the AI module of this installation analyses texts"
          },
          "capabilities": {
            "type": "object",
            "properties": {
              "annotate": {
                "type": "boolean"
              },
              "tasks": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "languages": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "summarize": {
                "type": "boolean"
              },
              "topics": {
                "type": "boolean"
              }
            }
          },
          "limits": {
            "$ref": "#/components/schemas/TextAnalysisLimits"
          },
          "usage": {
            "type": "object",
            "properties": {
              "month": {
                "type": "string",
                "example": "2026-11"
              },
              "analyses": {
                "type": "integer"
              },
              "texts": {
                "type": "integer"
              },
              "labelled": {
                "type": "integer",
                "description": "Texts labelled by generative AI"
              }
            }
          },
          "labels": {
            "type": "object",
            "properties": {
              "available": {
                "type": "boolean"
              },
              "code": {
                "type": "string",
                "description": "Why not: GENAI_PLAN_REQUIRED, TEXT_ANALYSIS_PLAN or ASSISTANT_DISABLED"
              }
            }
          },
          "permissions": {
            "type": "object"
          }
        }
      },
      "TextAnalysisOverview": {
        "description": "The «Resumen del análisis» of the last run",
        "properties": {
          "at": {
            "type": "integer"
          },
          "texts": {
            "type": "object",
            "properties": {
              "rows": {
                "type": "integer"
              },
              "analysed": {
                "type": "integer"
              },
              "empty": {
                "type": "integer"
              },
              "skipped": {
                "type": "integer",
                "description": "Over the cap of the plan"
              },
              "cut": {
                "type": "integer"
              }
            }
          },
          "languages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "n": {
                  "type": "integer"
                }
              }
            }
          },
          "sentiment": {
            "type": "object",
            "nullable": true,
            "properties": {
              "positive": {
                "type": "integer"
              },
              "neutral": {
                "type": "integer"
              },
              "negative": {
                "type": "integer"
              },
              "mean": {
                "type": "number"
              }
            }
          },
          "over_time": {
            "type": "object",
            "nullable": true,
            "properties": {
              "unit": {
                "type": "string",
                "enum": [
                  "day",
                  "week",
                  "month"
                ]
              },
              "periods": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "period": {
                      "type": "string"
                    },
                    "n": {
                      "type": "integer"
                    },
                    "positive": {
                      "type": "integer"
                    },
                    "neutral": {
                      "type": "integer"
                    },
                    "negative": {
                      "type": "integer"
                    },
                    "mean": {
                      "type": "number",
                      "nullable": true
                    },
                    "topics": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      },
                      "description": "Texts of each topic (plans with topics over time)"
                    }
                  }
                }
              }
            }
          },
          "keywords": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "n": {
                  "type": "integer"
                },
                "positive": {
                  "type": "integer"
                },
                "negative": {
                  "type": "integer"
                }
              }
            }
          },
          "entities": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "ORG",
                    "LOC",
                    "MISC"
                  ]
                },
                "n": {
                  "type": "integer"
                }
              }
            }
          },
          "people": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "n": {
                  "type": "integer"
                }
              }
            },
            "description": "Names of people (personal data)"
          },
          "topics": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "label": {
                  "type": "string"
                },
                "words": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "n": {
                  "type": "integer"
                },
                "share": {
                  "type": "number"
                },
                "examples": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "classifiers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "column": {
                  "type": "string"
                },
                "kind": {
                  "type": "string"
                },
                "labels": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      },
                      "n": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "examples": {
            "type": "object",
            "description": "Up to 3 texts of each sentiment: {positive, neutral, negative: [{row, text, score}]}"
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "analyzers": {
            "type": "object",
            "description": "The analyzers of the AI module and their versions"
          }
        }
      },
      "TextAnalysis": {
        "properties": {
          "source": {
            "type": "object"
          },
          "origin": {
            "type": "object"
          },
          "column": {
            "type": "string"
          },
          "tasks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "language": {
            "type": "string"
          },
          "keywords_top": {
            "type": "integer"
          },
          "date_column": {
            "type": "string"
          },
          "topics": {
            "type": "object",
            "nullable": true,
            "description": "{k (0 automatic), method, model: {id, name}}"
          },
          "classifiers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "model": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "column": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "emotions",
                    "labels"
                  ]
                },
                "missing": {
                  "type": "boolean"
                }
              }
            }
          },
          "outputs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "output": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                }
              }
            }
          },
          "analysis_version": {
            "type": "integer"
          },
          "last_report": {
            "type": "object",
            "nullable": true
          },
          "overview": {
            "$ref": "#/components/schemas/TextAnalysisOverview"
          },
          "pending": {
            "type": "boolean"
          },
          "running": {
            "type": "boolean"
          },
          "stale": {
            "type": "boolean"
          },
          "limits": {
            "$ref": "#/components/schemas/TextAnalysisLimits"
          },
          "usage": {
            "type": "object"
          }
        }
      },
      "TextAnalysisOf": {
        "properties": {
          "analysis": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TextAnalysis"
              }
            ],
            "nullable": true
          },
          "can_edit": {
            "type": "boolean"
          },
          "can_create": {
            "type": "boolean"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "text": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "TextAnalysisPreview": {
        "properties": {
          "origin": {
            "type": "object"
          },
          "column": {
            "type": "string"
          },
          "tasks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "language": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "language": {
                  "type": "object",
                  "nullable": true
                },
                "sentiment": {
                  "type": "object",
                  "nullable": true
                },
                "keywords": {
                  "type": "array",
                  "nullable": true,
                  "items": {
                    "type": "string"
                  }
                },
                "entities": {
                  "type": "array",
                  "nullable": true,
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "analyzers": {
            "type": "object"
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "plan": {
            "type": "object",
            "properties": {
              "texts": {
                "type": "integer"
              },
              "max_texts": {
                "type": "integer"
              },
              "over_cap": {
                "type": "boolean"
              },
              "entities": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "TopicsModel": {
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "text_column": {
            "type": "string"
          },
          "date_column": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "method": {
            "type": "string"
          },
          "k": {
            "type": "integer"
          },
          "topics": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "name": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "words": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "text": {
                        "type": "string"
                      },
                      "weight": {
                        "type": "number"
                      }
                    }
                  }
                },
                "size": {
                  "type": "integer"
                },
                "share": {
                  "type": "number"
                }
              }
            }
          },
          "prevalence": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "period": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "shares": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  }
                },
                "n": {
                  "type": "integer"
                }
              }
            }
          },
          "period": {
            "type": "string"
          },
          "can_edit": {
            "type": "boolean"
          }
        }
      },
      "Recipe": {
        "properties": {
          "source": {
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "origin": {
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "missing": {
                "type": "boolean"
              },
              "columns": {
                "type": "array",
                "items": {
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecipeStep"
            }
          },
          "columns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecipeColumn"
            }
          },
          "check": {
            "properties": {
              "ok": {
                "type": "boolean"
              },
              "error": {
                "$ref": "#/components/schemas/RecipeStepError"
              }
            }
          },
          "recipe_version": {
            "type": "integer"
          },
          "updated_at": {
            "type": "integer"
          },
          "updated_by": {
            "type": "string"
          },
          "last_report": {
            "nullable": true,
            "properties": {
              "at": {
                "type": "integer"
              },
              "status": {
                "type": "string",
                "enum": [
                  "ok",
                  "failed"
                ]
              },
              "recipe_version": {
                "type": "integer"
              },
              "rows_read": {
                "type": "integer"
              },
              "rows_written": {
                "type": "integer"
              },
              "steps": {
                "type": "array",
                "items": {
                  "properties": {
                    "op": {
                      "type": "string"
                    },
                    "rows_in": {
                      "type": "integer"
                    },
                    "rows_out": {
                      "type": "integer"
                    },
                    "changed": {
                      "type": "integer"
                    },
                    "emptied": {
                      "type": "integer"
                    }
                  }
                }
              },
              "error": {
                "$ref": "#/components/schemas/RecipeStepError"
              }
            }
          },
          "pending": {
            "type": "boolean",
            "description": "A recomputation is asked for and not done yet"
          },
          "running": {
            "type": "boolean"
          },
          "can_edit": {
            "type": "boolean"
          }
        }
      },
      "RecipeStepError": {
        "nullable": true,
        "properties": {
          "step": {
            "type": "integer",
            "description": "Position of the step, from 0 (-1: not about a step)"
          },
          "op": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "RECIPE_COLUMN_MISSING, RECIPE_COLUMN_EXISTS, RECIPE_STEP_TYPE, RECIPE_STEP_INVALID, RECIPE_EXPRESSION_INVALID, RECIPE_REGEX_TIMEOUT, RECIPE_TOO_LARGE, ORIGIN_MISSING..."
          },
          "column": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "RecipePreview": {
        "properties": {
          "origin": {
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "rows": {
                "type": "integer"
              }
            }
          },
          "sample": {
            "properties": {
              "rows": {
                "type": "integer"
              },
              "filtered": {
                "type": "boolean"
              }
            }
          },
          "columns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecipeColumn"
            }
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {}
            }
          },
          "steps": {
            "type": "array",
            "items": {
              "properties": {
                "index": {
                  "type": "integer"
                },
                "op": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "ok": {
                  "type": "boolean"
                },
                "rows_in": {
                  "type": "integer"
                },
                "rows_out": {
                  "type": "integer"
                },
                "changed": {
                  "type": "integer"
                },
                "emptied": {
                  "type": "integer"
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RecipeColumn"
                  }
                },
                "rows": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {}
                  }
                }
              }
            }
          },
          "error": {
            "$ref": "#/components/schemas/RecipeStepError"
          },
          "output": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecipeColumn"
            }
          }
        }
      },
      "ModelMonitoringSettings": {
        "properties": {
          "psi_warning": {
            "type": "number",
            "description": "PSI from which a column is «watch» (default 0.10; above 0, at most 5, lower than psi_alert)"
          },
          "psi_alert": {
            "type": "number",
            "description": "PSI from which a column is «alert» (default 0.25)"
          },
          "metric_warning": {
            "type": "number",
            "description": "Fall of the main metric (accuracy, F1 or R², in units: 0.05 = 5 points) from which the quality is «watch» (default 0.05; above 0, at most 1)"
          },
          "metric_alert": {
            "type": "number",
            "description": "Fall of the main metric from which the quality is «alert» (default 0.10)"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ids of the sources the model is applied to that are watched besides the training source (see candidates; at most 20)"
          },
          "include_dates": {
            "type": "boolean",
            "description": "Whether the date columns count in the status (default false: they move forward with every new row)"
          },
          "training": {
            "type": "boolean",
            "description": "Whether the training source is watched (default true)"
          }
        }
      },
      "ModelMonitoringChange": {
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "settings": {
            "$ref": "#/components/schemas/ModelMonitoringSettings"
          },
          "alert": {
            "properties": {
              "enabled": {
                "type": "boolean"
              }
            }
          },
          "check": {
            "type": "boolean",
            "description": "true: run it now"
          }
        }
      },
      "ModelMonitoringColumn": {
        "properties": {
          "name": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "input",
              "target"
            ]
          },
          "type": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "bins",
              "categories"
            ]
          },
          "field": {
            "type": "string",
            "description": "The column of the source compared (its name there)"
          },
          "psi": {
            "type": "number",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "stable",
              "watch",
              "alert",
              "unknown"
            ]
          },
          "counts": {
            "type": "boolean",
            "description": "Whether it counts in the status"
          },
          "edges": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Edges of the bins (dates in ms)"
          },
          "values": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "reference": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Shares of the rows of each bucket in the training data"
          },
          "current": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Shares of the rows of each bucket now"
          },
          "rows": {
            "type": "integer"
          },
          "problem": {
            "type": "string",
            "enum": [
              "missing",
              "type",
              "storage"
            ]
          }
        }
      },
      "ModelMonitoringRun": {
        "properties": {
          "at": {
            "type": "integer"
          },
          "trigger": {
            "type": "string",
            "enum": [
              "update",
              "first",
              "manual",
              "api",
              "settings"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "stable",
              "watch",
              "alert",
              "unknown"
            ]
          },
          "reference": {
            "properties": {
              "kind": {
                "type": "string"
              },
              "captured_at": {
                "type": "integer"
              }
            }
          },
          "drift": {
            "properties": {
              "status": {
                "type": "string"
              },
              "max_psi": {
                "type": "number",
                "nullable": true
              },
              "sources": {
                "type": "array",
                "items": {
                  "properties": {
                    "source": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "training",
                        "applied"
                      ]
                    },
                    "rows": {
                      "type": "integer"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string"
                    },
                    "max_psi": {
                      "type": "number",
                      "nullable": true
                    },
                    "columns": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ModelMonitoringColumn"
                      }
                    },
                    "error": {
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "quality": {
            "properties": {
              "status": {
                "type": "string"
              },
              "metric": {
                "type": "string",
                "enum": [
                  "accuracy",
                  "f1_macro",
                  "r2"
                ]
              },
              "training": {
                "type": "number"
              },
              "current": {
                "type": "number"
              },
              "drop": {
                "type": "number"
              },
              "rows": {
                "type": "integer"
              },
              "skipped_rows": {
                "type": "integer"
              },
              "from": {
                "type": "integer",
                "description": "The first row scored: the rows the model was trained on"
              },
              "code": {
                "type": "string",
                "description": "Why it was not measured: SCORE_UNAVAILABLE, NO_NEW_ROWS, FEW_ROWS, TRAINED_ROWS_UNKNOWN, COLUMNS_MISSING, NOT_SUPERVISED, TRAINING_NOT_WATCHED, NO_TRAINING_METRIC, SCORE_FAILED"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "settings": {
            "$ref": "#/components/schemas/ModelMonitoringSettings"
          }
        }
      },
      "ModelMonitoring": {
        "properties": {
          "model": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "supported": {
            "type": "boolean"
          },
          "enabled": {
            "type": "boolean"
          },
          "origin": {
            "type": "string",
            "description": "default (on because the model is new), person, or empty"
          },
          "on_by_default": {
            "type": "boolean"
          },
          "can_edit": {
            "type": "boolean"
          },
          "settings": {
            "$ref": "#/components/schemas/ModelMonitoringSettings"
          },
          "candidates": {
            "type": "array",
            "items": {
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "training",
                    "applied"
                  ]
                },
                "available": {
                  "type": "boolean"
                }
              }
            }
          },
          "reference": {
            "nullable": true,
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "exact",
                  "approximate"
                ]
              },
              "source": {
                "type": "string"
              },
              "source_version": {
                "type": "integer"
              },
              "rows": {
                "type": "integer"
              },
              "training_rows": {
                "type": "integer",
                "description": "-1 when not known"
              },
              "captured_at": {
                "type": "integer"
              },
              "bins": {
                "type": "string"
              },
              "columns": {
                "type": "array",
                "items": {
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "bins",
                        "categories",
                        "skipped"
                      ]
                    },
                    "edges": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    "values": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "shares": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "stable",
              "watch",
              "alert",
              "unknown",
              "pending",
              "off"
            ]
          },
          "last_run": {
            "$ref": "#/components/schemas/ModelMonitoringRun"
          },
          "runs": {
            "type": "array",
            "items": {
              "properties": {
                "id": {
                  "type": "string"
                },
                "at": {
                  "type": "integer"
                },
                "trigger": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "max_psi": {
                  "type": "number",
                  "nullable": true
                },
                "drift_status": {
                  "type": "string"
                },
                "quality_status": {
                  "type": "string"
                },
                "metric": {
                  "nullable": true,
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "value": {
                      "type": "number"
                    },
                    "training": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "stale": {
            "type": "boolean",
            "description": "A source watched changed after the last run"
          },
          "running": {
            "type": "boolean"
          },
          "score_available": {
            "type": "boolean",
            "description": "Whether the AI module scores the model on new rows (gimodeler 0.20)"
          },
          "updated": {
            "type": "integer"
          },
          "alert": {
            "properties": {
              "can_change": {
                "type": "boolean"
              },
              "enabled": {
                "type": "boolean"
              },
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        }
      },
      "ModelExperimentCandidateRequest": {
        "description": "A candidate of a comparison of methods",
        "required": [
          "method"
        ],
        "properties": {
          "method": {
            "type": "string",
            "description": "A method the AI module offers for the type (GET /api/v2/models/methods)"
          },
          "search": {
            "type": "string",
            "enum": [
              "default",
              "auto"
            ],
            "description": "default: the default settings of the method; auto: the automatic search of its settings (as hyper_search_configuration {\"auto\": true})"
          },
          "inputs": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "The columns it learns from (indexes, without the target); absent: every column but the target. Only with an AI module that trains on chosen columns"
          }
        }
      },
      "ModelExperimentMetrics": {
        "properties": {
          "accuracy": {
            "type": "number",
            "nullable": true
          },
          "f1": {
            "type": "number",
            "nullable": true,
            "description": "F1, macro average"
          },
          "r2": {
            "type": "number",
            "nullable": true
          },
          "mae": {
            "type": "number",
            "nullable": true
          }
        }
      },
      "ModelExperimentOptions": {
        "properties": {
          "min_candidates": {
            "type": "integer"
          },
          "max_candidates": {
            "type": "integer",
            "description": "3 on the free plan, 10 on the paid plans"
          },
          "free_plan": {
            "type": "boolean"
          },
          "methods": {
            "type": "object",
            "properties": {
              "classifier": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "regressor": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "inputs": {
            "type": "boolean",
            "description": "Whether candidates can learn from chosen columns"
          },
          "baseline": {
            "type": "string",
            "enum": [
              "ai-module",
              "platform"
            ],
            "description": "Who measures the naive prediction"
          }
        }
      },
      "ModelExperimentSummary": {
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "done",
              "failed",
              "chosen",
              "expired",
              "history"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "classifier",
              "regressor"
            ]
          },
          "source": {
            "type": "string"
          },
          "target": {
            "type": "integer"
          },
          "from_model": {
            "type": "string"
          },
          "model": {
            "type": "string",
            "description": "The model the winner became"
          },
          "task": {
            "type": "string"
          },
          "created": {
            "type": "integer"
          },
          "finished": {
            "type": "integer"
          },
          "expires": {
            "type": "integer",
            "description": "Until when a winner can be picked (0 when not waiting for a choice)"
          },
          "can_choose": {
            "type": "boolean"
          },
          "methods": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "recommended": {
            "type": "string"
          }
        }
      },
      "ModelExperiment": {
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "done",
              "failed",
              "chosen",
              "expired",
              "history"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "classifier",
              "regressor"
            ]
          },
          "source": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "available": {
                "type": "boolean"
              },
              "version": {
                "type": "integer"
              }
            }
          },
          "target": {
            "type": "object",
            "properties": {
              "index": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "from_model": {
            "type": "string"
          },
          "task": {
            "type": "string"
          },
          "created": {
            "type": "integer"
          },
          "finished": {
            "type": "integer"
          },
          "expires": {
            "type": "integer"
          },
          "can_choose": {
            "type": "boolean"
          },
          "winner": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "model_available": {
            "type": "boolean"
          },
          "split": {
            "type": "object",
            "properties": {
              "test_size": {
                "type": "number"
              },
              "shuffle": {
                "type": "boolean"
              },
              "random_state": {
                "type": "integer"
              }
            }
          },
          "primary_metric": {
            "type": "string",
            "enum": [
              "accuracy",
              "f1",
              "r2"
            ]
          },
          "baseline_source": {
            "type": "string",
            "nullable": true,
            "enum": [
              "ai-module",
              "platform",
              "mixed"
            ]
          },
          "recommended": {
            "type": "string"
          },
          "recommended_reason": {
            "type": "string",
            "enum": [
              "best",
              "tie_simpler",
              "tie_faster",
              "only",
              ""
            ]
          },
          "beats_baseline": {
            "type": "boolean",
            "nullable": true
          },
          "candidates": {
            "type": "array",
            "items": {
              "properties": {
                "key": {
                  "type": "string"
                },
                "method": {
                  "type": "string"
                },
                "search": {
                  "type": "string",
                  "enum": [
                    "default",
                    "auto"
                  ]
                },
                "inputs": {
                  "type": "array",
                  "nullable": true,
                  "items": {
                    "type": "object",
                    "properties": {
                      "index": {
                        "type": "integer"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  }
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "training",
                    "done",
                    "failed",
                    "skipped",
                    "stopped",
                    "chosen",
                    "discarded",
                    "expired",
                    "history"
                  ]
                },
                "error": {
                  "type": "string"
                },
                "error_description": {
                  "type": "string"
                },
                "metrics": {
                  "$ref": "#/components/schemas/ModelExperimentMetrics"
                },
                "main": {
                  "type": "number",
                  "nullable": true
                },
                "baseline": {
                  "nullable": true,
                  "properties": {
                    "source": {
                      "type": "string",
                      "enum": [
                        "ai-module",
                        "platform"
                      ]
                    },
                    "strategy": {
                      "type": "string",
                      "enum": [
                        "most-frequent",
                        "mean"
                      ]
                    },
                    "prediction": {
                      "description": "What it always answers (the class, or the mean); never for an AI application connected through MCP"
                    },
                    "metrics": {
                      "$ref": "#/components/schemas/ModelExperimentMetrics"
                    }
                  }
                },
                "gain": {
                  "type": "number",
                  "nullable": true,
                  "description": "Main metric minus that of the naive prediction"
                },
                "mae_reduction": {
                  "type": "number",
                  "nullable": true,
                  "description": "Regressors: 1 - mae / mae of the naive prediction, when known"
                },
                "training_ms": {
                  "type": "integer"
                },
                "size": {
                  "type": "integer"
                },
                "recommended": {
                  "type": "boolean"
                },
                "chosen": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "ModelRetrainScheduleSettings": {
        "type": "object",
        "properties": {
          "every": {
            "type": "string",
            "enum": [
              "daily",
              "weekly",
              "monthly"
            ]
          },
          "weekday": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7,
            "description": "Weekly: 1 Monday … 7 Sunday"
          },
          "day": {
            "type": "integer",
            "minimum": 1,
            "maximum": 31,
            "description": "Monthly: the day of the month (a shorter month uses its last day)"
          },
          "hour_from": {
            "type": "integer",
            "minimum": 0,
            "maximum": 23,
            "description": "The window starts at this hour"
          },
          "hour_to": {
            "type": "integer",
            "minimum": 0,
            "maximum": 23,
            "description": "The window ends at this hour (not after hour_from: the next day)"
          },
          "timezone": {
            "type": "string",
            "description": "IANA time zone; empty: the one of the organization"
          },
          "min_new_rows": {
            "type": "integer",
            "minimum": 1,
            "nullable": true,
            "description": "Mode data: new rows since the data of the version in use (null: not a condition)"
          },
          "min_growth": {
            "type": "number",
            "exclusiveMinimum": true,
            "minimum": 0,
            "maximum": 10,
            "nullable": true,
            "description": "Mode data: more rows as a share (0.1 = 10 %; null: not a condition)"
          },
          "auto_promote": {
            "type": "boolean",
            "description": "Promote the new version by itself when better on the same rows (default false)"
          },
          "min_gain": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Least improvement of the main metric to promote by itself, as a share (default 0.01 = 1 %)"
          }
        }
      },
      "ModelRetrainScheduleChange": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "off",
              "schedule",
              "data",
              "drift"
            ]
          },
          "settings": {
            "$ref": "#/components/schemas/ModelRetrainScheduleSettings"
          }
        }
      },
      "ModelRetrainSchedule": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string",
            "example": "success"
          },
          "model": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "supported": {
            "type": "boolean",
            "description": "Classifiers and regressors (forecasts keep their own retraining)"
          },
          "mode": {
            "type": "string",
            "enum": [
              "off",
              "schedule",
              "data",
              "drift"
            ]
          },
          "settings": {
            "$ref": "#/components/schemas/ModelRetrainScheduleSettings"
          },
          "timezone": {
            "type": "string",
            "description": "The time zone in use"
          },
          "next_run": {
            "type": "integer",
            "nullable": true
          },
          "last_started": {
            "type": "integer",
            "nullable": true
          },
          "last_task": {
            "type": "string"
          },
          "last_result": {
            "$ref": "#/components/schemas/ModelRetrainResult"
          },
          "history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ModelRetrainResult"
            }
          },
          "state": {
            "type": "object",
            "properties": {
              "data": {
                "nullable": true,
                "properties": {
                  "met": {
                    "type": "boolean"
                  },
                  "base_rows": {
                    "type": "integer",
                    "description": "Rows of the data the version in use learned from (-1: not known)"
                  },
                  "rows": {
                    "type": "integer"
                  },
                  "new_rows": {
                    "type": "integer"
                  },
                  "growth": {
                    "type": "number",
                    "nullable": true
                  },
                  "changed": {
                    "type": "boolean",
                    "description": "The source has a version no version of the model learned from"
                  }
                }
              },
              "monitoring": {
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "status": {
                    "type": "string"
                  },
                  "last_run": {
                    "type": "integer"
                  }
                }
              }
            }
          },
          "once_a_day": {
            "type": "object",
            "properties": {
              "free_at": {
                "type": "integer",
                "nullable": true
              }
            }
          },
          "same_rows": {
            "type": "boolean"
          },
          "keep_previous": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          },
          "updated_by": {
            "nullable": true,
            "properties": {
              "uid": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "description": "Never for an AI application connected through MCP"
          },
          "can_edit": {
            "type": "boolean"
          }
        }
      },
      "ModelRetrainResult": {
        "type": "object",
        "nullable": true,
        "properties": {
          "at": {
            "type": "integer"
          },
          "trigger": {
            "type": "string",
            "enum": [
              "schedule",
              "data",
              "drift"
            ]
          },
          "outcome": {
            "type": "string",
            "enum": [
              "started",
              "skipped",
              "candidate",
              "promoted",
              "failed"
            ]
          },
          "reason": {
            "type": "string"
          },
          "task": {
            "type": "string"
          },
          "version": {
            "type": "integer"
          },
          "previous": {
            "type": "integer"
          },
          "comparison": {
            "nullable": true,
            "properties": {
              "basis": {
                "type": "string",
                "enum": [
                  "same_rows",
                  "own_evaluation"
                ]
              },
              "metric": {
                "type": "string",
                "nullable": true
              },
              "higher_is_better": {
                "type": "boolean"
              },
              "active": {
                "type": "number",
                "nullable": true
              },
              "candidate": {
                "type": "number",
                "nullable": true
              },
              "relative": {
                "type": "number",
                "nullable": true
              },
              "rows": {
                "type": "number",
                "nullable": true
              },
              "against": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "min_gain": {
            "type": "number"
          },
          "catch_up": {
            "type": "boolean"
          },
          "source_version": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "first": {
            "type": "integer"
          },
          "started": {
            "type": "integer"
          }
        }
      },
      "TextSegment": {
        "type": "object",
        "description": "A piece of a text; `match` marks the words of the question",
        "properties": {
          "text": {
            "type": "string"
          },
          "match": {
            "type": "boolean"
          }
        }
      },
      "DataSearchHit": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "source",
              "column",
              "recipe",
              "join",
              "model",
              "dashboard",
              "visualization",
              "metric"
            ]
          },
          "id": {
            "type": "string",
            "description": "The identifier of the object (for a column, of its source)"
          },
          "ws": {
            "type": "string"
          },
          "ws_name": {
            "type": "string"
          },
          "title": {
            "type": "string",
            "description": "Its name as it is now (for a column, the column)"
          },
          "title_segments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextSegment"
            }
          },
          "column": {
            "type": "string",
            "description": "Kind column: the column"
          },
          "source": {
            "type": "object",
            "description": "Kind column: its source",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "details": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "type (of a column or a model), columns (of a source), unit (of a metric)"
          },
          "excerpt": {
            "type": "object",
            "description": "The text that matched besides the name, cut around the match (field: description, catalog, synonyms, tags, unit, semantic, target, origins, columns, inputs or source)",
            "properties": {
              "field": {
                "type": "string"
              },
              "segments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TextSegment"
                }
              }
            }
          },
          "score": {
            "type": "number"
          },
          "link": {
            "type": "object",
            "properties": {
              "section": {
                "type": "string",
                "description": "source, model, dashboard, visualization or metric"
              },
              "id": {
                "type": "string"
              },
              "tool": {
                "type": "string",
                "description": "The tool of the page that shows what matched: columns, catalog, recipe or joined (a source), config (a model)"
              },
              "column": {
                "type": "string"
              },
              "path": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "description": "The address of the page in AIR-Core"
              }
            }
          }
        }
      },
      "DataSearchResult": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "terms": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The words used (without stop words)"
          },
          "mode": {
            "type": "string",
            "enum": [
              "lexical",
              "hybrid"
            ],
            "description": "lexical: by words (hybrid only with a search by meaning, not available yet)"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataSearchHit"
            }
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Results by kind"
          },
          "took_ms": {
            "type": "integer"
          }
        }
      },
      "SearchSynonyms": {
        "type": "object",
        "properties": {
          "groups": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "defaults": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "updated": {
            "type": "string",
            "nullable": true
          },
          "updated_by": {
            "type": "string"
          },
          "can_edit": {
            "type": "boolean"
          },
          "index": {
            "type": "object",
            "description": "Only for the administrators of the organization",
            "properties": {
              "documents": {
                "type": "integer"
              },
              "pending": {
                "type": "integer"
              }
            }
          }
        }
      },
      "ModelTrustReport": {
        "type": "object",
        "description": "Trust report of a model (schema_version 1.0)",
        "properties": {
          "schema_version": {
            "type": "string",
            "example": "1.0"
          },
          "language": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "notice": {
            "type": "string",
            "description": "What the report is and is not (it helps document; no certification, no legal advice)"
          },
          "regulation": {
            "type": "string",
            "example": "Regulation (EU) 2024/1689"
          },
          "model": {
            "type": "object",
            "description": "Identity of the model (as in the model card) with its type, method and workspace"
          },
          "purpose": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "written": {
                "type": "boolean",
                "description": "Written by the organization (otherwise the description of the model)"
              },
              "missing": {
                "type": "string"
              },
              "intended_use": {
                "type": "string"
              },
              "out_of_scope": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "classification": {
            "type": "object",
            "properties": {
              "risk": {
                "type": "string",
                "enum": [
                  "unassessed",
                  "minimal",
                  "limited",
                  "high"
                ]
              },
              "risk_label": {
                "type": "string"
              },
              "chosen": {
                "type": "boolean",
                "description": "Chosen by the organization in its register of AI systems"
              },
              "responsible": {
                "type": "string"
              },
              "last_review": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            }
          },
          "data": {
            "type": "object",
            "description": "Training source, version, rows, input columns, target, columns left out and personal_data (checked, fields with name, kinds, mode, used_by_model and ai_choice)"
          },
          "method": {
            "type": "object"
          },
          "evaluation": {
            "type": "object",
            "description": "Main metric, naive baseline, test rows and the quality verdict (good, weak, not_better_than_naive or unknown)"
          },
          "explanations": {
            "type": "object",
            "description": "Global importance of the inputs: kind stored (SHAP kept with the model), evaluation (measured at training) or none"
          },
          "limitations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "severity": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "monitoring": {
            "type": "object",
            "description": "supported, enabled and the last check (drift status, PSI, current metric)"
          },
          "versions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "activity": {
            "type": "array",
            "description": "Who changed the model and when (names left out for AI applications connected through MCP)",
            "items": {
              "type": "object",
              "properties": {
                "at": {
                  "type": "string",
                  "format": "date-time"
                },
                "action": {
                  "type": "string"
                },
                "action_label": {
                  "type": "string"
                },
                "who": {
                  "type": "string"
                }
              }
            }
          },
          "human_oversight": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "written": {
                "type": "boolean"
              },
              "missing": {
                "type": "string"
              }
            }
          },
          "hosting": {
            "type": "object",
            "properties": {
              "where": {
                "type": "string",
                "enum": [
                  "eu",
                  "on_premises",
                  "self_hosted",
                  "outside_eu"
                ]
              },
              "provider": {
                "type": "string"
              },
              "region": {
                "type": "string"
              },
              "eu": {
                "type": "boolean",
                "nullable": true
              },
              "text": {
                "type": "string"
              },
              "generative_ai": {
                "type": "boolean"
              }
            }
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "generated_by": {
            "type": "string"
          }
        }
      },
      "DecisionFlowInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 500
          },
          "enabled": {
            "type": "boolean"
          },
          "trigger": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "source_updated",
                  "schedule"
                ]
              },
              "source": {
                "type": "string"
              },
              "every_hours": {
                "type": "integer",
                "minimum": 1,
                "maximum": 744
              }
            }
          },
          "model": {
            "type": "string",
            "description": "A classifier, regressor, clustering or outlier model of the workspace; empty: the condition is on the data only"
          },
          "retrain": {
            "type": "string",
            "enum": [
              "never",
              "if_due",
              "always"
            ]
          },
          "condition": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "all",
                  "rules",
                  "alert"
                ]
              },
              "match": {
                "type": "string",
                "enum": [
                  "all",
                  "any"
                ]
              },
              "rules": {
                "type": "array",
                "maxItems": 10,
                "items": {
                  "type": "object",
                  "properties": {
                    "column": {
                      "type": "string"
                    },
                    "op": {
                      "type": "string",
                      "enum": [
                        "eq",
                        "gt",
                        "gte",
                        "lt",
                        "lte",
                        "cn",
                        "cni",
                        "sw",
                        "ew",
                        "null"
                      ]
                    },
                    "value": {}
                  }
                }
              },
              "alert": {
                "type": "string"
              },
              "min_rows": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000
              }
            }
          },
          "actions": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "email",
                    "webhook",
                    "append"
                  ]
                },
                "to": {
                  "type": "string",
                  "enum": [
                    "me",
                    "members",
                    "list"
                  ],
                  "description": "email: me (who saved the flow), members (who read the workspace) or list (the notice list of the workspace)"
                },
                "recipients": {
                  "type": "array",
                  "maxItems": 20,
                  "items": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "description": "email with to list: the ids or addresses of the entries of the notice list to send to (stored as their ids); empty or missing: every address of the list. Each address receives it only while it is a member who reads the workspace or an outside address that confirmed (double opt-in), never once it unsubscribed; its unsubscribe link stops every notice of the workspace (simple notices and flows). A chosen address removed from the list is skipped, never replaced by the whole list."
                },
                "url": {
                  "type": "string",
                  "description": "webhook: https and public; never answered back"
                },
                "target": {
                  "type": "string"
                }
              }
            }
          },
          "rotate_secret": {
            "type": "boolean"
          }
        }
      },
      "DecisionFlow": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "version": {
            "type": "integer"
          },
          "trigger": {
            "type": "object"
          },
          "model": {
            "type": "string"
          },
          "retrain": {
            "type": "string"
          },
          "condition": {
            "type": "object"
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "The webhook as { type, origin, has_secret }"
            }
          },
          "last_run": {
            "type": "integer",
            "nullable": true
          },
          "next_run": {
            "type": "integer",
            "nullable": true
          },
          "waiting": {
            "type": "boolean",
            "description": "A run waits for the retraining it started"
          },
          "created": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          },
          "created_by": {
            "type": "string"
          },
          "updated_by": {
            "type": "string"
          },
          "history": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "version": {
                  "type": "integer"
                },
                "at": {
                  "type": "integer"
                },
                "by": {
                  "type": "string"
                }
              }
            }
          },
          "last_outcome": {
            "type": "object",
            "nullable": true
          },
          "webhook_secret": {
            "type": "string",
            "description": "Only in the answer that made it (shown once)"
          }
        }
      },
      "DecisionFlowRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "flow": {
            "type": "string"
          },
          "flow_version": {
            "type": "integer"
          },
          "trigger": {
            "type": "string",
            "enum": [
              "source_updated",
              "schedule",
              "test"
            ]
          },
          "dry_run": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "waiting",
              "done",
              "guarded",
              "skipped",
              "failed"
            ]
          },
          "reason": {
            "type": "string"
          },
          "actions": {
            "type": "integer"
          },
          "started": {
            "type": "integer"
          },
          "finished": {
            "type": "integer",
            "nullable": true
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "step (trigger, retrain, predict, condition, action) and its status, reason and counts"
            }
          }
        }
      },
      "SectorTemplate": {
        "type": "object",
        "description": "A template by sector: what it creates and from which data.",
        "properties": {
          "id": {
            "type": "string",
            "example": "customer-churn"
          },
          "sector": {
            "type": "string",
            "example": "services"
          },
          "icon": {
            "type": "string"
          },
          "tone": {
            "type": "string"
          },
          "minutes": {
            "type": "integer",
            "description": "About how long it takes to apply"
          },
          "name": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "story": {
            "type": "string",
            "description": "What the example shows"
          },
          "data": {
            "type": "object",
            "properties": {
              "file": {
                "type": "string",
                "description": "File of the library of example sources"
              },
              "rows": {
                "type": "integer"
              },
              "origin": {
                "type": "string",
                "description": "`synthetic`, or where the data comes from"
              },
              "licence": {
                "type": "string",
                "example": "CC0 1.0"
              }
            }
          },
          "creates": {
            "type": "object",
            "properties": {
              "source": {
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "integer"
                  }
                }
              },
              "model": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "classifier",
                      "regressor",
                      "forecast"
                    ]
                  },
                  "text": {
                    "type": "boolean",
                    "description": "Whether it reads a column of free text"
                  },
                  "name": {
                    "type": "string"
                  },
                  "explain": {
                    "type": "string"
                  },
                  "target": {
                    "type": "string",
                    "description": "The column it predicts or forecasts"
                  }
                }
              },
              "dashboard": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              },
              "alert": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "explain": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "own_data": {
            "type": "object",
            "description": "What a source of your own needs to do the same with your data",
            "properties": {
              "text": {
                "type": "string"
              },
              "columns": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string",
                      "enum": [
                        "target",
                        "input",
                        "date",
                        "series",
                        "text"
                      ],
                      "description": "What the column is for"
                    },
                    "column": {
                      "type": "string",
                      "description": "The column of the example with that role"
                    },
                    "required": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "TemplateRun": {
        "type": "object",
        "description": "The run of a template by sector (only in the task that applies one): what each step created, or why it could not.",
        "properties": {
          "task_id": {
            "type": "string"
          },
          "task_status": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "success",
              "failed"
            ]
          },
          "template": {
            "$ref": "#/components/schemas/SectorTemplate"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "complete",
              "partial",
              "failed"
            ],
            "description": "complete: everything was created; partial: something is missing; failed: nothing was created"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "step": {
                  "type": "string",
                  "enum": [
                    "source",
                    "model",
                    "dashboard",
                    "alert"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "running",
                    "done",
                    "failed",
                    "skipped"
                  ]
                },
                "id": {
                  "type": "string",
                  "description": "Identifier of what the step created"
                },
                "name": {
                  "type": "string"
                },
                "code": {
                  "type": "string",
                  "description": "Why not, when it failed or was skipped (LIMIT, NEEDS_SOURCE, ...)"
                },
                "message": {
                  "type": "string"
                },
                "details": {
                  "type": "object",
                  "description": "source: rows and columns; model: its quality verdict and figures (or the test of a forecast); dashboard: visualizations created"
                }
              }
            }
          }
        }
      },
      "AutomationTrigger": {
        "type": "object",
        "required": [
          "type"
        ],
        "description": "`source` is required but for `metric` (which watches the source of its metric; answered, not sent)",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "source_updated",
              "schedule",
              "stall",
              "metric"
            ],
            "description": "source_updated: when new rows reach the source; schedule: every `every_hours` hours (a flow); stall: when the source gets no new data for `hours` hours (a simple notice); metric: when a metric meets a condition (a simple notice)"
          },
          "source": {
            "type": "string",
            "description": "The source watched"
          },
          "every_hours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 744,
            "description": "schedule: every how many hours"
          },
          "hours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 744,
            "description": "stall: hours without new data"
          },
          "metric": {
            "type": "string",
            "description": "metric: the metric watched (GET …/metrics)"
          },
          "measure": {
            "type": "string",
            "enum": [
              "value",
              "change_pct",
              "change"
            ],
            "description": "metric: what is compared — its value, its change in percent or its difference against `compare`"
          },
          "op": {
            "type": "string",
            "enum": [
              "gt",
              "gte",
              "lt",
              "lte"
            ],
            "description": "metric: how it is compared with `threshold`"
          },
          "threshold": {
            "type": "number",
            "description": "metric: the threshold (in percent for change_pct, e.g. -20)"
          },
          "period": {
            "type": "string",
            "enum": [
              "today",
              "yesterday",
              "this_week",
              "last_7_days",
              "last_week",
              "this_month",
              "last_30_days",
              "last_month",
              "this_quarter"
            ],
            "description": "metric: the period measured"
          },
          "compare": {
            "type": "string",
            "enum": [
              "previous_period",
              "previous_year"
            ],
            "description": "metric: against what a change is measured (previous_period by default; none for value)"
          },
          "filters": {
            "type": "array",
            "maxItems": 8,
            "description": "metric: only the rows with these values, `[{field, value}]` on fields of the source of the metric",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "value": {}
              }
            }
          }
        }
      },
      "AutomationInput": {
        "type": "object",
        "description": "The fields of a flow (DecisionFlowInput) and the triggers `stall` and `metric`. Unknown keys answer 400 UNKNOWN_KEY.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 300
          },
          "enabled": {
            "type": "boolean",
            "description": "On (true by default when it is created). A simple notice is always on."
          },
          "trigger": {
            "$ref": "#/components/schemas/AutomationTrigger"
          },
          "model": {
            "type": "string",
            "description": "A model that predicts the new rows (a flow)"
          },
          "retrain": {
            "type": "string",
            "enum": [
              "never",
              "if_due",
              "always"
            ]
          },
          "condition": {
            "type": "object",
            "description": "`{kind: all}`, `{kind: rules, match: all|any, rules: [{column, op, value}]}` (op: eq, gt, gte, lt, lte, cn, cni, sw, ew, null) or `{kind: alert, alert}` (the condition of a simple notice of the source; a flow). `min_rows`: rows that must meet it (1)."
          },
          "actions": {
            "type": "array",
            "maxItems": 3,
            "description": "`{type: email, to: list|me|members, recipients?}`, `{type: webhook, url}` (https; Slack, Microsoft Teams, Google Chat and Discord get a readable message, any other address a signed JSON event) and `{type: append, target}`. Without it: an email to the notice list.",
            "items": {
              "type": "object"
            }
          },
          "rotate_secret": {
            "type": "boolean",
            "description": "A flow: a new signing secret for its webhook"
          }
        }
      },
      "Automation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "notice",
              "flow"
            ]
          },
          "type": {
            "type": "string",
            "description": "A simple notice: update, stall, metric, quality or model"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "trigger": {
            "$ref": "#/components/schemas/AutomationTrigger"
          },
          "condition": {
            "type": "object"
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "created": {
            "type": "integer",
            "description": "Milliseconds since 1970"
          },
          "updated": {
            "type": "integer",
            "description": "Milliseconds since 1970"
          }
        }
      },
      "AutomationList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "notice",
                    "flow"
                  ]
                },
                "type": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "enabled": {
                  "type": "boolean"
                },
                "source": {
                  "type": "string"
                },
                "created": {
                  "type": "integer"
                },
                "updated": {
                  "type": "integer"
                },
                "trigger": {
                  "$ref": "#/components/schemas/AutomationTrigger"
                },
                "last_outcome": {
                  "type": "object",
                  "description": "A flow: the outcome of its last run (status, reason, dry_run, started), or null"
                }
              }
            }
          }
        }
      },
      "AutomationSaved": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "notice",
              "flow"
            ]
          },
          "saved_as": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              }
            }
          },
          "automation": {
            "$ref": "#/components/schemas/Automation"
          },
          "webhook_secret": {
            "type": "string",
            "description": "The signing secret of a new webhook (shown once)"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "LIST_EMPTY: the notice list has no address yet"
          }
        }
      },
      "AutomationDeleted": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string",
            "example": "success"
          },
          "kind": {
            "type": "string",
            "enum": [
              "notice",
              "flow"
            ]
          },
          "id": {
            "type": "string"
          }
        }
      },
      "AutomationHistory": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "notice",
              "flow"
            ]
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "pages_count": {
            "type": "integer"
          },
          "items_count": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "A notice: {id, timestamp, data}; a flow: its runs (DecisionFlowRun)"
          }
        }
      },
      "AutomationTest": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "notice",
              "flow"
            ]
          },
          "dry_run": {
            "type": "boolean"
          },
          "would_fire": {
            "type": "boolean"
          },
          "rows_checked": {
            "type": "integer"
          },
          "matched": {
            "type": "integer"
          },
          "silent_hours": {
            "type": "integer"
          },
          "after_hours": {
            "type": "integer"
          },
          "run": {
            "$ref": "#/components/schemas/DecisionFlowRun"
          },
          "preview": {
            "type": "object"
          }
        }
      }
    },
    "securitySchemes": {
      "scimBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "SCIM token of the organization, shown once when it is generated"
      }
    }
  }
}
