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

# Import Lighter Credentials

> Import existing Lighter API credentials for a wallet. Used when delegation or server wallet generation is not possible.

Import existing Lighter API credentials for a wallet. This endpoint is used when delegation or server wallet generation is not possible, allowing users to provide their own pre-generated API keys from the Lighter platform.

<Warning>
  The imported credentials will be securely linked to the authenticated user account. Never share your API private keys.
</Warning>

## Features

* **Credential Import**: Link existing Lighter API keys to your HyperDEX account
* **Secure Storage**: Credentials are encrypted and stored securely
* **Flexible Wallet Linking**: Use wallet address or internal wallet ID

## When to Use

Use this endpoint when:

* You already have Lighter API credentials generated from the Lighter platform
* Server-side wallet delegation is not available
* You want to use your existing Lighter account with HyperDEX

## Request

* **Method**: `POST`
* **Endpoint**: `/api/trading/lighter/import`
* **Authentication**: Required (JWT Bearer token)

### Headers

| Header          | Value                | Required |
| --------------- | -------------------- | -------- |
| `Content-Type`  | application/json     | Yes      |
| `Authorization` | Bearer \<jwt\_token> | Yes      |

### Request Body

```json theme={null}
{
  "walletIdOrAddress": "0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996",
  "accountIndex": 0,
  "apiKeyIndex": 10,
  "apiPublicKey": "0x...",
  "apiPrivateKey": "0x..."
}
```

### Request Parameters

| Field               | Type   | Required | Description                                                                |
| ------------------- | ------ | -------- | -------------------------------------------------------------------------- |
| `walletIdOrAddress` | string | Yes      | The wallet address or internal wallet ID associated with these credentials |
| `accountIndex`      | number | Yes      | The Lighter account index (usually `0` or `1`)                             |
| `apiKeyIndex`       | number | Yes      | The index of the API key being imported                                    |
| `apiPublicKey`      | string | Yes      | The public key of the API key pair                                         |
| `apiPrivateKey`     | string | Yes      | The private key of the API key pair                                        |

## Example Request

```bash theme={null}
curl -X POST https://api.tide.ag/api/trading/lighter/import \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "walletIdOrAddress": "0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996",
    "accountIndex": 0,
    "apiKeyIndex": 10,
    "apiPublicKey": "your_public_key",
    "apiPrivateKey": "your_private_key"
  }'
```

```javascript theme={null}
await axios.post('https://api.tide.ag/api/trading/lighter/import', {
  walletIdOrAddress: '0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996',
  accountIndex: 0,
  apiKeyIndex: 10,
  apiPublicKey: 'your_public_key',
  apiPrivateKey: 'your_private_key'
}, {
  headers: {
    'Authorization': 'Bearer YOUR_JWT_TOKEN'
  }
});
```

## Success Response

```json theme={null}
{
  "success": true,
  "message": "Lighter credentials imported successfully",
  "timestamp": 1733215000000
}
```

### Response Fields

| Field       | Type    | Description                    |
| ----------- | ------- | ------------------------------ |
| `success`   | boolean | Operation status               |
| `message`   | string  | Success message                |
| `timestamp` | number  | Unix timestamp in milliseconds |

## Error Responses

### 400 Bad Request - Missing Parameters

```json theme={null}
{
  "success": false,
  "error": "Missing parameters",
  "message": "walletIdOrAddress, accountIndex, apiKeyIndex, apiPublicKey, and apiPrivateKey are required",
  "timestamp": 1733215000000
}
```

### 401 Unauthorized - Missing Token

```json theme={null}
{
  "success": false,
  "error": "No authorization header provided"
}
```

### 500 Internal Server Error - Wallet Not Found

```json theme={null}
{
  "success": false,
  "error": "Internal server error",
  "message": "Wallet not found in system. Please connect wallet first.",
  "timestamp": 1733215000000
}
```

## How to Get Lighter Credentials

1. Visit [Lighter DEX](https://app.lighter.xyz) and create an account
2. Navigate to your account settings
3. Generate API keys from the dashboard
4. Note down your:
   * `accountIndex` - Your Lighter account index
   * `apiKeyIndex` - The API key index
   * `apiPublicKey` - Your API public key
   * `apiPrivateKey` - Your API private key

<Note>
  After importing credentials, you can use the standard trading endpoints to place orders on Lighter without providing credentials as query parameters.
</Note>

<Tip>
  If you don't have existing Lighter credentials, you can generate them directly on the Lighter platform and then import them using this endpoint.
</Tip>


## OpenAPI

````yaml POST /api/trading/lighter/import
openapi: 3.1.0
info:
  title: Tide API
  description: >-
    Decentralized Perpetual Aggregator API for multi-exchange trading across
    Hyperliquid, Aster, Lighter, and Pacifica
  version: 1.0.0
  contact:
    name: Tide Support
    email: support@tide.ag
    url: https://tide.ag
  license:
    name: MIT
servers:
  - url: https://api.tide.ag
    description: Production server
security:
  - ApiKeyAuth: []
tags:
  - name: Market Data
    description: Public market data endpoints
  - name: Trading
    description: Order placement and management
  - name: Positions
    description: Position management and history
  - name: Account
    description: Account and balance management
  - name: System
    description: System status and health
paths:
  /api/trading/lighter/import:
    post:
      tags:
        - Account
      summary: Import Lighter Credentials
      description: >-
        Import existing Lighter API credentials for a wallet. Used when
        delegation or server wallet generation is not possible.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LighterImportRequest'
            example:
              walletIdOrAddress: '0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996'
              accountIndex: 0
              apiKeyIndex: 10
              apiPublicKey: 0x...
              apiPrivateKey: 0x...
      responses:
        '200':
          description: Credentials imported successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LighterImportResponse'
        '400':
          description: Missing required parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Missing parameters
                  message:
                    type: string
                    example: >-
                      walletIdOrAddress, accountIndex, apiKeyIndex,
                      apiPublicKey, and apiPrivateKey are required
                  timestamp:
                    type: integer
        '401':
          description: Unauthorized - Missing or invalid JWT token
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: No authorization header provided
        '500':
          description: Internal server error - Wallet not found or other issues
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Internal server error
                  message:
                    type: string
                    example: Wallet not found in system. Please connect wallet first.
                  timestamp:
                    type: integer
      security:
        - BearerAuth: []
components:
  schemas:
    LighterImportRequest:
      type: object
      required:
        - walletIdOrAddress
        - accountIndex
        - apiKeyIndex
        - apiPublicKey
        - apiPrivateKey
      properties:
        walletIdOrAddress:
          type: string
          description: >-
            The wallet address or internal wallet ID associated with these
            credentials
          example: '0xA5BD439c4d4Fc7cA8B14A9FE77fd5C4FFd7e4996'
        accountIndex:
          type: integer
          description: The Lighter account index (usually 0 or 1)
          example: 0
        apiKeyIndex:
          type: integer
          description: The index of the API key being imported
          example: 10
        apiPublicKey:
          type: string
          description: The public key of the API key pair
          example: 0x...
        apiPrivateKey:
          type: string
          description: The private key of the API key pair
          example: 0x...
    LighterImportResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Lighter credentials imported successfully
        timestamp:
          type: integer
          description: Unix timestamp in milliseconds
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        API key for authentication. Also requires X-API-SECRET, X-API-TIMESTAMP,
        and X-API-SIGNATURE headers for private endpoints.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token for authentication. Required for smart order execution.

````