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

# Crear Wallet

> POST /v1/wallets

Crea una nueva wallet para un usuario de tu aplicación.

## Endpoint

```
POST https://api.pan.tech/v1/wallets
```

## Autenticación

<Note>
  Solo API Key. X402 no soportado para operaciones de escritura.
</Note>

## Request

### Headers

| Header        | Valor               |
| ------------- | ------------------- |
| Authorization | `Bearer pan_sk_...` |
| Content-Type  | `application/json`  |

### Body

```json theme={null}
{
  "userId": "usuario_123",
  "chainType": "ethereum",
  "email": "usuario@ejemplo.com",
  "metadata": {
    "nombre": "Juan Perez",
    "plan": "premium"
  }
}
```

### Parámetros

| Campo       | Tipo   | Requerido | Descripción                    |
| ----------- | ------ | --------- | ------------------------------ |
| `userId`    | string | Si        | ID único del usuario en tu app |
| `chainType` | string | No        | `ethereum` (default) o `tron`  |
| `email`     | string | No        | Email para notificaciones      |
| `metadata`  | object | No        | Datos adicionales (JSON)       |

## Response

### 201 Created

```json theme={null}
{
  "id": "pan_wallet_a1b2c3d4e5f6",
  "userId": "usuario_123",
  "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
  "chainType": "ethereum",
  "chains": [
    "ethereum",
    "ethereum-sepolia",
    "arbitrum",
    "arbitrum-sepolia",
    "base",
    "base-sepolia"
  ],
  "metadata": {
    "nombre": "Juan Perez",
    "plan": "premium"
  },
  "createdAt": "2024-01-15T10:30:00Z"
}
```

### Errores

| Código | Error                   | Descripción                |
| ------ | ----------------------- | -------------------------- |
| 400    | INVALID\_REQUEST        | Body inválido              |
| 401    | UNAUTHORIZED            | API key inválida           |
| 403    | WALLET\_LIMIT\_EXCEEDED | Límite de wallets del plan |
| 409    | WALLET\_ALREADY\_EXISTS | Usuario ya tiene wallet    |

## Ejemplos

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.pan.tech/v1/wallets \
    -H "Authorization: Bearer $PAN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "userId": "usuario_123",
      "metadata": {"nombre": "Juan Perez"}
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.pan.tech/v1/wallets', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.PAN_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      userId: 'usuario_123',
      metadata: { nombre: 'Juan Perez' }
    })
  });

  const wallet = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.pan.tech/v1/wallets',
      headers={
          'Authorization': f'Bearer {API_KEY}',
          'Content-Type': 'application/json'
      },
      json={
          'userId': 'usuario_123',
          'metadata': {'nombre': 'Juan Perez'}
      }
  )

  wallet = response.json()
  ```

  ```typescript SDK theme={null}
  const wallet = await pan.wallet.create({
    userId: 'usuario_123',
    metadata: { nombre: 'Juan Perez' }
  });
  ```
</CodeGroup>
