{
  "openapi": "3.1.0",
  "info": {
    "title": "RMG Circular API",
    "version": "v1",
    "summary": "Recycling and international waste shipment information.",
    "description": "Public, unauthenticated, rate limited. Every successful response carries the source it came from and the time it was retrieved. Information only, not legal advice.",
    "license": {
      "name": "Not specified"
    }
  },
  "servers": [
    {
      "url": "https://rmgcircular.com"
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Service health",
        "description": "Liveness check. Calls no upstream service and is safe to poll. Returns the API version and the current server time.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The service is up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/company/{cui}": {
      "get": {
        "operationId": "getCompanyByCui",
        "summary": "Look up a Romanian company by CUI",
        "description": "Returns registry data for a Romanian company from the ANAF public VAT-payer web service (v9). The CUI is validated locally, including its check digit, before any upstream call is made, so a malformed CUI never reaches ANAF. Responses are cached for 24 hours. Only fields ANAF actually returned are present — nothing is inferred or defaulted. Information only, not legal advice.",
        "parameters": [
          {
            "name": "cui",
            "in": "path",
            "required": true,
            "description": "Romanian fiscal identification code, with or without the RO prefix, e.g. 1590082 or RO1590082.",
            "schema": {
              "type": "string",
              "pattern": "^(RO)?[0-9]{2,10}$",
              "examples": [
                "1590082"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Company found. Includes source and retrieved_at.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "required": [
                            "cui"
                          ],
                          "description": "Only the fields ANAF returned are present. Absent fields are omitted rather than nulled.",
                          "properties": {
                            "cui": {
                              "type": "string",
                              "description": "Normalised CUI, digits only.",
                              "examples": [
                                "1590082"
                              ]
                            },
                            "name": {
                              "type": "string",
                              "examples": [
                                "OMV PETROM SA"
                              ]
                            },
                            "address": {
                              "type": "string",
                              "examples": [
                                "MUNICIPIUL BUCUREŞTI, SECTOR 1, STR. CORALILOR, NR.22, BL.PETROM CITY"
                              ]
                            },
                            "registration_status": {
                              "type": "string",
                              "examples": [
                                "INREGISTRAT din data 23.10.1997"
                              ]
                            },
                            "vat_registered": {
                              "type": "boolean",
                              "examples": [
                                true
                              ]
                            },
                            "vat_on_collection": {
                              "type": "boolean",
                              "description": "TVA la încasare — VAT accounted on collection.",
                              "examples": [
                                false
                              ]
                            },
                            "inactive": {
                              "type": "boolean",
                              "examples": [
                                false
                              ]
                            },
                            "caen_code": {
                              "type": "string",
                              "pattern": "^[0-9]{4}$",
                              "description": "CAEN Rev. 2 activity code, always four digits. ANAF returns these without leading zeros, so 0610 arrives as 610; this API pads it back to the documented width.",
                              "examples": [
                                "0610"
                              ]
                            },
                            "registration_number": {
                              "type": "string",
                              "description": "Trade register number.",
                              "examples": [
                                "J1997008302407"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The CUI is malformed or fails its check digit. No upstream call was made.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ANAF has no record for this CUI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "ANAF returned an error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "ANAF did not respond in time.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/countries": {
      "get": {
        "operationId": "list_countries",
        "summary": "Countries with published data",
        "description": "Subjects of type country that have at least one published fact. Draft, rejected and withheld data never appear.",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published countries.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/countries/{code}": {
      "get": {
        "operationId": "get_country",
        "summary": "One country",
        "description": "Every published fact about one country. Each fact carries its own source, its locator and its trust level; a fact from the official-source layer also carries the localized caveat and the 'listed in <source> as of <date>' wording.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "Identifier of the country.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The country and its published facts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "No published data for that country.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/materials": {
      "get": {
        "operationId": "list_materials",
        "summary": "Materials with published data",
        "description": "Subjects of type material that have at least one published fact. Draft, rejected and withheld data never appear.",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published materials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/materials/{id}": {
      "get": {
        "operationId": "get_material",
        "summary": "One material",
        "description": "Every published fact about one material. Each fact carries its own source, its locator and its trust level; a fact from the official-source layer also carries the localized caveat and the 'listed in <source> as of <date>' wording.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the material.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The material and its published facts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "No published data for that material.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/routes": {
      "get": {
        "operationId": "list_routes",
        "summary": "Routes with published data",
        "description": "Subjects of type route that have at least one published fact. Draft, rejected and withheld data never appear.",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published routes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/routes/{id}": {
      "get": {
        "operationId": "get_route",
        "summary": "One route",
        "description": "Every published fact about one route. Each fact carries its own source, its locator and its trust level; a fact from the official-source layer also carries the localized caveat and the 'listed in <source> as of <date>' wording.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the route.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The route and its published facts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "No published data for that route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/authorities": {
      "get": {
        "operationId": "list_authorities",
        "summary": "Authorities with published data",
        "description": "Subjects of type authority that have at least one published fact. Draft, rejected and withheld data never appear.",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published authorities.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/authorities/{id}": {
      "get": {
        "operationId": "get_authority",
        "summary": "One authority",
        "description": "Every published fact about one authority. Each fact carries its own source, its locator and its trust level; a fact from the official-source layer also carries the localized caveat and the 'listed in <source> as of <date>' wording.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the authority.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The authority and its published facts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "No published data for that authority.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/destinations": {
      "get": {
        "operationId": "list_destinations",
        "summary": "Destinations with published data",
        "description": "Subjects of type destination that have at least one published fact. Draft, rejected and withheld data never appear.",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published destinations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/destinations/{id}": {
      "get": {
        "operationId": "get_destination",
        "summary": "One destination",
        "description": "Every published fact about one destination. Each fact carries its own source, its locator and its trust level; a fact from the official-source layer also carries the localized caveat and the 'listed in <source> as of <date>' wording.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Identifier of the destination.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The destination and its published facts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "No published data for that destination.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sources/{id}": {
      "get": {
        "operationId": "get_source",
        "summary": "One source",
        "description": "A source document or official page, with how many published facts rest on it.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Source identifier.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The source.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "No such source.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/registries": {
      "get": {
        "operationId": "list_registries",
        "summary": "Mirrored official registers",
        "description": "Registers reproduced verbatim from their issuer. Each snapshot records the file's SHA-256, the version date and whether it is still the active one.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The mirrored registers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/registries/{id}/lookup": {
      "get": {
        "operationId": "lookup_registry",
        "summary": "Look a CUI up in a mirrored register",
        "description": "Returns the rows of the register that carry this CUI, exactly as the issuer wrote them. This says the CUI is listed in that register as of that date. It does not say the operator is authorised, and must not be presented as if it did.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Registry snapshot identifier.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cui",
            "in": "query",
            "required": true,
            "description": "Romanian fiscal code, with or without the RO prefix.",
            "schema": {
              "type": "string",
              "examples": [
                "RO 20920187"
              ]
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching rows, possibly none.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "400": {
            "description": "The cui parameter is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such registry snapshot.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/operators/{cui}": {
      "get": {
        "operationId": "get_operator",
        "summary": "Permit data for one operator",
        "description": "Permit data imported from official sources and published automatically because every automatic check passed. Facts are grouped by the document they came from, so an operator holding two permits does not appear as one. Phrased as listed in a source as of a date, never as authorised.",
        "parameters": [
          {
            "name": "cui",
            "in": "path",
            "required": true,
            "description": "Romanian fiscal code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language for the official-source labels: ro, en, tr or zh-Hans.",
            "schema": {
              "type": "string",
              "enum": [
                "ro",
                "en",
                "tr",
                "zh-Hans"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The operator's published permit data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "No published data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Envelope": {
        "type": "object",
        "required": [
          "data",
          "source",
          "retrieved_at",
          "disclaimer",
          "api_version"
        ],
        "properties": {
          "data": {
            "description": "The payload. Shape depends on the endpoint."
          },
          "source": {
            "type": "object",
            "required": [
              "name",
              "url"
            ],
            "description": "Where the facts came from.",
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "retrieved_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the data was fetched from the source, ISO 8601."
          },
          "disclaimer": {
            "type": "string",
            "const": "Information only, not legal advice"
          },
          "api_version": {
            "type": "string",
            "const": "v1"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "api_version"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "api_version": {
            "type": "string",
            "const": "v1"
          }
        }
      }
    }
  }
}