# SBS

Para sunat tenemos disponible los siguientes endpoint

## Tipo de cambio Promedio

<mark style="color:green;">`GET`</mark> `https://api.decolecta.com/v1/tipo-cambio/sbs/average?currency=USD`

<mark style="color:green;">`GET`</mark> `https://api.decolecta.com/v1/tipo-cambio/sbs/average?currency=EUR`

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

Extraer tipo de cambio PROMEDIO de las monedas publicadas filtrando por fecha o mensual,&#x20;

**Headers**

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

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

| Nombre   | Tipo              | Descripción                     |
| -------- | ----------------- | ------------------------------- |
| date     | date (YYYY-MM-DD) | Filtro por fecha en formato ISO |
| currency | string            | codígo de moneda                |

### 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                          |
| currency | string  | código de moneda                            |

**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-25"
}
```

{% endtab %}

{% tab title="400" %}

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

{% endtab %}
{% endtabs %}

## Tipo de cambio  contable

<mark style="color:green;">`GET`</mark> `https://api.decolecta.com/v1/tipo-cambio/sbs/accounting?currency=USD`

<mark style="color:green;">`GET`</mark> `https://api.decolecta.com/v1/tipo-cambio/sbs/accounting?currency=EUR`

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

Tipo de cambio promedio publicado por la SBS

**Headers**

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

**Body**

| Nombre           | Tipo              | Descripción                                   |
| ---------------- | ----------------- | --------------------------------------------- |
| `price`          | string            | Precio de compra                              |
| `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
{
	"price": "3.546000",
	"base_currency": "USD",
	"quote_currency": "PEN",
	"date": "2025-07-25"
}
```

{% 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-1.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.
