{
    "openapi": "3.1.0",
    "info": {
        "title": "iva.pt API",
        "version": "1.0.0",
        "description": "Free API to validate EU VAT numbers in the European Commission VIES system and to read the Portuguese VAT Code (CIVA) and the intra-Community VAT regime (RITI). No key required; rate limited per IP (20 requests/minute, 500/day for VAT checks). Legislation text is published by the Portuguese Tax and Customs Authority (AT) and is not legal or tax advice.\n\nAPI gratuita para validar números de IVA da UE no VIES e consultar o Código do IVA e o RITI.",
        "contact": {
            "name": "Sooma",
            "url": "https://iva.pt/en/api",
            "email": "support@sooma.com"
        },
        "termsOfService": "https://sooma.com/pt-pt/termos-e-condicoes/"
    },
    "servers": [
        {
            "url": "https://iva.pt/api/v1"
        }
    ],
    "paths": {
        "/vat/{vat}": {
            "get": {
                "operationId": "checkVat",
                "summary": "Validate an EU VAT number in VIES",
                "description": "Real-time check in VIES. Add `requester` (your own EU VAT number) for a qualified check, which returns the European Commission consultation number. Portuguese numbers: PT + 9-digit NIF.",
                "parameters": [
                    {
                        "name": "vat",
                        "in": "path",
                        "required": true,
                        "description": "VAT number with country prefix, e.g. PT515060445 (Greece: EL).",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "requester",
                        "in": "query",
                        "required": false,
                        "description": "Your own EU VAT number, for a qualified check.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "lang",
                        "in": "query",
                        "required": false,
                        "description": "Language of error messages.",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "en",
                                "pt"
                            ],
                            "default": "en"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Check result",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/VatResponse"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Invalid input",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate limited",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "VIES or Member State unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/status": {
            "get": {
                "operationId": "viesStatus",
                "summary": "VIES availability per Member State",
                "responses": {
                    "200": {
                        "description": "Map of country code to Available/Unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "status": {
                                            "type": "object",
                                            "additionalProperties": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/{law}/{article}": {
            "get": {
                "operationId": "getArticle",
                "summary": "Text of an article of the Portuguese VAT Code (civa) or RITI (riti)",
                "parameters": [
                    {
                        "name": "law",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "civa",
                                "riti"
                            ]
                        }
                    },
                    {
                        "name": "article",
                        "in": "path",
                        "required": true,
                        "description": "Article number, e.g. 36 or 7-a.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "lang",
                        "in": "query",
                        "required": false,
                        "description": "pt = official Portuguese text (default); en = unofficial English translation.",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "pt",
                                "en"
                            ],
                            "default": "pt"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Article",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "result": {
                                            "$ref": "#/components/schemas/Article"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/search": {
            "get": {
                "operationId": "searchLaw",
                "summary": "Search the CIVA and RITI (Portuguese keywords)",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "minLength": 3
                        }
                    },
                    {
                        "name": "law",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "civa",
                                "riti"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Matching articles",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "query": {
                                            "type": "string"
                                        },
                                        "results": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "law": {
                                                        "type": "string"
                                                    },
                                                    "article": {
                                                        "type": "string"
                                                    },
                                                    "label": {
                                                        "type": "string"
                                                    },
                                                    "title": {
                                                        "type": "string"
                                                    },
                                                    "url": {
                                                        "type": "string"
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "VatResponse": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean"
                    },
                    "result": {
                        "$ref": "#/components/schemas/VatResult"
                    }
                }
            },
            "VatResult": {
                "type": "object",
                "properties": {
                    "valid": {
                        "type": "boolean"
                    },
                    "vat": {
                        "type": "string",
                        "example": "PT515060445"
                    },
                    "countryCode": {
                        "type": "string"
                    },
                    "vatNumber": {
                        "type": "string"
                    },
                    "countryName": {
                        "type": "string"
                    },
                    "name": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "address": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "mode": {
                        "type": "string",
                        "enum": [
                            "simple",
                            "qualified"
                        ]
                    },
                    "requestDate": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "checkedAt": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "consultationNumber": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "European Commission consultation number (qualified checks only)."
                    },
                    "warning": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "requester": {
                        "type": "object",
                        "properties": {
                            "vat": {
                                "type": "string"
                            },
                            "status": {
                                "type": "string",
                                "enum": [
                                    "vies",
                                    "nifpt",
                                    "formal"
                                ]
                            },
                            "acceptedByVies": {
                                "type": "boolean"
                            }
                        }
                    },
                    "matches": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string",
                            "enum": [
                                "match",
                                "no_match",
                                "not_processed"
                            ]
                        }
                    },
                    "source": {
                        "type": "string"
                    },
                    "checkUrl": {
                        "type": "string",
                        "description": "Page on iva.pt where the user can repeat the check and request a PDF report."
                    }
                }
            },
            "Article": {
                "type": "object",
                "properties": {
                    "law": {
                        "type": "string"
                    },
                    "lawTitle": {
                        "type": "string"
                    },
                    "article": {
                        "type": "string"
                    },
                    "label": {
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "revoked": {
                        "type": "boolean"
                    },
                    "text": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "url": {
                        "type": "string"
                    },
                    "source": {
                        "type": "string"
                    },
                    "retrievedAt": {
                        "type": "string"
                    },
                    "disclaimer": {
                        "type": "string"
                    }
                }
            },
            "Error": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean"
                    },
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}