# Sunat

Para sunat tenemos disponible los siguientes endpoint

## Tipo de cambio

<mark style="color:green;">`GET`</mark> `https://api.decolecta.com/v1/tipo-cambio/sunat?month=7&year=2025`

<mark style="color:green;">`GET`</mark>` ``https://api.decolecta.com/v1/tipo-cambio/sunat`

<mark style="color:green;">`GET`</mark>` ``https://api.decolecta.com/v1/tipo-cambio/sunat?date=2025-08-08`

Extraer tipo de cambio del dolar por fecha o mensual

**Headers**

| Nombre        | Valor              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <API_KEY>` |

### **Filtro por fecha (querystring)**

| Nombre | Tipo              | Descripción                     |
| ------ | ----------------- | ------------------------------- |
| date   | date (YYYY-MM-DD) | Filtro por fecha en formato ISO |

### Filtro por mes (querystring)

| Nombre | Tipo    | Descripción                                 |
| ------ | ------- | ------------------------------------------- |
| month  | integer | acepta del 1 al 12 correspondiente a un mes |
| year   | integer | fecha de 4 digitos                          |

**Body**

| Nombre           | Tipo              | Descripción                                   |
| ---------------- | ----------------- | --------------------------------------------- |
| `buy_price`      | string            | Precio de compra                              |
| `sell_price`     | string            | Precio de venta                               |
| `base_currency`  | string            | Moneda Base , para sunat siempre es dolar USD |
| `quote_currency` | string            | Siempre es PEN                                |
| `date`           | date (YYYY-MM-DD) | Fecha al que corresponde el tipo de cambio    |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
	"buy_price": "3.540",
	"sell_price": "3.552",
	"base_currency": "USD",
	"quote_currency": "PEN",
	"date": "2025-07-26"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## Consuta de RUC - Basico

<mark style="color:green;">`GET`</mark> `https://api.decolecta.com/v1/sunat/ruc?numero=20601030013`

Endpoint para consultar información de RUC

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

El token puedes incluir en el querystring (en la url) con \&token=\<token>

**Body**

| Name                    | Type   | Description        |
| ----------------------- | ------ | ------------------ |
| `razon_social`          | string |                    |
| `numero_documento`      | string | ruc de la empresa  |
| `estado`                | string |                    |
| `condicion`             | string |                    |
| `dirección`             | string |                    |
| `ubigeo`                | string | ubigeo segun sunat |
| `via_tipo`              | string |                    |
| `via_nombre`            | string |                    |
| `zona_codigo`           | string |                    |
| `zona_tipo`             | string |                    |
| `numero`                | string |                    |
| `interior`              | string |                    |
| `lote`                  | string |                    |
| `dpto`                  | string | departamente       |
| `manzana`               | string |                    |
| `kilometro`             | string |                    |
| `distrito`              | string |                    |
| `provincia`             | string |                    |
| `departamento`          | string |                    |
| `es_agente_retencion`   | bool   |                    |
| `es_buen_contribuyente` |        |                    |
| locales\_anexos         | List   |                    |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
	"razon_social": "REXTIE S.A.C.",
	"numero_documento": "20601030013",
	"estado": "ACTIVO",
	"condicion": "HABIDO",
	"direccion": "AV. JOSE GALVEZ BARRENECHEA NRO 566 INT. 101 URB. CORPAC ",
	"ubigeo": "150131",
	"via_tipo": "AV.",
	"via_nombre": "JOSE GALVEZ BARRENECHEA",
	"zona_codigo": "URB.",
	"zona_tipo": "CORPAC",
	"numero": "566",
	"interior": "101",
	"lote": "-",
	"dpto": "-",
	"manzana": "-",
	"kilometro": "-",
	"distrito": "SAN ISIDRO",
	"provincia": "LIMA",
	"departamento": "LIMA",
	"es_agente_retencion": false,
	"es_buen_contribuyente": false,
	"locales_anexos": null
}
```

{% endtab %}

{% tab title="422" %}

```json
{
  "message": "ruc no valido"
}
```

{% endtab %}
{% endtabs %}

## Consulta de ruc avanzado

<mark style="color:green;">`GET`</mark> `https://api.decolecta.com/v1/sunat/ruc/full?numero=20601030013`

Consultar información adicional de una empresa

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
	"razon_social": "REXTIE S.A.C.",
	"numero_documento": "20601030013",
	"estado": "ACTIVO",
	"condicion": "HABIDO",
	"direccion": "AV. JOSE GALVEZ BARRENECHEA NRO 566 INT. 101 URB. CORPAC ",
	"ubigeo": "150131",
	"via_tipo": "AV.",
	"via_nombre": "JOSE GALVEZ BARRENECHEA",
	"zona_codigo": "URB.",
	"zona_tipo": "CORPAC",
	"numero": "566",
	"interior": "101",
	"lote": "-",
	"dpto": "-",
	"manzana": "-",
	"kilometro": "-",
	"distrito": "SAN ISIDRO",
	"provincia": "LIMA",
	"departamento": "LIMA",
	"es_agente_retencion": false,
	"es_buen_contribuyente": false,
	"locales_anexos": null,
	"tipo": "SOCIEDAD ANONIMA CERRADA",
	"actividad_economica": "OTROS TIPOS DE INTERMEDIACION MONETARIA",
	"numero_trabajadores": "45",
	"tipo_facturacion": "MANUAL/COMPUTARIZADO",
	"tipo_contabilidad": "MANUAL/COMPUTARIZADO",
	"comercio_exterior": "SIN ACTIVIDAD"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://decolecta.gitbook.io/docs/servicios/integrations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
