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

# Notify Deposit

> Notify NEAR 1Click API about completed deposits for faster swap processing

## Overview

The notify-deposit endpoint notifies the NEAR 1Click API about a completed deposit transaction. This allows NEAR to preemptively verify the deposit, speeding up swap processing.

<Note>
  This endpoint is specifically for NEAR protocol swaps. It's optional but recommended for faster swap execution.
</Note>

## Endpoint

```
POST /leokit/notify-deposit
```

## Request

### Headers

| Header         | Value              |
| -------------- | ------------------ |
| `Content-Type` | `application/json` |
| `Api-Key`      | Your API key       |

### Body

```json theme={null}
{
  "txHash": "0x1234567890abcdef...",
  "depositAddress": "0xabcdef1234567890..."
}
```

### Parameters

| Parameter        | Type   | Required | Description                                                  |
| ---------------- | ------ | -------- | ------------------------------------------------------------ |
| `txHash`         | string | Yes      | Transaction hash of the deposit (must start with `0x`)       |
| `depositAddress` | string | Yes      | Deposit address provided in the quote (must start with `0x`) |

## Response

### Success (200)

```json theme={null}
{
  "success": true,
  "status": "submitted",
  "correlationId": "abc123-def456",
  "message": "Deposit notification sent to NEAR"
}
```

| Field           | Description                           |
| --------------- | ------------------------------------- |
| `success`       | Whether the notification was accepted |
| `status`        | Status from NEAR 1Click API           |
| `correlationId` | Tracking ID from NEAR                 |
| `message`       | Human-readable status message         |

### Error Responses

<Tabs>
  <Tab title="400 Bad Request">
    Missing or invalid parameters:

    ```json theme={null}
    {
      "error": "Missing required fields: txHash, depositAddress"
    }
    ```

    Or invalid format:

    ```json theme={null}
    {
      "error": "Invalid format: txHash and depositAddress must be hex strings starting with 0x"
    }
    ```
  </Tab>

  <Tab title="4xx/5xx from NEAR">
    NEAR API error forwarded:

    ```json theme={null}
    {
      "error": "NEAR 1Click API error",
      "details": { ... }
    }
    ```
  </Tab>

  <Tab title="500 Internal Error">
    Server error:

    ```json theme={null}
    {
      "error": "Failed to notify NEAR about deposit",
      "details": "Connection timeout"
    }
    ```
  </Tab>
</Tabs>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.leokit.dev/leokit/notify-deposit \
    -H "Content-Type: application/json" \
    -H "Api-Key: your_api_key" \
    -d '{
      "txHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
      "depositAddress": "0xabcdef1234567890abcdef1234567890abcdef12"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.leokit.dev/leokit/notify-deposit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Api-Key': 'your_api_key'
    },
    body: JSON.stringify({
      txHash: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
      depositAddress: '0xabcdef1234567890abcdef1234567890abcdef12'
    })
  });

  const result = await response.json();
  console.log(result);
  // { success: true, status: "submitted", correlationId: "...", message: "..." }
  ```

  ```typescript TypeScript theme={null}
  interface NotifyDepositRequest {
    txHash: string;
    depositAddress: string;
  }

  interface NotifyDepositResponse {
    success: boolean;
    status: string;
    correlationId: string;
    message: string;
  }

  async function notifyDeposit(
    txHash: string,
    depositAddress: string
  ): Promise<NotifyDepositResponse> {
    const response = await fetch('https://api.leokit.dev/leokit/notify-deposit', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Api-Key': process.env.LEOKIT_API_KEY!
      },
      body: JSON.stringify({ txHash, depositAddress })
    });

    if (!response.ok) {
      throw new Error(`Notify failed: ${response.status}`);
    }

    return response.json();
  }
  ```
</CodeGroup>

## When to Use

Call this endpoint after broadcasting a deposit transaction for a NEAR-routed swap:

<Steps>
  <Step title="Get Quote">
    Request a quote with NEAR as the destination or intermediary
  </Step>

  <Step title="Generate Deposit">
    Call `/leokit/deposit` to get the deposit address and transaction
  </Step>

  <Step title="Sign & Broadcast">
    Sign and broadcast the transaction to the source chain
  </Step>

  <Step title="Notify Deposit">
    Call this endpoint with the transaction hash and deposit address
  </Step>

  <Step title="Track Status">
    Monitor the swap via `/leokit/status`
  </Step>
</Steps>

## Notes

* This endpoint forwards requests to NEAR's 1Click API at `https://1click.chaindefuser.com/v0/deposit/submit`
* The timeout for NEAR API calls is 10 seconds
* Notification is optional but can significantly speed up swap processing
* Only applicable for swaps routed through the NEAR protocol


## OpenAPI

````yaml /api-reference/openapi.json POST /notify-deposit
openapi: 3.0.3
info:
  title: Leokit API
  version: 1.0.0
  description: API reference for Leokit
servers:
  - url: https://api.leokit.dev
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /notify-deposit:
    post:
      summary: Notify NEAR deposit
      description: >-
        Notify NEAR 1Click API about a completed deposit transaction. This
        speeds up swap processing for Relay-NEAR aggregator swaps by allowing
        NEAR to preemptively verify the deposit.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotifyDepositRequest'
            example:
              txHash: >-
                0xa1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890
              depositAddress: '0x1234567890abcdef1234567890abcdef12345678'
      responses:
        '200':
          description: Deposit notification sent successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotifyDepositResponse'
              example:
                success: true
                status: received
                correlationId: abc123
                message: Deposit notification sent to NEAR
        '400':
          description: Invalid request (missing fields or invalid format)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: 'Missing required fields: txHash, depositAddress'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  schemas:
    NotifyDepositRequest:
      type: object
      description: >-
        Request body for /notify-deposit. Used to notify NEAR 1Click API about
        completed deposits.
      required:
        - txHash
        - depositAddress
      properties:
        txHash:
          type: string
          description: Transaction hash (hex string starting with 0x).
        depositAddress:
          type: string
          description: >-
            Deposit address from NEAR aggregator quote (hex string starting with
            0x).
    NotifyDepositResponse:
      type: object
      description: Response from /notify-deposit on success.
      required:
        - success
        - message
      properties:
        success:
          type: boolean
        status:
          type: string
          description: Status from NEAR 1Click API.
        correlationId:
          type: string
          description: Correlation ID from NEAR 1Click API.
        message:
          type: string
    Error:
      type: object
      description: Generic error payload.
      properties:
        message:
          type: string
        code:
          type: string
  responses:
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Api-Key
      description: 'Demo API-Key (Sandbox): 7037d2b3-9c76-4f62-b730-c544f7570fa4'

````