# Next available sub-account

Endpoint reference for the 1delta API. Index: https://docs.1delta.io/llms.txt · every endpoint: https://docs.1delta.io/llms-full.txt

---

### GET /v1/data/lending/next-account

- operationId: `next-available-sub-account`
- docs: https://docs.1delta.io/1delta-api/next-available-sub-account/
- markdown: https://docs.1delta.io/1delta-api/next-available-sub-account.md
- tags: Lending (Data)

Next available sub-account

Discover the next available sub-account or position ID for a given lender and owner.

Different protocols handle sub-accounts differently:

- **Euler V2** (`accountType: SELECT`): Sub-accounts are derived by XORing the owner's last address byte with an index (0-255). The integrator selects an `accountId` from the range. Any unused value automatically creates a new sub-account.
- **Dolomite** (`accountType: SELECT`): Margin sub-accounts are arbitrary `uint256` account numbers (`accountIdRange` is `0` to `2^256-1`). Account `0` is the default cross-margin account; `activeAccountIds` lists funded accounts and `nextAccountId` is the lowest unused integer. Any unused number automatically creates a new sub-account.
- **Init Capital** (`accountType: AUTOGEN`): Position IDs are NFT hashes generated on-chain. To create a new position, **omit** the `posId`/`accountId` parameter entirely. The `nextAccountId` field is a preview of the ID that will be generated.
- **Other lenders** (Aave, Morpho, Compound, etc.): Do not support sub-accounts — returns a 400 error.

### Integration Guide

| `accountType` | To create new account | To use existing account |
|---|---|---|
| `SELECT` | Pass `accountId=<unused value>` from `accountIdRange` | Pass `accountId=<existing value>` |
| `AUTOGEN` | **Omit** `accountId` / `posId` parameter | Pass `posId=<existing ID>` |

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `chainId` | query | string | yes | Chain ID. See the `ChainId` schema for the full set of supported chains. |
| `lender` | query | string | yes | Lender identifier. See the `LenderId` schema for the full set of accepted values. |
| `account` | query | string | yes | Owner wallet address. |

**Response `200`** — Next account information

| Field | Type | Description |
| --- | --- | --- |
| `success` | true |  |
| `data` | object |  |
| `data.accountType` | "SELECT" \| "AUTOGEN" | SELECT — integrator picks an ID from the range (Euler V2). AUTOGEN — ID is generated on-chain; omit the param to create (Init Capital). |
| `data.nextAccountId` | string | For SELECT: lowest unused account ID. For AUTOGEN: preview of the on-chain generated ID. |
| `data.activeAccountIds` | string[] | Currently active account IDs for this owner. May be empty for AUTOGEN protocols. |
| `data.accountIdRange` | string[] | Inclusive [min, max] range of valid account IDs. |
| `data.createHint` | string | Human-readable instructions for integrators on how to create a new sub-account. |
| `actions` | null |  |

**Example response**

```json
{
  "success": true,
  "data": {
    "accountType": "SELECT",
    "nextAccountId": "1",
    "activeAccountIds": [
      "0",
      "3",
      "7"
    ],
    "accountIdRange": [
      "0",
      "255"
    ],
    "createHint": "string"
  }
}
```

**Response `400`** — Validation error

**Response `429`** — Rate limited. Unauthenticated callers share a per-IP budget; send an `x-api-key` header to lift it. Retry with exponential backoff.

**Response `500`** — Unexpected server error. Safe to retry with backoff.

**Response `502`** — An upstream data source or protocol origin failed (`error.code` is `ORIGIN_FAILED`). `error.details` carries the per-origin status. This is also what a missing or malformed required parameter currently returns, rather than a 400.
