{
  "openapi": "3.1.0",
  "info": {
    "title": "Djinn Company Verifier",
    "description": "Vérification et suivi conformité des entreprises",
    "version": "0.1.0"
  },
  "paths": {
    "/health": {
      "get": {
        "summary": "Health",
        "operationId": "health_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{siren}": {
      "get": {
        "summary": "Get Company V1",
        "description": "Lookup company info from SIRENE.",
        "operationId": "get_company_v1_v1_companies__siren__get",
        "parameters": [
          {
            "name": "siren",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Siren"
            }
          },
          {
            "name": "X-API-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Company"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{siren}/compliance": {
      "get": {
        "summary": "Get Compliance V1",
        "description": "Get compliance status combining SIRENE and BODACC data.",
        "operationId": "get_compliance_v1_v1_companies__siren__compliance_get",
        "parameters": [
          {
            "name": "siren",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Siren"
            }
          },
          {
            "name": "X-API-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComplianceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{siren}/alerts": {
      "get": {
        "summary": "Get Alerts V1",
        "description": "Get BODACC alerts for a company, paginated.",
        "operationId": "get_alerts_v1_v1_companies__siren__alerts_get",
        "parameters": [
          {
            "name": "siren",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Siren"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 20,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "X-API-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "title": "Response Get Alerts V1 V1 Companies  Siren  Alerts Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/track": {
      "post": {
        "summary": "Track Company",
        "description": "Start tracking a company by SIREN for a given tenant.",
        "operationId": "track_company_v1_companies_track_post",
        "parameters": [
          {
            "name": "X-API-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TrackRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrackResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies": {
      "post": {
        "summary": "Add Company",
        "operationId": "add_company_v1_companies_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInfo"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyInfo"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/lookup": {
      "post": {
        "summary": "Lookup",
        "operationId": "lookup_v1_companies_lookup_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyLookupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyLookupResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{siren}/documents/compliance": {
      "get": {
        "summary": "Get Document Compliance",
        "operationId": "get_document_compliance_v1_companies__siren__documents_compliance_get",
        "parameters": [
          {
            "name": "siren",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Siren"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentComplianceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{siren}/documents": {
      "post": {
        "summary": "Add Document",
        "operationId": "add_document_v1_companies__siren__documents_post",
        "parameters": [
          {
            "name": "siren",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Siren"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ComplianceDocument"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComplianceDocument"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "Get Documents",
        "operationId": "get_documents_v1_companies__siren__documents_get",
        "parameters": [
          {
            "name": "siren",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Siren"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ComplianceDocument"
                  },
                  "title": "Response Get Documents V1 Companies  Siren  Documents Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/alerts": {
      "get": {
        "summary": "Get Alerts",
        "operationId": "get_alerts_v1_alerts_get",
        "parameters": [
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 50,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Alert"
                  },
                  "title": "Response Get Alerts V1 Alerts Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Alert": {
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Id"
          },
          "company_siren": {
            "type": "string",
            "title": "Company Siren"
          },
          "company_name": {
            "type": "string",
            "title": "Company Name"
          },
          "alert_type": {
            "$ref": "#/components/schemas/AlertType"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "severity": {
            "type": "string",
            "title": "Severity",
            "default": "warning"
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created At"
          },
          "resolved": {
            "type": "boolean",
            "title": "Resolved",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "company_siren",
          "company_name",
          "alert_type",
          "message"
        ],
        "title": "Alert",
        "description": "Alerte de conformité."
      },
      "AlertType": {
        "type": "string",
        "enum": [
          "document_expiring",
          "document_expired",
          "bodacc_event",
          "company_inactive"
        ],
        "title": "AlertType",
        "description": "Types d'alertes."
      },
      "Company": {
        "properties": {
          "siren": {
            "type": "string",
            "pattern": "^\\d{9}$",
            "title": "Siren"
          },
          "siret": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\d{14}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Siret"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "legal_form": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Legal Form"
          },
          "address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Address"
          },
          "naf_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Naf Code"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "ceased",
              "unknown"
            ],
            "title": "Status",
            "default": "unknown"
          },
          "creation_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Creation Date"
          }
        },
        "type": "object",
        "required": [
          "siren",
          "name"
        ],
        "title": "Company",
        "description": "Modèle entreprise exposé par les routes /v1/."
      },
      "CompanyInfo": {
        "properties": {
          "siren": {
            "type": "string",
            "pattern": "^\\d{9}$",
            "title": "Siren",
            "description": "SIREN (9 digits)"
          },
          "siret": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\d{14}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Siret",
            "description": "SIRET (14 digits)"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "legal_form": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Legal Form"
          },
          "naf_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Naf Code",
            "description": "Code APE/NAF"
          },
          "naf_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Naf Label"
          },
          "address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Address"
          },
          "postal_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Postal Code"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "City"
          },
          "creation_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Creation Date"
          },
          "workforce_bracket": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Workforce Bracket"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "siren",
          "name"
        ],
        "title": "CompanyInfo",
        "description": "Informations d'une entreprise (depuis API SIRENE)."
      },
      "CompanyLookupRequest": {
        "properties": {
          "siren": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\d{9}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Siren",
            "description": "SIREN (9 digits)"
          },
          "siret": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\d{14}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Siret",
            "description": "SIRET (14 digits)"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "description": "Raison sociale (recherche partielle)"
          }
        },
        "type": "object",
        "title": "CompanyLookupRequest",
        "description": "Requête de recherche d'entreprise."
      },
      "CompanyLookupResponse": {
        "properties": {
          "results": {
            "items": {
              "$ref": "#/components/schemas/CompanyInfo"
            },
            "type": "array",
            "title": "Results"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "results",
          "total"
        ],
        "title": "CompanyLookupResponse",
        "description": "Réponse de recherche d'entreprise."
      },
      "ComplianceDocument": {
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Id"
          },
          "company_siren": {
            "type": "string",
            "title": "Company Siren"
          },
          "document_type": {
            "$ref": "#/components/schemas/DocumentType"
          },
          "filename": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Filename"
          },
          "upload_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Upload Date"
          },
          "issue_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Issue Date"
          },
          "expiry_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expiry Date"
          },
          "status": {
            "$ref": "#/components/schemas/ComplianceStatus",
            "default": "pending"
          },
          "verification_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verification Code",
            "description": "Code de vérification URSSAF (15 chars)"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          }
        },
        "type": "object",
        "required": [
          "company_siren",
          "document_type"
        ],
        "title": "ComplianceDocument",
        "description": "Document de conformité d'une entreprise."
      },
      "ComplianceResponse": {
        "properties": {
          "siren": {
            "type": "string",
            "title": "Siren"
          },
          "company": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Company"
              },
              {
                "type": "null"
              }
            ]
          },
          "compliance_status": {
            "type": "string",
            "enum": [
              "compliant",
              "at_risk",
              "non_compliant",
              "unknown"
            ],
            "title": "Compliance Status"
          },
          "data_freshness": {
            "type": "string",
            "enum": [
              "live",
              "stale",
              "partial",
              "unavailable"
            ],
            "title": "Data Freshness"
          },
          "sources_unavailable": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Sources Unavailable",
            "default": []
          },
          "warnings": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Warnings",
            "default": []
          },
          "alerts_count": {
            "type": "integer",
            "title": "Alerts Count",
            "default": 0
          },
          "checked_at": {
            "type": "string",
            "format": "date-time",
            "title": "Checked At"
          }
        },
        "type": "object",
        "required": [
          "siren",
          "company",
          "compliance_status",
          "data_freshness",
          "checked_at"
        ],
        "title": "ComplianceResponse",
        "description": "Réponse statut conformité (routes /v1/)."
      },
      "ComplianceStatus": {
        "type": "string",
        "enum": [
          "compliant",
          "non_compliant",
          "partial",
          "pending",
          "expired"
        ],
        "title": "ComplianceStatus",
        "description": "Statut de conformité."
      },
      "DocumentComplianceResponse": {
        "properties": {
          "siren": {
            "type": "string",
            "title": "Siren"
          },
          "status": {
            "$ref": "#/components/schemas/ComplianceStatus"
          },
          "documents": {
            "items": {
              "$ref": "#/components/schemas/ComplianceDocument"
            },
            "type": "array",
            "title": "Documents"
          },
          "alerts": {
            "items": {
              "$ref": "#/components/schemas/Alert"
            },
            "type": "array",
            "title": "Alerts"
          }
        },
        "type": "object",
        "required": [
          "siren",
          "status",
          "documents",
          "alerts"
        ],
        "title": "DocumentComplianceResponse"
      },
      "DocumentType": {
        "type": "string",
        "enum": [
          "kbis",
          "urssaf",
          "fiscal",
          "rc_pro",
          "foreign_workers",
          "other"
        ],
        "title": "DocumentType",
        "description": "Types de documents de conformité."
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "HealthResponse": {
        "properties": {
          "status": {
            "type": "string",
            "title": "Status",
            "default": "ok"
          },
          "service": {
            "type": "string",
            "title": "Service",
            "default": "company-verifier"
          }
        },
        "type": "object",
        "title": "HealthResponse"
      },
      "TrackRequest": {
        "properties": {
          "siren": {
            "type": "string",
            "pattern": "^\\d{9}$",
            "title": "Siren"
          },
          "tenant_id": {
            "type": "string",
            "title": "Tenant Id"
          }
        },
        "type": "object",
        "required": [
          "siren",
          "tenant_id"
        ],
        "title": "TrackRequest",
        "description": "Requête de suivi d'entreprise."
      },
      "TrackResponse": {
        "properties": {
          "siren": {
            "type": "string",
            "title": "Siren"
          },
          "tenant_id": {
            "type": "string",
            "title": "Tenant Id"
          },
          "tracked": {
            "type": "boolean",
            "title": "Tracked",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "siren",
          "tenant_id"
        ],
        "title": "TrackResponse"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    }
  }
}
