{
  "openapi": "3.1.0",
  "info": {
    "title": "Ibero.center — Domicilios de empresas",
    "version": "1.0.0",
    "description": "Domicilios, sucursales e historial de personas jurídicas presentes en el directorio. Nómina SII, no consulta en vivo. Pro incluye 500 y Max 1.000 consultas por mes UTC con activación asistida. Permisos y cupo compartidos con POST /api/v1/sii/rut. Cada solicitud admitida consume una unidad incluso si falla. Las fichas web de Plus, Pro y Max no consumen cupo API. Guarde la clave exclusivamente en el servidor de su aplicación."
  },
  "servers": [
    {
      "url": "https://ibero.center"
    }
  ],
  "paths": {
    "/api/v1/companies/addresses": {
      "post": {
        "operationId": "getCompanyAddresses",
        "summary": "Consultar domicilio tributario y sucursales por RUT",
        "security": [
          {
            "ApiKey": []
          },
          {
            "Bearer": []
          }
        ],
        "description": "Enviar una sola cabecera de autenticación. domicilio es null si no existe uno vigente único. Revisar domicilioAmbiguo y domiciliosVigentes. Fechas y vigencia según SII, no verificación presencial. Respuestas Cache-Control: no-store, private y X-Request-Id para soporte.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "rut"
                ],
                "properties": {
                  "rut": {
                    "type": "string",
                    "example": "76.086.428-5"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Última edición completada. Puede contener solo historial.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CompanyAddresses"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_RUT",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "INVALID_API_KEY",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "COMPANY_DISABLED / SERVICE_FORBIDDEN / SUBSCRIPTION_REQUIRED / API_NOT_INCLUDED",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "ADDRESS_NOT_FOUND: sin registro en la edición importada; no significa que no exista domicilio.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED; Retry-After indica el próximo mes UTC.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "ADDRESS_DATA_UNAVAILABLE / API_STORAGE_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Ibero-Api-Key"
      },
      "Bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Address": {
        "type": "object",
        "properties": {
          "fecha": {
            "type": [
              "string",
              "null"
            ]
          },
          "calle": {
            "type": [
              "string",
              "null"
            ]
          },
          "numero": {
            "type": [
              "string",
              "null"
            ]
          },
          "bloque": {
            "type": [
              "string",
              "null"
            ]
          },
          "departamento": {
            "type": [
              "string",
              "null"
            ]
          },
          "villaPoblacion": {
            "type": [
              "string",
              "null"
            ]
          },
          "ciudad": {
            "type": [
              "string",
              "null"
            ]
          },
          "comuna": {
            "type": [
              "string",
              "null"
            ]
          },
          "region": {
            "type": [
              "string",
              "null"
            ]
          },
          "vigente": {
            "type": "boolean"
          },
          "tipo": {
            "type": "string"
          },
          "direccion": {
            "type": "string"
          }
        },
        "required": [
          "fecha",
          "calle",
          "numero",
          "bloque",
          "departamento",
          "villaPoblacion",
          "ciudad",
          "comuna",
          "region",
          "vigente",
          "tipo",
          "direccion"
        ]
      },
      "CompanyAddresses": {
        "type": "object",
        "properties": {
          "rut": {
            "type": "string",
            "example": "76086428-5"
          },
          "domicilio": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Address"
              },
              {
                "type": "null"
              }
            ],
            "description": "Solo cuando existe un domicilio vigente único."
          },
          "domicilioAmbiguo": {
            "type": "boolean"
          },
          "domiciliosVigentes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "sucursales": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "historicas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "otrasVigentes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "fuente": {
            "type": "object",
            "properties": {
              "nombre": {
                "const": "SII_NOMINA_DIRECCIONES"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "periodo": {
                "type": "string",
                "example": "2026-08"
              },
              "actualizadoEnOrigen": {
                "type": "string",
                "format": "date-time"
              },
              "importadoEl": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        },
        "required": [
          "rut",
          "domicilio",
          "domicilioAmbiguo",
          "domiciliosVigentes",
          "sucursales",
          "historicas",
          "otrasVigentes",
          "fuente"
        ]
      }
    }
  }
}
