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

# Load Index

Loads an existing encrypted index and returns an instance of `EncryptedIndex`.

```python theme={null}
def load_index(self,
               index_name: str,
               index_key: bytes,
               logger: Logger | None = None,
               *,
               user_id: bytes | None = None) -> EncryptedIndex
```

### Parameters

| Parameter    | Type                 | Default | Description                                                                                                                                                                                          |
| ------------ | -------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index_name` | `str`                | -       | Name of the index to load.                                                                                                                                                                           |
| `index_key`  | `bytes`              | -       | 32-byte encryption key. For a normal load this is the index KEK used during [`create_index()`](./create-index). For an RBAC user-scoped load (`user_id` set), this is that user's 32-byte KEK.       |
| `logger`     | [`Logger`](./logger) | `None`  | *(Optional)* Logger instance for capturing operation logs.                                                                                                                                           |
| `user_id`    | `bytes` \| `None`    | `None`  | *(Optional, keyword-only)* 16-byte RBAC user identifier. When set, the index is loaded scoped to that user and `index_key` is interpreted as the user's KEK; per-operation permissions are enforced. |

<Note>RBAC user keys are minted by the root KEK holder via `create_user_keys`. A user then loads with `load_index(name, their_user_kek, user_id=their_id)`. See [access control](../../guides/advanced/access-control).</Note>

### Returns

`EncryptedIndex`: An instance of the loaded encrypted index.

### Exceptions

<AccordionGroup>
  <Accordion title="ValueError">
    * Throws if the index name does not exist.
  </Accordion>

  <Accordion title="RuntimeError">
    * Throws if the index could not be loaded or decrypted.
  </Accordion>
</AccordionGroup>

### Example Usage

```python theme={null}
import cyborgdb_core as cyborgdb

api_key = "your_api_key_here"  # Replace with your CyborgDB API key

client = cyborgdb.Client(api_key, cyborgdb.StorageConfig.disk("/tmp/cyborgdb"))

index_name = "my_index"
index_key = my_index_key  # Same 32-byte KEK used during index creation

# Optional: Set up logging
logger = cyborgdb.Logger.instance()
logger.configure(level="debug", to_file=True, file_path="index_loading.log")

# Load the existing index with logging enabled
index = client.load_index(index_name, index_key, logger=logger)
```

#### RBAC user-scoped load

```python theme={null}
# Load the index scoped to an RBAC user, passing that user's KEK as index_key
index = client.load_index(
    index_name,
    user_kek,            # the user's 32-byte KEK
    user_id=user_id,     # the user's 16-byte identifier
)
```
