ANAF (Romania)

reference Facts, options, APIs

On this page

This example looks up an organization’s Romanian fiscal code (cod unic de înregistrare, CUI, also called CIF) with the web service for VAT payers (PlatitorTvaRest v9) of Romania’s National Agency for Fiscal Administration (Agenția Națională de Administrare Fiscală, ANAF). For each golden record it stores the registered name, the trade register number, the legal form, the main CAEN activity code, the fiscal and registered office addresses, the registration status, and the VAT, VAT on cash basis, split VAT, e-Factura and inactive-taxpayer status. No API key is needed.

This is the tax agency’s register of taxpayers, not the National Trade Register Office (Oficiul Național al Registrului Comerțului, ONRC), which has no free API. It includes the trade register number (nrRegCom), legal form and registration status that ANAF holds for each company, and it also covers taxpayers that aren’t in the trade register, such as associations, public institutions and self-employed persons.

Enricher version: V2
API key: not needed

To set up the enricher, see Add REST API enricher, then use the settings and script on this page.

Settings

  • Accepted Business Domain – /Organization, or the business domain that holds your companies.

  • Version – V2 (recommended).

  • API Key – leave empty.

  • Filters – we recommend a rule that only accepts golden records where organization.cui has a value. Otherwise, every record without a CUI is listed on the enricher’s Logs tab as having returned no results.

Vocabulary and Properties

organization.cui

organization.cui holds the fiscal code, with or without the RO prefix (for example 14399840 or RO14399840). If your data uses another vocabulary key, change this field and the CUI_KEY value at the top of the script.

Request and response

Endpoint: POST https://webservicesp.anaf.ro/api/PlatitorTvaRest/v9/tva
Authentication: none
Rate limits: at most 100 CUIs per request and 1 request per second per client, as published in the service documentation. Each request takes about 1.5–2 seconds.

The script sends one request per golden record, with the CUI and today’s date (the date the status is checked for):

POST https://webservicesp.anaf.ro/api/PlatitorTvaRest/v9/tva
Content-Type: application/json
Accept: application/json

[{ "cui": 14399840, "data": "2026-12-02" }]

Shortened response (from a real response):

{
  "found": [{
    "date_generale": {
      "data": "2026-12-02",
      "cui": 14399840,
      "denumire": "DANTE INTERNATIONAL SA",
      "adresa": "MUNICIPIUL BUCUREŞTI, SECTOR 2, STR. GARA HERĂSTRĂU, NR.6, CLADIREA GLOBALWORTH SQUARE, ET.1,2,3,5,8",
      "telefon": "",
      "codPostal": "",
      "stare_inregistrare": "INREGISTRAT din data 29.08.2006",
      "organFiscalCompetent": "Direcţia Generală de Administrare a Marilor Contribuabili",
      "forma_de_proprietate": "PROPR.PRIVATA-CAPITAL PRIVAT AUTOHTON SI STRAIN",
      "forma_organizare": "PERSOANA JURIDICA",
      "forma_juridica": "SOCIETATE COMERCIALĂ PE ACŢIUNI",
      "data_inregistrare": "2002-01-23",
      "statusRO_e_Factura": false,
      "nrRegCom": "J2002000372404",
      "cod_CAEN": "4754"
    },
    "inregistrare_scop_Tva": { "scpTVA": true, "perioade_TVA": [{ "data_inceput_ScpTVA": "2002-02-01", "data_sfarsit_ScpTVA": "" }] },
    "inregistrare_RTVAI": { "statusTvaIncasare": false },
    "stare_inactiv": { "dataInactivare": "", "dataReactivare": "", "dataRadiere": "", "statusInactivi": false },
    "inregistrare_SplitTVA": { "statusSplitTVA": false },
    "adresa_sediu_social": {
      "sdenumire_Strada": "Şos. Virtuţii",
      "snumar_Strada": "148",
      "sdetalii_Adresa": "spatiul E47",
      "scod_Postal": "60787",
      "sdenumire_Localitate": "Sector 6 Mun. Bucureşti",
      "sdenumire_Judet": "MUNICIPIUL BUCUREŞTI"
    }
  }],
  "notFound": []
}

A CUI that isn’t registered returns HTTP 404 with { "found": [], "notFound": [99999999] }.

Properties added by the enricher

Property Response field Example
anaf.cui the CUI that was looked up, without RO 14399840
anaf.name date_generale.denumire DANTE INTERNATIONAL SA
anaf.tradeRegisterNumber date_generale.nrRegCom J2002000372404
anaf.registrationDate date_generale.data_inregistrare 2002-01-23
anaf.registrationStatus date_generale.stare_inregistrare, without the date INREGISTRAT
anaf.registrationStatusDate the date in stare_inregistrare, as YYYY-MM-DD 2006-08-29
anaf.legalForm date_generale.forma_juridica SOCIETATE COMERCIALĂ PE ACŢIUNI
anaf.organizationForm date_generale.forma_organizare PERSOANA JURIDICA
anaf.ownershipForm date_generale.forma_de_proprietate PROPR.PRIVATA-CAPITAL PRIVAT AUTOHTON SI STRAIN
anaf.caenCode date_generale.cod_CAEN, padded to 4 digits 4754
anaf.address date_generale.adresa (fiscal domicile), as ANAF formats it MUNICIPIUL BUCUREŞTI, SECTOR 2, STR. GARA HERĂSTRĂU, NR.6, …
anaf.registeredOfficeAddress adresa_sediu_social, on one line Şos. Virtuţii 148, spatiul E47, 060787, Sector 6 Mun. Bucureşti, MUNICIPIUL BUCUREŞTI
anaf.city adresa_sediu_social.sdenumire_Localitate Sector 6 Mun. Bucureşti
anaf.county adresa_sediu_social.sdenumire_Judet MUNICIPIUL BUCUREŞTI
anaf.postalCode date_generale.codPostal (fiscal domicile), padded to 6 digits 013329
anaf.phone date_generale.telefon 0213100245
anaf.taxOffice date_generale.organFiscalCompetent Direcţia Generală de Administrare a Marilor Contribuabili
anaf.vatRegistered inregistrare_scop_Tva.scpTVA True
anaf.vatNumber RO and the CUI, when scpTVA is true RO14399840
anaf.vatCashAccounting inregistrare_RTVAI.statusTvaIncasare False
anaf.splitVat inregistrare_SplitTVA.statusSplitTVA False
anaf.eInvoiceRegistered date_generale.statusRO_e_Factura False
anaf.inactive stare_inactiv.statusInactivi False
anaf.inactiveDate stare_inactiv.dataInactivare (the last time it was declared inactive) 2019-02-08
anaf.deregistrationDate stare_inactiv.dataRadiere 2021-07-15

A property is added only when ANAF returns a value for it. Registration statuses include INREGISTRAT (registered), RADIERE (struck off), TRANSFER(SOSIRE) (moved to another tax office), SUSPENDARE ACTIVITATE and RELUARE ACTIVITATE. Values are in Romanian, as ANAF returns them. The VAT, inactive and e-Factura values are for the date of the lookup.

If the enricher has a Preview tab, the results appear there first. To add them to golden records, go to the Map tab, select Map Data, and choose Auto Mapping. Select the business domain, enter a new vocabulary named ANAF with the key prefix anaf, and then create the mapping. Auto mapping also uses name as the golden record name, so remove that from the mapping if you want to keep your existing names. Then process the data on the Process tab. If the enricher has no Preview tab, the properties are added to the golden record as soon as it is enriched.

How the script handles input and errors

  • A leading RO, spaces, dots and dashes are removed, so RO 14399840 is looked up as 14399840. The last digit of a CUI is a check digit; golden records without a valid CUI (2 to 10 digits with a correct check digit) are skipped without calling ANAF.

  • If the CUI isn’t registered (HTTP 404, the CUI is in notFound), the script logs it and adds nothing.

  • If ANAF rejects the request (HTTP 400), its firewall answers with an HTML “Request Rejected” page, or it returns another error, the script logs the reason and adds nothing.

  • If ANAF reports that it is too busy (HTTP 429), the script throws an error that makes the enricher try the golden record again later.

  • Successful results are cached for 24 hours per CUI. Not-found answers and errors aren’t cached. To change this, edit CACHE_MILLISECONDS in the script.

Testing the enricher

  • Test connection checks only that the script runs. It doesn’t call ANAF.

  • To try the setup, create a golden record with organization.cui set to 14399840 (Dante International SA) or RO1590082 (OMV Petrom SA).

Limitations

  • ANAF allows only 1 request per second per client, and a script can’t wait between requests. When the enricher processes many golden records at once, ANAF may answer with errors or block requests. Enrich large numbers of golden records in smaller batches and keep the cache on.

  • The data is ANAF’s taxpayer record. The ONRC trade register can hold more recent information (for example, a change of name or address that ANAF hasn’t recorded yet), and data such as share capital, shareholders and administrators isn’t available.

  • The register also contains natural persons who are taxpayers (for example authorized self-employed persons, PFA, and sole traders). Their names and addresses are personal data.

  • Only the main CAEN code is available. The VAT periods history (perioade_TVA) and the IBAN field aren’t added.

Process script

// REST API enricher (V2) - Romanian taxpayer lookup with ANAF
//
// Looks up a golden record's Romanian fiscal code (CUI/CIF) in the taxpayer registers of the
// National Agency for Fiscal Administration (Agenția Națională de Administrare Fiscală, ANAF),
// using its free web service for VAT payers, PlatitorTvaRest v9
// (https://static.anaf.ro/static/10/Anaf/Informatii_R/Servicii_web/doc_WS_V9.txt), and adds
// the result to the golden record as anaf.* properties:
//
//   anaf.cui                      fiscal code (CUI/CIF) that was looked up, without RO
//   anaf.name                     registered name (denumire)
//   anaf.tradeRegisterNumber      trade register number (nrRegCom), for example J40/6743/1998
//   anaf.registrationDate         date the taxpayer was registered (YYYY-MM-DD)
//   anaf.registrationStatus       registration status, for example INREGISTRAT, RADIERE or TRANSFER(SOSIRE)
//   anaf.registrationStatusDate   date of that status (YYYY-MM-DD)
//   anaf.legalForm                legal form (forma juridică), for example SOCIETATE COMERCIALĂ PE ACȚIUNI
//   anaf.organizationForm         form of organization, for example PERSOANA JURIDICA
//   anaf.ownershipForm            form of ownership (forma de proprietate)
//   anaf.caenCode                 main activity code (CAEN), 4 digits, for example 4754
//   anaf.address                  fiscal domicile address on one line, as ANAF formats it
//   anaf.registeredOfficeAddress  registered office (sediu social) address on one line
//   anaf.city                     locality of the registered office
//   anaf.county                   county (județ) of the registered office
//   anaf.postalCode               postal code of the fiscal domicile
//   anaf.phone                    phone number of the fiscal domicile
//   anaf.taxOffice                competent tax office (organ fiscal competent)
//   anaf.vatRegistered            "True" / "False" - registered for VAT on the query date
//   anaf.vatNumber                VAT number (RO + CUI), when registered for VAT
//   anaf.vatCashAccounting        "True" / "False" - applies VAT on a cash basis (TVA la încasare)
//   anaf.splitVat                 "True" / "False" - applies split VAT payment (plata defalcată)
//   anaf.eInvoiceRegistered       "True" / "False" - in the RO e-Factura register
//   anaf.inactive                 "True" / "False" - declared an inactive taxpayer
//   anaf.inactiveDate             date it was declared inactive (YYYY-MM-DD)
//   anaf.deregistrationDate       date it was struck off (data radiere, YYYY-MM-DD)
//
// This is the tax agency's register, not the National Trade Register Office (ONRC), which has
// no free API. It includes the trade register number, legal form and registration status.
//
// No API key is needed. ANAF allows at most 1 request per second per client. See README.md next
// to this file for the enricher settings.
//
// A record gets no result (nothing is stored) when it has no valid CUI, when the CUI isn't
// registered with ANAF, or when the API can't answer.

// ---- Settings -------------------------------------------------------------------------

// Vocabulary key to read. Add the same key to the Vocabulary and Properties field.
const CUI_KEY = "organization.cui";

const ANAF_URL = "https://webservicesp.anaf.ro/api/PlatitorTvaRest/v9/tva";

// How long to reuse an answer for the same CUI. 0 turns caching off.
const CACHE_MILLISECONDS = 24 * 60 * 60 * 1000;

// ---- Script ---------------------------------------------------------------------------

function getValue(key) {
  // A plain loop rather than vocabularies.find(...): vocabularies is a .NET list, and when
  // .find is called from inside a function, later calls return the first call's match.
  const items = vocabularies || [];
  for (let i = 0; i < items.length; i++) {
    if (items[i].Key === key) {
      const value = items[i].Value;
      return value === null || value === undefined ? "" : String(value).trim();
    }
  }
  return "";
}

// Accepts "14399840", "RO14399840", "RO 14399840", "14 399 840", etc. Returns the CUI without
// leading zeros, or null when it isn't a valid CUI (2 to 10 digits, the last one a check digit
// computed with the key 753217532).
function parseCui(raw) {
  const digits = raw.toUpperCase().replace(/^RO/, "").replace(/[\s.\-]/g, "").replace(/^0+/, "");
  if (!/^\d{2,10}$/.test(digits)) {
    return null;
  }
  const body = digits.substring(0, digits.length - 1);
  const padded = ("000000000" + body).substring(body.length);
  const weights = "753217532";
  let sum = 0;
  for (let i = 0; i < 9; i++) {
    sum += Number(padded.charAt(i)) * Number(weights.charAt(i));
  }
  const checkDigit = (sum * 10) % 11 === 10 ? 0 : (sum * 10) % 11;
  return checkDigit === Number(digits.charAt(digits.length - 1)) ? digits : null;
}

function clean(value) {
  if (value === null || value === undefined) {
    return null;
  }
  const text = String(value).replace(/\s+/g, " ").trim();
  return text === "" ? null : text;
}

function parseJson(text) {
  try {
    return JSON.parse(text);
  } catch (e) {
    return null;
  }
}

function dateOnly(value) {
  const text = clean(value);
  return text && /^\d{4}-\d{2}-\d{2}/.test(text) ? text.substring(0, 10) : null;
}

function bool(value) {
  return typeof value === "boolean" ? value : null;
}

// stare_inregistrare looks like "INREGISTRAT din data 29.08.2006".
function parseStatus(value) {
  const text = clean(value);
  if (!text) {
    return { status: null, date: null };
  }
  const match = /^(.*?)\s+din data\s+(\d{2})\.(\d{2})\.(\d{4})$/.exec(text);
  return match ? { status: match[1], date: `${match[4]}-${match[3]}-${match[2]}` } : { status: text, date: null };
}

// CAEN codes have 4 digits; ANAF drops a leading zero (for example 610 for 0610).
function caenCode(value) {
  const text = clean(value);
  if (!text || !/^\d{3,4}$/.test(text)) {
    return null;
  }
  return text.length === 3 ? "0" + text : text;
}

// Romanian postal codes have 6 digits; ANAF drops a leading zero (for example 60787 for 060787).
function postalCode(value) {
  const text = clean(value);
  return text && /^\d{5}$/.test(text) ? "0" + text : text;
}

function formatOffice(office) {
  if (!office) {
    return null;
  }
  const street = [clean(office.sdenumire_Strada), clean(office.snumar_Strada)].filter((x) => !!x).join(" ");
  const parts = [street, clean(office.sdetalii_Adresa), postalCode(office.scod_Postal), clean(office.sdenumire_Localitate), clean(office.sdenumire_Judet), clean(office.stara)]
    .filter((x) => !!x);
  return parts.length > 0 ? parts.join(", ") : null;
}

// Calls the API. Returns the taxpayer (an entry of "found"), or null when there's no answer to store.
function lookUp(cui) {
  const today = new Date().toISOString().substring(0, 10);
  const apiResponse = http.send({
    url: ANAF_URL,
    method: "POST",
    headers: [
      { Key: "Content-Type", Value: "application/json" },
      { Key: "Accept", Value: "application/json" },
    ],
    body: [{ cui: Number(cui), data: today }],
  });

  const status = String(apiResponse.HttpStatus || "");
  const body = parseJson(apiResponse.Content);

  if (status === "TooManyRequests") {
    throw new Error("TooManyRequests - the ANAF web service is busy, the record will be retried");
  }

  // A CUI that isn't registered comes back in "notFound", with HTTP 404.
  if (body && Array.isArray(body.found)) {
    for (let i = 0; i < body.found.length; i++) {
      const general = body.found[i] && body.found[i].date_generale;
      if (general && String(general.cui) === cui && clean(general.denumire)) {
        return body.found[i];
      }
    }
  }

  // Others: 400 (rejected request), 5xx, or an HTML "Request Rejected" page from ANAF's firewall.
  log(`ANAF could not look up ${cui}. HTTP ${status}. ${String(apiResponse.Content || "").substring(0, 200)}`);
  return null;
}

function run() {
  const cui = parseCui(getValue(CUI_KEY));
  if (!cui) {
    // No valid CUI on this record (this is also what Test connection hits, because it passes
    // placeholder values instead of real ones).
    return [];
  }

  const cacheKey = `anaf:${cui}`;
  const cached = CACHE_MILLISECONDS > 0 ? cache.get(cacheKey) : null;
  let taxpayer = cached ? parseJson(String(cached)) : null;

  if (!taxpayer) {
    taxpayer = lookUp(cui);
    if (!taxpayer) {
      return [];
    }
    if (CACHE_MILLISECONDS > 0) {
      cache.set(cacheKey, JSON.stringify(taxpayer), CACHE_MILLISECONDS);
    }
  }

  const general = taxpayer.date_generale || {};
  const vat = taxpayer.inregistrare_scop_Tva || {};
  const cashVat = taxpayer.inregistrare_RTVAI || {};
  const inactive = taxpayer.stare_inactiv || {};
  const splitVat = taxpayer.inregistrare_SplitTVA || {};
  const office = taxpayer.adresa_sediu_social || null;
  const registration = parseStatus(general.stare_inregistrare);

  const data = {
    "anaf.cui": cui,
    "anaf.name": clean(general.denumire),
    "anaf.tradeRegisterNumber": clean(general.nrRegCom),
    "anaf.registrationDate": dateOnly(general.data_inregistrare),
    "anaf.registrationStatus": registration.status,
    "anaf.registrationStatusDate": registration.date,
    "anaf.legalForm": clean(general.forma_juridica),
    "anaf.organizationForm": clean(general.forma_organizare),
    "anaf.ownershipForm": clean(general.forma_de_proprietate),
    "anaf.caenCode": caenCode(general.cod_CAEN),
    "anaf.address": clean(general.adresa),
    "anaf.registeredOfficeAddress": formatOffice(office),
    "anaf.city": office ? clean(office.sdenumire_Localitate) : null,
    "anaf.county": office ? clean(office.sdenumire_Judet) : null,
    "anaf.postalCode": postalCode(general.codPostal),
    "anaf.phone": clean(general.telefon),
    "anaf.taxOffice": clean(general.organFiscalCompetent),
    "anaf.vatRegistered": bool(vat.scpTVA),
    "anaf.vatNumber": vat.scpTVA === true ? "RO" + cui : null,
    "anaf.vatCashAccounting": bool(cashVat.statusTvaIncasare),
    "anaf.splitVat": bool(splitVat.statusSplitTVA),
    "anaf.eInvoiceRegistered": bool(general.statusRO_e_Factura),
    "anaf.inactive": bool(inactive.statusInactivi),
    "anaf.inactiveDate": dateOnly(inactive.dataInactivare),
    "anaf.deregistrationDate": dateOnly(inactive.dataRadiere),
  };

  // Leave out values ANAF didn't return, so they don't overwrite existing data with blanks.
  Object.keys(data).forEach((key) => {
    if (data[key] === null) {
      delete data[key];
    }
  });

  return [{ Data: data, Score: 100 }];
}

response = JSON.stringify(run());