# Wallet Create

This API allows clients to create or retrieve a wallet for a user. The client supplies an email address or phone number, and receive a wallet address (and anonymized wallet ID) in response. If a wallet has already been created for the user, the wallet address and anonymized wallet ID will be returned. If a wallet already exists for the user, the wallet is looked up and the address and ID are returned.

## Endpoint Details

| Description | Data                                                                                              |
| ----------- | ------------------------------------------------------------------------------------------------- |
| API Name    | [postWalletCreate](https://sandbox.api.labs.zelus.io/docs/api-json#/Wallet/post_v1_wallet_create) |
| HTTP Method | POST                                                                                              |
| URL         | `/v1/wallet/create`                                                                               |

{% tabs %}
{% tab title="Request" %}

#### Headers

| Key          | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| x-api-key    | API\_KEY           |

#### Query Parameters

| Parameter         | Type    | Description                                                                                        |
| ----------------- | ------- | -------------------------------------------------------------------------------------------------- |
| **ignoreAddress** | boolean | when set to `true`, prevents the return of the wallet address                                      |
| **email**         | string  | The email of the user for claim. Note: Either `email` or `phone` should be present in the request. |
| **phone**         | string  | The phone number of the user. Note: Either `email` or `phone` should be present in the request.    |

#### **Payload Example:**

1. By Email:

```json
{
  "ignoreAddress": false,
  "email": "email@example.com",
}
```

2. By Mobile phone

```json
{
  "ignoreAddress": false,
  "phone": "+12223334444"
}
```

{% endtab %}

{% tab title="Response" %}
The response will be a JSON object containing the wallet address and the wallet ID or error object in case of error

#### Successful Response

```json
{
  "result": {
    "walletId": "wallet_60afcf25-2c1f-4b90-9fea-6174fd416040",
    "walletAddress": "0x0097f04ac9b2af2fb40c2c30a65023a78eaff5d6"
  }
}
```

#### Error Response

```json
{
  "error": {
    "code": "400"
    "message": "Validation error: \"value\" must contain at least one of [email, phone]",
  }
}
```

{% endtab %}
{% endtabs %}

## **Examples**

{% tabs %}
{% tab title="CURL" %}

```bash
curl -X POST "https://sandbox.api.labs.zelus.io/v1/wallet/create" \
-H "x-api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"ignoreAddress": false, "email": "email@example.com", "phone": "+12223334444"}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://sandbox.api.labs.zelus.io/v1/wallet/create"
headers = {
    "x-api-key": "<YOUR_API_KEY>",
    "Content-Type": "application/json"
}
data = {
    "ignoreAddress": False,
    "email": "email@example.com",
    "phone": "+12223334444"
}

response = requests.post(url, headers=headers, json=data)
result = response.json()

wallet_address = result.get("walletAddress")
wallet_id = result.get("walletId")
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const url = "https://sandbox.api.labs.zelus.io/v1/wallet/create";
const headers = {
    "x-api-key": "<YOUR_API_KEY>",
    "Content-Type": "application/json"
};
const data = {
    ignoreAddress: false,
    email: "email@example.com",
    phone: "+12223334444"
};

axios.post(url, data, { headers: headers })
    .then(response => {
        const walletAddress = response.data.walletAddress;
        const walletId = response.data.walletId;
    })
    .catch(error => {
        console.error("Error during wallet creation:", error);
    });
```

{% endtab %}
{% endtabs %}

## Notes

1. Validation:
   * Ensure you have an active API key.
   * Either `email` or `phone` should be present in the request, otherwise, a validation error will be returned.
2. If the wallet already exists for the provided email address or phone number, the previously created wallet ID will be returned.
3. If the `ignoreAddress` parameter is set to `true`, the wallet address won't be returned.
4. If the `ignoreAddress` parameter is omitted or set to `false`, both the wallet ID and the wallet address will be returned.


---

# Agent Instructions: 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.labs.zelus.io/zelus-labs-api/reference/wallet/postwalletcreate.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.
