> For the complete documentation index, see [llms.txt](https://docs.opinion.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opinion.trade/developer-guide/opinion-clob-typescript-sdk/builder-mode/create-user.md).

# Create User

> Register a new user sub-account under your builder and get their API key.

## Usage

```typescript
import { BuilderClient } from '@opinion-labs/opinion-clob-sdk';

const builder = new BuilderClient({
  host: 'https://openapi.opinion.trade/openapi',
  builderApiKey: 'YOUR_BUILDER_KEY',
  chainId: 56,
});

const result = await builder.createUser('0xUserWalletAddress...');

console.log(result.walletAddress);    // User's login wallet address
console.log(result.multiSigWallet);   // User's Gnosis Safe wallet address
console.log(result.apikey);           // User's API key - SAVE THIS!
console.log(result.builderName);      // Builder name
console.log(result.enableTrading);    // Whether trading is enabled
```

## Parameters

| Parameter       | Type   | Required | Description                             |
| --------------- | ------ | -------- | --------------------------------------- |
| `walletAddress` | string | Yes      | User's EOA wallet address (0x-prefixed) |

## Response

```typescript
interface UserInfo {
  apikey: string;              // API key (only returned during creation)
  walletAddress: string;       // User's login wallet address
  multiSigWallet: string;     // User's Gnosis Safe wallet address
  builderName: string;        // Builder name
  walletCreationTxHash?: string; // Safe creation transaction hash
  enableTrading: boolean;      // Whether trading approvals are set up
}
```

## Notes

* The API key is returned **only once** during creation. Store it securely in your database.
* The Gnosis Safe wallet is created asynchronously (1-10 minutes). Poll `getUser()` until `multiSigWallet` is non-empty.
* If the user already exists, the API will return an error. Use `getUser()` to retrieve existing user info.

### Polling for Safe Wallet

```typescript
// Poll until Safe wallet is ready
let safeAddress = result.multiSigWallet;
while (!safeAddress) {
  await new Promise((r) => setTimeout(r, 30_000)); // Wait 30s
  const user = await builder.getUser('0xUserWalletAddress...');
  safeAddress = user.multiSigWallet;
}
console.log('Safe wallet ready:', safeAddress);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.opinion.trade/developer-guide/opinion-clob-typescript-sdk/builder-mode/create-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
