> For the complete documentation index, see [llms.txt](https://docs.tupayonline.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tupayonline.com/english/api-documentation/deposit/subscriptions-process/refunds.md). Agents can also search and read this documentation through its [MCP server](https://docs.tupayonline.com/~gitbook/mcp).

# Refunds

Devolución de cobros `YPOC` / `YPOR` a la cuenta Yape del usuario (mismo endpoint de refunds de la API v3).

## Devolución de un cobro YPOC / YPOR a la cuenta Yape

> Endpoint estándar de refunds de la API v3. Para depósitos \`YPOC\` / \`YPOR\` el dinero vuelve a la cuenta Yape\
> del usuario y \*\*no se requiere \`bank\_account\`\*\* (si viene, se ignora).\
> \
> Reglas para \`YPOC\` / \`YPOR\`:\
> \- El depósito debe estar \`COMPLETED\`.\
> \- \*\*Solo monto total\*\*: sin \`amount\` se devuelve el total; con \`amount\`, debe ser igual al total. Un depósito\
> &#x20; admite una sola devolución.\
> \- Hasta \*\*365 días\*\* desde el cobro.\
> \- El merchant debe tener los refunds habilitados y saldo suficiente. El monto se descuenta del balance cuando\
> &#x20; la devolución queda \`COMPLETED\`.\
> \
> Es \*\*asíncrono\*\*: la respuesta solo confirma que la devolución quedó registrada (\`PENDING\`). El resultado llega\
> después, normalmente en minutos (\`DELIVERED\` → \`COMPLETED\` | \`REJECTED\`).<br>

```json
{"openapi":"3.0.3","info":{"title":"Payment Subscriptions API","version":"1.3.0"},"tags":[{"name":"Refunds","description":"Devolución de cobros `YPOC` / `YPOR` a la cuenta Yape del usuario (mismo endpoint de refunds de la API v3)."}],"servers":[{"url":"https://api.directa24.com","description":"Production"},{"url":"https://api-stg.directa24.com","description":"Staging"}],"paths":{"/v3/refunds":{"post":{"tags":["Refunds"],"operationId":"createRefund","summary":"Devolución de un cobro YPOC / YPOR a la cuenta Yape","description":"Endpoint estándar de refunds de la API v3. Para depósitos `YPOC` / `YPOR` el dinero vuelve a la cuenta Yape\ndel usuario y **no se requiere `bank_account`** (si viene, se ignora).\n\nReglas para `YPOC` / `YPOR`:\n- El depósito debe estar `COMPLETED`.\n- **Solo monto total**: sin `amount` se devuelve el total; con `amount`, debe ser igual al total. Un depósito\n  admite una sola devolución.\n- Hasta **365 días** desde el cobro.\n- El merchant debe tener los refunds habilitados y saldo suficiente. El monto se descuenta del balance cuando\n  la devolución queda `COMPLETED`.\n\nEs **asíncrono**: la respuesta solo confirma que la devolución quedó registrada (`PENDING`). El resultado llega\ndespués, normalmente en minutos (`DELIVERED` → `COMPLETED` | `REJECTED`).\n","parameters":[{"$ref":"#/components/parameters/XLogin"},{"$ref":"#/components/parameters/XDate"},{"$ref":"#/components/parameters/Authorization"},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRefundRequest"}}}},"responses":{"201":{"description":"Devolución registrada en `PENDING`.","headers":{"Location":{"description":"URL de la devolución creada","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRefundResponse"}}}},"400":{"description":"Request inválido. Además de los errores generales de la API v3:\n`104 IDEMPOTENCY_KEY_ALREADY_USED`, `800 REFUND_NOT_ENABLED`, `801 DEPOSIT_NOT_COMPLETED`,\n`802 INVALID_AMOUNT_TO_REFUND` (monto distinto del total, o el depósito ya tiene una devolución),\n`803 INSUFFICIENT_FUNDS`, `808 REFUND_PERIOD_EXPIRED` (más de 365 días desde el cobro).\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"`208 RESOURCE_NOT_FOUND`: el depósito no existe, es de otro merchant o no corresponde al `invoice_id`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`807 REFUND_IN_PROGRESS`: se está creando otra devolución de ese depósito. Reintentar en unos segundos.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"callbacks":{"refundStatusChanged":{"{$request.body#/notification_url}":{"post":{"summary":"Aviso de cambio de estado de la devolución","description":"Se envía en cada cambio de estado (`DELIVERED`, `COMPLETED`, `REJECTED`) a la `notification_url` del\nrequest o, si no vino, a la \"Url de devolución\" configurada en el panel (Settings > Integration).\nSolo trae el `refund_id`: consultar el estado con `GET /v3/refunds/{refund_id}`. Es distinto del aviso\nde pagos (que llega a la \"Url de confirmación\" con `deposit_id`).\n","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefundNotification"}}}},"responses":{"200":{"description":"Responder 200 para confirmar la recepción."}}}}}}}}},"components":{"parameters":{"XLogin":{"name":"X-Login","in":"header","required":true,"description":"Login del merchant","schema":{"type":"string"}},"XDate":{"name":"X-Date","in":"header","required":true,"description":"Fecha UTC del request, `yyyy-MM-dd'T'HH:mm:ss'Z'`. Vale 15 segundos (fuera de ventana → `103 INVALID_DATE_RANGE`).","schema":{"type":"string"}},"Authorization":{"name":"Authorization","in":"header","required":true,"description":"`D24 ` + HMAC-SHA256 (hex) de `X-Date + X-Login + body` con el secret key del merchant.","schema":{"type":"string"}},"IdempotencyKey":{"name":"X-Idempotency-Key","in":"header","required":false,"description":"Recomendado. Evita crear dos devoluciones si se reintenta el mismo request (repetido → `104`).","schema":{"type":"string"}}},"schemas":{"CreateRefundRequest":{"type":"object","required":["deposit_id","invoice_id"],"description":"Mismo body de `POST /v3/refunds` que para cualquier depósito. Para `YPOC` / `YPOR` no se envía `bank_account`\n(si viene, se ignora) y solo se admite el monto total.\n","properties":{"deposit_id":{"type":"integer","description":"Id del depósito a devolver (devuelto por `POST /v3/deposits`)"},"invoice_id":{"type":"string","description":"El `invoice_id` enviado en ese depósito"},"amount":{"type":"number","format":"decimal","description":"Opcional. Si se envía, debe ser igual al monto total del depósito (`YPOC` / `YPOR` no admite parciales)."},"notification_url":{"type":"string","format":"uri","description":"Opcional. URL para avisar los cambios de estado. Si no viene, se usa la \"Url de devolución\" del panel."},"comments":{"type":"string","description":"Opcional. Comentario libre."}}},"CreateRefundResponse":{"type":"object","required":["refund_id"],"properties":{"refund_id":{"type":"integer","description":"Id de la devolución. Usarlo en `GET /v3/refunds/{refund_id}`."}}},"Error":{"type":"object","required":["code","description","type"],"properties":{"code":{"type":"integer","description":"Código público de error"},"description":{"type":"string"},"type":{"type":"string","description":"Nombre del error"},"details":{"type":"array","items":{"type":"string"},"description":"Solo en `201 BEAN_VALIDATION_ERROR`, un elemento por campo inválido (`campo: motivo`)"}},"description":"Códigos propios de suscripciones:\n\n| code | type | HTTP |\n|---|---|---|\n| 910 | PAYMENT_SUBSCRIPTION_NOT_FOUND | 404 |\n| 911 | PAYMENT_SUBSCRIPTION_NOT_CANCELLABLE | 409 |\n| 912 | PAYMENT_SUBSCRIPTION_PENDING_CONFIRMATION | 409 |\n| 913 | PAYMENT_SUBSCRIPTION_INVALID_REQUEST | 400 |\n| 914 | PAYMENT_SUBSCRIPTION_PROVIDER_REJECTED | 502 |\n| 915 | PAYMENT_SUBSCRIPTION_PROVIDER_UNAVAILABLE | 503 |\n| 916 | PAYMENT_SUBSCRIPTION_REQUIRED | 400 (solo en `POST /v3/deposits` con YPOC / YPOR: sin suscripción `CONFIRMED` para ese `payer.id`) |\n\nCódigos de devoluciones (`POST /v3/refunds`, `GET /v3/refunds/{refund_id}`):\n\n| code | type | HTTP |\n|---|---|---|\n| 104 | IDEMPOTENCY_KEY_ALREADY_USED | 400 |\n| 208 | RESOURCE_NOT_FOUND | 404 |\n| 705 | REFUND_NOT_FOUND | 404 |\n| 800 | REFUND_NOT_ENABLED | 400 |\n| 801 | DEPOSIT_NOT_COMPLETED | 400 |\n| 802 | INVALID_AMOUNT_TO_REFUND | 400 |\n| 803 | INSUFFICIENT_FUNDS | 400 |\n| 807 | REFUND_IN_PROGRESS | 409 |\n| 808 | REFUND_PERIOD_EXPIRED | 400 |\n\nTambién aplican los errores generales de la API v3 (headers, credenciales, `INVALID_COUNTRY`,\n`PAYMENT_METHOD_NOT_FOUND` si el merchant no tiene el payment method habilitado).\n"},"RefundNotification":{"type":"object","required":["refund_id"],"description":"Body del aviso de cambio de estado de una devolución.","properties":{"refund_id":{"type":"integer"}}}},"responses":{"Unauthorized":{"description":"`100 INVALID_CREDENTIALS` (X-Login inválido), `102 INVALID_SIGNATURE` (firma inválida) o\n`202 INVALID_IP` (IP fuera de la whitelist del merchant).\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```

## GET /v3/refunds/{refund\_id}

> Consulta de una devolución

```json
{"openapi":"3.0.3","info":{"title":"Payment Subscriptions API","version":"1.3.0"},"tags":[{"name":"Refunds","description":"Devolución de cobros `YPOC` / `YPOR` a la cuenta Yape del usuario (mismo endpoint de refunds de la API v3)."}],"servers":[{"url":"https://api.directa24.com","description":"Production"},{"url":"https://api-stg.directa24.com","description":"Staging"}],"paths":{"/v3/refunds/{refund_id}":{"get":{"tags":["Refunds"],"operationId":"getRefund","summary":"Consulta de una devolución","parameters":[{"$ref":"#/components/parameters/RefundId"},{"$ref":"#/components/parameters/XLogin"},{"$ref":"#/components/parameters/XDate"},{"$ref":"#/components/parameters/Authorization"}],"responses":{"200":{"description":"Devolución encontrada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefundStatus"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"`705 REFUND_NOT_FOUND`: la devolución no existe o es de otro merchant.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"RefundId":{"name":"refund_id","in":"path","required":true,"description":"Id de la devolución devuelto en `POST /v3/refunds`","schema":{"type":"integer"}},"XLogin":{"name":"X-Login","in":"header","required":true,"description":"Login del merchant","schema":{"type":"string"}},"XDate":{"name":"X-Date","in":"header","required":true,"description":"Fecha UTC del request, `yyyy-MM-dd'T'HH:mm:ss'Z'`. Vale 15 segundos (fuera de ventana → `103 INVALID_DATE_RANGE`).","schema":{"type":"string"}},"Authorization":{"name":"Authorization","in":"header","required":true,"description":"`D24 ` + HMAC-SHA256 (hex) de `X-Date + X-Login + body` con el secret key del merchant.","schema":{"type":"string"}}},"schemas":{"RefundStatus":{"type":"object","properties":{"deposit_id":{"type":"integer"},"merchant_invoice_id":{"type":"string"},"status":{"type":"string","enum":["PENDING","DELIVERED","COMPLETED","REJECTED"],"description":"- `PENDING`: registrada, todavía no enviada a Yape.\n- `DELIVERED`: enviada a Yape, esperando el resultado.\n- `COMPLETED`: Yape devolvió el dinero a la cuenta del usuario.\n- `REJECTED`: Yape la rechazó.\n"},"amount":{"type":"number","format":"decimal"}}},"Error":{"type":"object","required":["code","description","type"],"properties":{"code":{"type":"integer","description":"Código público de error"},"description":{"type":"string"},"type":{"type":"string","description":"Nombre del error"},"details":{"type":"array","items":{"type":"string"},"description":"Solo en `201 BEAN_VALIDATION_ERROR`, un elemento por campo inválido (`campo: motivo`)"}},"description":"Códigos propios de suscripciones:\n\n| code | type | HTTP |\n|---|---|---|\n| 910 | PAYMENT_SUBSCRIPTION_NOT_FOUND | 404 |\n| 911 | PAYMENT_SUBSCRIPTION_NOT_CANCELLABLE | 409 |\n| 912 | PAYMENT_SUBSCRIPTION_PENDING_CONFIRMATION | 409 |\n| 913 | PAYMENT_SUBSCRIPTION_INVALID_REQUEST | 400 |\n| 914 | PAYMENT_SUBSCRIPTION_PROVIDER_REJECTED | 502 |\n| 915 | PAYMENT_SUBSCRIPTION_PROVIDER_UNAVAILABLE | 503 |\n| 916 | PAYMENT_SUBSCRIPTION_REQUIRED | 400 (solo en `POST /v3/deposits` con YPOC / YPOR: sin suscripción `CONFIRMED` para ese `payer.id`) |\n\nCódigos de devoluciones (`POST /v3/refunds`, `GET /v3/refunds/{refund_id}`):\n\n| code | type | HTTP |\n|---|---|---|\n| 104 | IDEMPOTENCY_KEY_ALREADY_USED | 400 |\n| 208 | RESOURCE_NOT_FOUND | 404 |\n| 705 | REFUND_NOT_FOUND | 404 |\n| 800 | REFUND_NOT_ENABLED | 400 |\n| 801 | DEPOSIT_NOT_COMPLETED | 400 |\n| 802 | INVALID_AMOUNT_TO_REFUND | 400 |\n| 803 | INSUFFICIENT_FUNDS | 400 |\n| 807 | REFUND_IN_PROGRESS | 409 |\n| 808 | REFUND_PERIOD_EXPIRED | 400 |\n\nTambién aplican los errores generales de la API v3 (headers, credenciales, `INVALID_COUNTRY`,\n`PAYMENT_METHOD_NOT_FOUND` si el merchant no tiene el payment method habilitado).\n"}},"responses":{"Unauthorized":{"description":"`100 INVALID_CREDENTIALS` (X-Login inválido), `102 INVALID_SIGNATURE` (firma inválida) o\n`202 INVALID_IP` (IP fuera de la whitelist del merchant).\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tupayonline.com/english/api-documentation/deposit/subscriptions-process/refunds.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
