Validate the RUC when invoicing

When you issue an invoice you need reliable customer data: legal name, registered address and whether the RUC is active. Instead of typing it by hand or copying it from a web page, your system can fetch it through an API with consultaruc.

What to look up

GET /ruc/{id} returns, among others, these fields from the SUNAT reduced registry:

  • razon_social and direccion, to fill in the invoice;
  • estado, for example ACTIVO, BAJA DEFINITIVA or SUSPENSION TEMPORAL;
  • condicion, for example HABIDO or NO HABIDO.

An example check

What to do with each status or condition is your business decision. This is only an example of reading the response:

const res = await fetch('https://consultaruc-api.karvesol.com/ruc/' + ruc, {
  headers: { Authorization: 'Bearer sk_your_key' },
});
if (res.status === 404) return { valid: false, reason: 'RUC not found' };
const customer = await res.json();
const active = customer.estado === 'ACTIVO' && customer.condicion === 'HABIDO';

Note that estado and condicion texts arrive as SUNAT publishes them; some are abbreviated. Details are in the GET /ruc/{id} reference.

Costs and limits

Each lookup consumes 1 credit, and you can start on the Free plan. Error codes and the per-minute limit are in errors and limits; plans are in pricing.

Frequently asked questions

What should I check on a RUC before invoicing?

Usually the taxpayer status (estado) and address condition (condicion). The rules for deciding whether to issue are yours, based on your business.

Does this API validate electronic invoices?

No. It only looks up taxpayer data in the SUNAT reduced registry; it neither issues nor validates invoices.

What if the RUC does not exist?

The API returns 404 with {"error": "RUC no encontrado"}. A 404 response also consumes 1 credit.

Can I look up many RUCs in a row?

Yes, up to 240 requests per minute per API key. Store the customers you invoice often in your system so you do not request them every time.

Sign up freePricing