> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pague.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Запросить возврат

> Запрашивает полный возврат указанной платёжной транзакции. Возврат асинхронный — подтверждение приходит через вебхук `refund_completed`, когда PSP обработает его.

**Требуемое разрешение:** `REFUND:WRITE` или `FULL_ACCESS`



## OpenAPI

````yaml openapi.ru.json POST /transactions/{id}/refund
openapi: 3.0.0
info:
  title: pague.dev API
  description: Документация платёжного API pague.dev
  version: '1.0'
  contact: {}
servers:
  - url: https://api-gateway.pague.dev/v2
security: []
paths:
  /transactions/{id}/refund:
    post:
      tags:
        - External API - Transactions
      summary: Запросить возврат по транзакции
      description: >-
        Запрашивает полный возврат указанной платёжной транзакции. Возврат
        асинхронный — подтверждение приходит через вебхук `refund_completed`,
        когда PSP обработает его.


        **Требуемое разрешение:** `REFUND:WRITE` или `FULL_ACCESS`
      operationId: ExternalTransactionsController_requestRefund
      parameters:
        - name: id
          required: true
          in: path
          description: ID платёжной транзакции, подлежащей возврату
          schema:
            type: string
            format: uuid
        - $ref: '#/components/parameters/SubAccount'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestRefundInput'
      responses:
        '201':
          description: >-
            Возврат успешно запрошен. Статус PENDING до подтверждения через
            вебхук.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestRefundOutput'
        '400':
          description: >-
            Bad Request — транзакция не может быть возвращена (уже возвращена,
            истекла, недопустимый статус и т.д.)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
        '401':
          description: Unauthorized — требуется аутентификация
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorResponse'
        '404':
          description: Not Found — транзакция не найдена
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorResponse'
        '500':
          description: Internal Server Error — внутренняя ошибка сервера
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
      security:
        - bearerAuth: []
components:
  parameters:
    SubAccount:
      name: X-Sub-Account
      in: header
      required: false
      description: >-
        Reference субсчёта, в котором должна выполняться операция. Если
        заголовок не передан, операция выполняется в основном аккаунте;
        зарезервированное значение `principal` также указывает на основной
        аккаунт и равнозначно отсутствию заголовка. Принимается всеми
        эндпоинтами, кроме `POST /auth` и самих эндпоинтов `/sub-accounts`,
        которые всегда работают с основным аккаунтом.


        Возможные ошибки: `404 SUB_ACCOUNT_NOT_FOUND`, `403
        SUB_ACCOUNT_FORBIDDEN`, `403 SUB_ACCOUNT_SUSPENDED`.


        Требует, чтобы у учётных данных был включён **доступ к субсчетам**
        (Настройки → Интеграция → Учётные данные API). По умолчанию он выключен
        и не заменяется никаким разрешением, даже `FULL_ACCESS`: без него ответ
        — `403 SUB_ACCOUNT_FORBIDDEN`.
      schema:
        type: string
        pattern: ^[a-z0-9][a-z0-9_-]{1,31}$
        example: loja-centro
  schemas:
    RequestRefundInput:
      type: object
      properties:
        reason:
          type: string
          maxLength: 255
          description: Причина возврата (необязательно, максимум 255 символов)
          example: Cliente solicitou cancelamento
    RequestRefundOutput:
      type: object
      properties:
        originalTransactionId:
          type: string
          format: uuid
          description: ID исходной транзакции, по которой выполняется возврат
        pspProvider:
          type: string
          description: PSP-провайдер, обработавший возврат
        pspRefundTransactionId:
          type: string
          description: ID транзакции возврата в PSP
        status:
          type: string
          enum:
            - PENDING
            - CONFIRMED
            - ERROR
          description: >-
            Статус, возвращённый PSP. PENDING означает, что возврат принят, но
            ещё не подтверждён — подтверждение приходит через вебхук
            `refund_completed`.
          example: PENDING
      required:
        - originalTransactionId
        - pspProvider
        - pspRefundTransactionId
        - status
    BadRequestErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 400
        error:
          type: string
          example: BadRequest
        message:
          type: string
          example: name must be longer than or equal to 2 characters
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    UnauthorizedErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 401
        error:
          type: string
          example: Unauthorized
        message:
          type: string
          example: Authentication token is required
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    NotFoundErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 404
        error:
          type: string
          example: NotFound
        message:
          type: string
          example: Resource with id 550e8400-e29b-41d4-a716-446655440000 not found
        details:
          type: object
          example:
            resource: Example
            id: 550e8400-e29b-41d4-a716-446655440000
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    InternalServerErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 500
        error:
          type: string
          example: InternalError
        message:
          type: string
          example: An unexpected error occurred
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
          example: 2771463d58840c8e116dc6dda1e1e5d0
      required:
        - statusCode
        - error
        - message
        - timestamp
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Токен доступа, полученный через POST /auth (client_id + client_secret).
        Действителен в течение 300 секунд.

````