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

# Refund a failed deposit by id

> Transfer the funds from a failed deposit back to a caller-provided address on the same chain, addressing the deposit by the stable id returned by `GET /deposits`. Authenticate with an `x-api-key` (write scope) or a Bearer platform token. Scoped to the caller's tenant: an unknown id and another tenant's id are both a 404. The deposit must be `failed` or `rejected`; operator-only states (`ignored`, `delayed`) are refundable through the admin endpoint only.



## OpenAPI

````yaml https://raw.githubusercontent.com/rhinestonewtf/openapi/refs/heads/main/deposit-service.json post /deposits/{id}/refund
openapi: 3.1.0
info:
  title: Deposit Service API
  version: 1.0.0
  description: >-
    Cross-chain deposit processing service with automatic token bridging and gas
    sponsorship
servers:
  - url: https://v1.orchestrator.rhinestone.dev/deposit-processor
security: []
paths:
  /deposits/{id}/refund:
    post:
      tags:
        - Processing
      summary: Refund a failed deposit by id
      description: >-
        Transfer the funds from a failed deposit back to a caller-provided
        address on the same chain, addressing the deposit by the stable id
        returned by `GET /deposits`. Authenticate with an `x-api-key` (write
        scope) or a Bearer platform token. Scoped to the caller's tenant: an
        unknown id and another tenant's id are both a 404. The deposit must be
        `failed` or `rejected`; operator-only states (`ignored`, `delayed`) are
        refundable through the admin endpoint only.
      parameters:
        - schema:
            type: string
            pattern: ^\d+$
            description: Deposit id. Returned by GET /deposits.
            example: '12345'
          required: true
          description: Deposit id. Returned by GET /deposits.
          name: id
          in: path
        - schema:
            type: string
            description: API key for authentication (omit when sending Authorization)
            example: your-api-key
          required: false
          description: API key for authentication (omit when sending Authorization)
          name: x-api-key
          in: header
        - schema:
            type: string
            description: >-
              Bearer platform token (e.g. forwarded by user-service). Takes
              precedence over `x-api-key` when both are present.
            example: Bearer eyJhbGciOi...
          required: false
          description: >-
            Bearer platform token (e.g. forwarded by user-service). Takes
            precedence over `x-api-key` when both are present.
          name: authorization
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RefundDepositByIdRequestBody'
      responses:
        '200':
          description: Deposit refunded successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefundDepositResponse'
        '400':
          description: Invalid deposit id or recipient, or deposit not eligible for refund
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            Unauthorized - credential does not belong to the client that
            registered the account, or API key lacks write scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Deposit not found or not owned by the caller
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Refund transfer failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    RefundDepositByIdRequestBody:
      type: object
      properties:
        recipient:
          type: string
          minLength: 1
          description: >-
            Address to receive the refunded tokens (EVM address or Solana public
            key).
          example: '0x742d35Cc6634C0532925a3b844Bc9e7595f5bE91'
      required:
        - recipient
    RefundDepositResponse:
      type: object
      properties:
        message:
          type: string
        transactionHash:
          type: string
        amount:
          type: string
      required:
        - message
        - transactionHash
        - amount
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        details:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
              path:
                type: array
                items:
                  anyOf:
                    - type: string
                    - type: number
              code:
                type: string
            required:
              - message
      required:
        - error

````