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

# Wallet Creation

> How to create a wallet using the Digital Asset Service Desk API

This section describes an end-to-end flow to create a wallet.

Here is an example :

#### Request

```shell theme={null}
curl --request POST 'https://hostname.zodia.io/v3/api/servicedesk/products'
--header 'company-identifier: ' \
--header 'submitter-id: ' \
--header 'request-identifier: ' \
--header 'request-timestamp: ' \
--header 'Content-Type: application/json' \
--header 'signature: ' \
--data-raw 
'{
  "products": [
  ],
  "productIds": [
    "0x0013"
  ],
  "serviceIds": [
    "0x0013-001"
  ],
  "serviceNames": [
  ],
  "requestTypes": [
  ]
}'

```

#### Response

`HTTP 200`

```json theme={null}
{
  "items": [
    {
      "product": "CUSTODY",
      "productId": "0x0013",
      "serviceId": "0x0013-001",
      "serviceName": "Custody Wallet Management",
      "requestType": "CREATE",
      "description": "Custody Wallet",
      "template": {
        "name": "Wallet_Name",
        "currency": "ETH | BTC | ...",
        "walletOwnerId": "Wallet_Beneficiary_ID"
      }
    }
  ]
}

```

The template object you see on the response above is what will be requested for any wallet creation.

The sample APIs calls below omit authentication information for simplicity, see more about [Signing requests](#section/Authentication/Signing-Requests).

### 1. Instruction to create a wallet

Create an `Ethereum` wallet with name `FUND123`

#### Request

```shell theme={null}
curl --request POST 'https://hostname.zodia.io/v3/api/servicedesk/create'
--header 'company-identifier: ' \
--header 'submitter-id: ' \
--header 'request-identifier: ' \
--header 'request-timestamp: ' \
--header 'Content-Type: application/json' \
--header 'signature: ' \
--data-raw 
'{
    "serviceId": "0x0013-001",
    "payload": {
        "name": "FUND123",
        "currency": "ETH",
        "currencyId": "eth-Seth"
    }
}'

```

#### Response

`HTTP 200`

```json theme={null}
{
  "requestId": "SERV-REQ-0RV7UQ2D56",
  "pluginDetail": {
    "entityId": "ZODCS-NOBENF-E3WB8MB4EI",
    "details": [
      {
        "name": "FUND123",
        "currency": "ETH",
        "currencyId": "eth-Seth",
        "isDeFi": false
      }
    ]
  }
}

```

### 2. Submit service request

Use the request ID obtained in the previous request to submit the instruction.

#### Request

```shell theme={null}
curl --request POST 'https://hostname.zodia.io/v3/api/servicedesk/submit' \
--header 'company-identifier: ' \
--header 'submitter-id: ' \
--header 'request-identifier: ' \
--header 'request-timestamp: ' \
--header 'Content-Type: application/json' \
--header 'signature: ' \
--data '{
  "requestId": "SERV-REQ-0RV7UQ2D56"
}'

```

#### Response

`HTTP 200`

### 3. Retrieve instruction to sign as maker

Retrieve the HSM instruction to be signed by the maker.
If you get empty response for this, it means that the service request is not ready to approve.

Possible reasons for getting empty response,

* Previous Submit request is still in progress, try again calling the pending API after few seconds.
* Or, Maybe the service request might have failed or timed-out

#### Request

```shell theme={null}
curl --request POST 'https://hostname.zodia.io/v3/api/servicedesk/pending' \
--header 'company-identifier: ' \
--header 'submitter-id: ' \
--header 'request-identifier: ' \
--header 'request-timestamp: ' \
--header 'Content-Type: application/json' \
--header 'signature: ' \
--data '{
  "requestId": "SERV-REQ-0RV7UQ2D56",
}'

```

#### Response

`HTTP 200`

```json theme={null}
{
  "request": {
    ...
  },
  "signature": "$$REPLACE$$"
}

```

### 4. Confirm instruction as maker

Sign the 'request' element with the **maker private key** and insert the resulting string in 'signature'. The signed instruction is submitted directly to the HSM.

#### Request

```shell theme={null}
curl --location 'https://hostname.zodia.io/v3/api/servicedesk/approve' \
--header 'company-identifier: ' \
--header 'submitter-id: ' \
--header 'request-identifier: ' \
--header 'request-timestamp: ' \
--header 'Content-Type: application/json' \
--header 'signature: ' \
--data '{
  "requestId": "SERV-REQ-0RV7UQ2D56",
  "request": {
    ...
  },
  "signature": "MEUCIQDqOsThmTIPlSyqPt2bWYC5FsahAxby/wUjOfdOpnATBgIgdszq9Gnbx8SyTYUcSjTW2OPmnB1a7PPxFO1ReKMWFo0="
}'

```

#### Response

`HTTP 200`

### 5. Retrieve instruction to sign as authoriser

#### Request

```shell theme={null}
curl --location 'https://hostname.zodia.io/v3/api/servicedesk/pending' \
--header 'company-identifier: ' \
--header 'submitter-id: authoriser@zodia.io' \
--header 'request-identifier: ' \
--header 'request-timestamp: ' \
--header 'Content-Type: application/json' \
--header 'signature: ' \
--data '{
  "requestId": "SERV-REQ-0RV7UQ2D56"
}'

```

#### Response

```json theme={null}
{
  "request": {
    ...,
    "type": "Approve|Reject"
  },
  "signature": "$$REPLACE$$"
}

```

### 6. Approve instruction as authoriser

To approve an instruction set `type` to `Approve`. To reject an instruction, set `type` to `Reject` and set a `rejectReason`.

#### Request

```shell theme={null}
curl --location 'https://hostname.zodia.io/v3/api/servicedesk/approve' \
--header 'submitter-id: authoriser@zodia.io' \
--header 'Content-Type: application/json' \
--data '{
  "requestId": "SERV-REQ-0RV7UQ2D56",
  "request": {
    ...,
    "type": "Approve"
  },
  "signature": "MEUCIQCP9Sqzh0jBj0WW++7oVwQyxpSTPfjhB2G7lNjjvom+LwIgcfU521JS3sUFVRHyUhjQGCgQbkb4P4IP/zzcGOxfUEA="
}'

```

#### Response

`HTTP 200`
