{
  "openapi": "3.1.0",
  "info": {
    "title": "Swiss Data Atlas API",
    "version": "1.0.0",
    "description": "Swiss company data: search, contacts, monitors, digests, natural-language questions and customer classification with gap analysis. Authenticate with a bearer API key; each key carries scopes and data limits."
  },
  "servers": [
    {
      "url": "https://swissdataatlas.com/api/public/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key issued in the app under Settings > API."
      }
    },
    "schemas": {
      "Meta": {
        "type": "object",
        "properties": {
          "requestId": {
            "type": "string"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "rowsReturned": {
            "type": "integer"
          },
          "quota": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "Company": {
        "type": "object",
        "properties": {
          "ehraId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "uid": {
            "type": "string"
          },
          "street": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "town": {
            "type": "string"
          },
          "canton": {
            "type": "string"
          },
          "cantonName": {
            "type": "string"
          },
          "registeredDate": {
            "type": "string",
            "nullable": true
          },
          "ageYears": {
            "type": "integer",
            "nullable": true
          },
          "anniversaryYears": {
            "type": "integer",
            "nullable": true
          },
          "anniversaryDate": {
            "type": "string",
            "nullable": true
          },
          "nogaCode": {
            "type": "string"
          },
          "nogaName": {
            "type": "string"
          },
          "website": {
            "type": "string"
          },
          "signatories": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "CompanyList": {
        "type": "object",
        "properties": {
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Company"
            }
          }
        }
      },
      "CompanyOne": {
        "type": "object",
        "properties": {
          "company": {
            "$ref": "#/components/schemas/Company"
          }
        }
      },
      "Contact": {
        "type": "object",
        "additionalProperties": true
      },
      "ContactResult": {
        "type": "object",
        "properties": {
          "contact": {
            "$ref": "#/components/schemas/Contact"
          },
          "cached": {
            "type": "boolean"
          }
        }
      },
      "MonitorList": {
        "type": "object",
        "properties": {
          "monitors": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "MonitorCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "MonitorRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "sent": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Digest": {
        "type": "object",
        "additionalProperties": true
      },
      "AskResult": {
        "type": "object",
        "properties": {
          "question": {
            "type": "string"
          },
          "answer": {
            "type": "string"
          },
          "sql": {
            "type": "string"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "NogaTree": {
        "type": "object",
        "properties": {
          "sections": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "Cantons": {
        "type": "object",
        "properties": {
          "cantons": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "mutationTypes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "NogaFeedbackReports": {
        "type": "object",
        "properties": {
          "reports": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "next_since": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "KeyInfo": {
        "type": "object",
        "additionalProperties": true
      },
      "CompanySearchRequest": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "anniversary",
              "registered"
            ],
            "default": "registered"
          },
          "industries": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "level",
                "code"
              ],
              "properties": {
                "level": {
                  "type": "string",
                  "enum": [
                    "section",
                    "division",
                    "group",
                    "class",
                    "type"
                  ]
                },
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "cantons": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            }
          },
          "anniversaryYears": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "fromMonths": {
            "type": "integer",
            "default": 3
          },
          "toMonths": {
            "type": "integer",
            "default": 24
          },
          "registeredFrom": {
            "type": "string",
            "nullable": true
          },
          "registeredTo": {
            "type": "string",
            "nullable": true
          },
          "websiteOnly": {
            "type": "boolean",
            "default": false
          },
          "includeDeleted": {
            "type": "boolean",
            "default": false
          },
          "includeLiquidation": {
            "type": "boolean",
            "default": false
          },
          "limit": {
            "type": "integer",
            "default": 50
          }
        }
      }
    }
  },
  "x-scopes": {
    "companies:read": "Search companies and read company details",
    "contacts:read": "Reveal signatory contact details (billed per lookup)",
    "monitors:read": "List saved monitors",
    "monitors:write": "Create monitors and trigger runs",
    "digests:read": "Read a monitor's current digest",
    "ask:write": "Ask questions in natural language",
    "reference:read": "Read industry (NOGA) and canton reference data",
    "customers:read": "Read your customer lists, their classification and gap analysis",
    "customers:write": "Upload customer lists for classification and delete them",
    "billing:read": "Read consumption and download paid receipts (organisation admins only)",
    "billing:write": "Request prepaid Wise topups (organisation admins only)",
    "feedback:read": "Read NOGA classification reports submitted by app users"
  },
  "paths": {
    "/me": {
      "get": {
        "summary": "Key introspection: scopes, limits and usage",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/KeyInfo"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/companies/search": {
      "post": {
        "summary": "Search companies (scope: companies:read)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanySearchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CompanyList"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Scope or data restriction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/companies/{uid}": {
      "get": {
        "summary": "One company by Swiss UID or registry id (scope: companies:read)",
        "parameters": [
          {
            "name": "uid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CompanyOne"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/contacts/reveal": {
      "post": {
        "summary": "Reveal a signatory's contact details (scope: contacts:read, billed)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ehraId",
                  "fullName"
                ],
                "properties": {
                  "ehraId": {
                    "type": "string"
                  },
                  "fullName": {
                    "type": "string"
                  },
                  "companyName": {
                    "type": "string",
                    "nullable": true
                  },
                  "residence": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ContactResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/monitors": {
      "get": {
        "summary": "List saved monitors (scope: monitors:read)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MonitorList"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a monitor (scope: monitors:write)",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MonitorCreated"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/monitors/{id}/run": {
      "post": {
        "summary": "Run a monitor now and mail its digest (scope: monitors:write)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MonitorRun"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/digests/{id}": {
      "get": {
        "summary": "Current digest for a monitor (scope: digests:read)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "lookbackDays",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Digest"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/ask": {
      "post": {
        "summary": "Ask a question in plain language (scope: ask:write)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "question"
                ],
                "properties": {
                  "question": {
                    "type": "string",
                    "minLength": 5,
                    "maxLength": 500
                  },
                  "history": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AskResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/customers/lists": {
      "get": {
        "summary": "List customer lists, own and organisation-shared (scope: customers:read)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Upload customers for classification (scope: customers:write)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "customers"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "includeItems": {
                    "type": "boolean",
                    "default": false
                  },
                  "customers": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 5000,
                    "items": {
                      "type": "object",
                      "description": "Provide name, uid or both.",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "uid": {
                          "type": "string",
                          "example": "CHE-123.456.789"
                        },
                        "town": {
                          "type": "string"
                        },
                        "customerId": {
                          "type": "string",
                          "description": "Your own ERP/CRM customer ID, returned unchanged"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created, with classification summary"
          }
        }
      }
    },
    "/customers/lists/{id}": {
      "get": {
        "summary": "Classification and matched customers of one list (scope: customers:read)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "summary": "Delete a list you uploaded (scope: customers:write)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted"
          }
        }
      }
    },
    "/customers/lists/{id}/gap-analysis": {
      "get": {
        "summary": "Gap analysis: untapped active companies per industry (scope: customers:read)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cantons",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "customers",
                "all"
              ],
              "default": "customers"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/billing/consumption": {
      "get": {
        "summary": "Recorded credit movements (billing:read, organisation admin)",
        "parameters": [
          {
            "name": "organisationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated credit ledger, not cash payment proof"
          },
          "403": {
            "description": "Billing access denied"
          }
        }
      }
    },
    "/billing/topups": {
      "get": {
        "summary": "List Wise topups (billing:read, organisation admin)",
        "parameters": [
          {
            "name": "organisationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Topups"
          }
        }
      },
      "post": {
        "summary": "Request a prepaid CHF Wise transfer (billing:write, organisation admin)",
        "parameters": [
          {
            "name": "organisationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount"
                ],
                "additionalProperties": false,
                "properties": {
                  "amount": {
                    "type": "number",
                    "minimum": 1,
                    "maximum": 100000,
                    "multipleOf": 0.01
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Pending topup and bank instructions, no payment made"
          },
          "503": {
            "description": "Wise receiving details not configured"
          }
        }
      }
    },
    "/billing/receipts": {
      "get": {
        "summary": "List paid receipts (billing:read, organisation admin)",
        "parameters": [
          {
            "name": "organisationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmed receipts"
          }
        }
      }
    },
    "/billing/receipts/{id}": {
      "get": {
        "summary": "Read or download paid receipt (billing:read, organisation admin)",
        "parameters": [
          {
            "name": "organisationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "download",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "html"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Receipt JSON or printable HTML attachment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "Payment not confirmed"
          }
        }
      }
    },
    "/billing/topups/{id}/confirm": {
      "post": {
        "summary": "Confirm independently verified Wise payment (billing:write, global admin only)",
        "parameters": [
          {
            "name": "organisationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wiseTransactionId",
                  "verifiedAmount",
                  "currency"
                ],
                "additionalProperties": false,
                "properties": {
                  "wiseTransactionId": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 150
                  },
                  "verifiedAmount": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "CHF"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pool funded exactly once and receipt stored"
          },
          "403": {
            "description": "Global admin required"
          },
          "409": {
            "description": "Amount mismatch or duplicate transaction"
          },
          "503": {
            "description": "Seller receipt details not configured"
          }
        }
      }
    },
    "/reference/noga": {
      "get": {
        "summary": "Industry tree (scope: reference:read)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/NogaTree"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reference/cantons": {
      "get": {
        "summary": "Cantons and mutation types (scope: reference:read)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Cantons"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/feedback/noga": {
      "get": {
        "summary": "NOGA classification reports from app users (scope: feedback:read)",
        "description": "Read-only pull of industry-classification corrections reported in the app, ordered oldest first, for the data warehouse to ingest. Reports cannot be created, changed or deleted over the API; pass the returned next_since as since on the next call.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only reports after this ISO timestamp (see cursor)."
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "created",
                "changed"
              ],
              "default": "created"
            },
            "description": "created: by report creation. changed: by last change (creation, approval or decline), so reports approved later are returned again. next_since follows the chosen cursor."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/NogaFeedbackReports"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid since or cursor value"
          }
        }
      }
    },
    "/feedback/noga/applied": {
      "get": {
        "summary": "Current applied NOGA corrections, one row per company (scope: feedback:read)",
        "description": "The authoritative corrected classification per company. primary_code is the activity used in the app; activities lists all selected codes, primary first. Ordered by updated_at; pass next_since as since to receive only companies changed since the last pull.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Invalid since value"
          }
        }
      }
    }
  }
}