oneapi
Sign in
Anaf v1 / Utilitare cross-zonă

Detect document

Tells you which ANAF document you sent, without validating it: the type, the product it belongs to, the root element and the namespace. Useful when you receive XML from third parties and do not know which route to send it to.

POST
https://oneapi.ro/api/anaf/v1/detect

Request body

The request body is the whole document, sent raw (Content-Type: application/xml) — not an object with fields.

An e-invoice

efactura.xml application/xml · 4,0 KB — sent as is, in the request body.

A D394 return

d394.xml application/xml · 1,3 KB — sent as is, in the request body.

A SAF-T file

saft-d406.xml application/xml · 17,5 KB — sent as is, in the request body.

Query parameters

This route accepts no query parameters.

How it behaves

  • The document can also be sent as a file: multipart/form-data with the fisier field (curl -F fisier=@document.xml), instead of the raw body. The file content becomes the request body, so the result is identical; options stay in the query string, and any other form field next to fisier returns 422 camp_necunoscut.
  • Takes an arbitrary XML in the request body and tells you which ANAF document it is, based on the root element and namespace: e-Invoice (Invoice/CreditNote UBL), e-Transport, SAF-T / D406 or a "D" declaration (mapped to the form code, e.g. D390).
  • Handy as a first step in a flow that receives heterogeneous files: you learn the product and the right validation route (ruta_validare) without guessing the type from the file name.
  • An invalid XML or unrecognized document is not a server error: the response is 404 with document_nerecunoscut (the common error format).
  • Zero retention: the XML received is not written and not logged.

What it is for

  • Automatically routing an incoming file to the correct product validator/parser.
  • Quickly checking that a file is really the expected type before processing.

Response structure

FieldTypeDescription
data.tip string The document type: e-Factura, e-Transport, SAF-T (D406) or the "D" form code (e.g. D390).
data.produs string The umbrella product that handles it: efactura, etransport, saft or declaratii.
data.root string The XML root element.
data.namespace string The XML namespace of the root (may be null).
data.ruta_validare string The path of the route that validates this document type (e.g. /anaf/v1/efactura/validate), ready to call on the same host. null for a recognised declaration we do not validate.
meta.generat_la string When the response was built (ISO 8601).
meta.request_id string The identifier of this request. Quote it when reporting a problem — it is what the answer is found by.
data.ruta_conversie For CII: the route that turns it into CIUS-RO. Present ONLY for CII, because it is the one format we do not validate ourselves — we do not have the Factur-X profile Schematron — but we can convert and embed it.

Response examples

body: @efactura.xml

POSThttps://oneapi.ro/api/anaf/v1/detect
{
    "data": {
        "tip": "e-Factura",
        "produs": "efactura",
        "root": "Invoice",
        "namespace": "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
        "ruta_validare": "/anaf/v1/efactura/validate"
    },
    "meta": {
        "generat_la": "2026-10-06T23: 59: 41+03: 00",
        "request_id": "01a11303-d7bb-726f-9bf0-4d8d26b22abf"
    }
}

Error codes

CodeSlugWhen it occurs
401neautentificatToken missing, invalid, expired or revoked.
403modul_interzisThe token has no access to the route's module.
404negasitInvalid XML or unrecognized ANAF document (unknown root/namespace).
422xml_invalidThe request body is missing or does not have the expected shape.
429cota_depasitaThe plan's monthly quota has been exceeded (see Retry-After).

Errors in the Anaf module use the same envelope as the rest of the platform, with two extra fields: {eroare: {cod, mesaj, camp, request_id}}. eroare.cod is stable and is what you branch on; on validation (422) the code is case-specific: xml_invalid, xml_nu_e_factura, unitate_necunoscuta, luna_invalida and so on. camp points at the offending field when one can be identified.

{
    "eroare": {
        "cod": "xml_invalid",
        "mesaj": "The request body is missing or does not have the expected shape.",
        "camp": null,
        "request_id": "0199c1f0-6e1a-7c3d-9b2f-4a8e5d1c7b04"
    }
}