# KardiaID Service API

### **Get request token**

User requests access-token using username and password to KardiaID Service, and KardiaID Service return access-token information

&#x20;Method: POST

&#x20;Endpoint: /oauth2/token/

&#x20;Headers: None

&#x20;Body:

| **Field**      | **Type** | **Description**                                                  |
| -------------- | -------- | ---------------------------------------------------------------- |
| client\_id     | string   | Client ID received from KardiaID Service                         |
| client\_secret | string   | Client secret received from KardiaID Service                     |
| grant\_type    | string   | Credential grant type. For this phase, should be set to password |
| username       | string   | username                                                         |
| password       | string   | password                                                         |

&#x20;Sample response

```
{
	"access_token": "7ct9AUUCOnjdj577Iy2Ziu6pjWwLfl",
	"expires_in": 36000,
	"token_type": "Bearer",
	"scope": "read write",
	"refresh_token": "vUzXEA1WTvL7eAf9MAGfzFgXqyX6Gc"
}

```

### **Refresh token**

User needs to refresh access-token and KardiaID Service return with new fresh access-token

&#x20;Method: POST

&#x20;Endpoint: /oauth2/token/

&#x20;Headers: None

&#x20;Body:

| **Field**      | **Type** | **Description**                                                           |
| -------------- | -------- | ------------------------------------------------------------------------- |
| client\_id     | string   | Client ID received from KardiaID Service                                  |
| client\_secret | string   | Client secret received from KardiaID Service                              |
| grant\_type    | string   | Credential grant type. To refresh token, set this field to refresh\_token |
| refresh\_token | string   | User’s refresh token received from API Get request token                  |

&#x20;Sample response

```
{
	"access_token": "Eo4GmFh45V3Yk6AcChVrJtOU08AfpQ",
	"expires_in": 36000,
	"token_type": "Bearer",
	"scope": "read write",
	"refresh_token": "tcJLrF0alvLejLdoh9cCLSVAvlDg3a"
}

```

### **Get user data**

Retrieving user’s information

&#x20;Method: GET

&#x20;Endpoint: /user/me/

&#x20;Headers:

| **Field**     | **Type**                      | **Description**                 |
| ------------- | ----------------------------- | ------------------------------- |
| Authorization | String (basic authentication) | Value should be Bearer \<TOKEN> |

Body: None

&#x20;Sample response

```
{
	"username": "your_username",
	"email": "your_email@gmail.com",
	"first_name": "",
	"last_name": "",
	"date_joined": "2020-09-28T06:00:23.745789Z",
	"last_login": "2020-09-28T06:00:37.622188Z",
	"wallet": {
		"balance": 0.0,
		"wallet_address": "0xc7849145419ee7d0f600Ae95A1C630FFB5287AFB"
	}
}
```

### **Register**

User enters information during the registration process

&#x20;Method: POST

Endpoint: /user/register/

Headers: None

Body:

| **Field**   | **Type** | **Description**   |
| ----------- | -------- | ----------------- |
| username    | string   | username          |
| email       | string   | User’s email      |
| password    | string   | User’s password   |
| first\_name | string   | User’s first name |
| last\_name  | string   | User’s last name  |

&#x20;Sample response

```
{
	"success":  [
		"Registration successful"
	]
}

```

&#x20;

### **Introspec token**

Checks the validity of the access token, gets back user information and expiration date.

&#x20;Method: GET

&#x20;Endpoint: /oauth2/introspec/

&#x20;Headers: None

Param:

| **Field** | **Type** | **Description**            |
| --------- | -------- | -------------------------- |
| token     | string   | Access token to intro-spec |

&#x20;Sample response

```
{
	"active":  true,
	"scope":  "read write",
	"exp":  1601476131,
	"client_id":  "lJmS5wt6L0m9cU9Fd2zo37VOWg7dTf0YAiDWbCSS",
	"username":  "admin"
}


```

&#x20;

### **My wallet**

Return mainnet wallet address.

Method: GET

&#x20;Endpoint: /user/my-wallet

&#x20;Headers:

| **Field**     | **Type**                      | **Description**                 |
| ------------- | ----------------------------- | ------------------------------- |
| Authorization | String (basic authentication) | Value should be Bearer \<TOKEN> |

Body: None

Response:

| **Field**        | **Type**                   | **Description**                                   |
| ---------------- | -------------------------- | ------------------------------------------------- |
| Wallet\_address  | Address string             | Wallet address on mainnet                         |
| Balance          | Balance in string          | Wallet balance in small unit HYDRO (KAI \* 10^18) |
| Balance\_display | KAI balance in float point | KAI balance for easier display                    |
| Nonce            | Account nonce in integer   | Account nonce to send transactions                |

&#x20;Sample response

```
{
  "success": 
  [{
    “wallet_address”: "0xA158A517C587fF706B0c639388B1722b78538FDE", 
    “balance”: "720308601624999676960",
    “balance_display”: 720.3086016249997,
    “Nonce”: 11
  }]
}
```

### **Send transaction**

Send transaction to Kardia Mainnet, the endpoint requests Trusted Client Authentication. Transaction is signed with a user private key on KardiaID Service and pushed to Kardia mainnet.

Raw\_tx contains fields of Kardia mainnet transactions, in JSON format.

&#x20;Method: POST

&#x20;Endpoint: /user/send-transaction

&#x20;Headers:

| **Field**     | **Type**                      | **Description**                 |
| ------------- | ----------------------------- | ------------------------------- |
| Authorization | String (basic authentication) | Value should be Bearer \<TOKEN> |

Sample request:

```
raw_tx = {
 "to": "0x772b965f2466A23370dB463d4E4fb25d84f1d72F",
 "value": 100000000000,
 "gas": 29000,
 "gasPrice": 1000000,
 "nonce": 12
}
```

&#x20;Response:

Response contains the transaction hash if success or error message.

Sample response:

```
{
  "success": ["0xd5cf583b8d0fa47d8b320b14f63caf759f0cd1b6c3a297e0db837b9435f8a550"]
}


```

### Password Reset

KardiaID Service sends an email password reset to user which contains password reset token.

Method: POST

Endpoint: /user/resetpassword/

Body

| Field | Type   | Description |
| ----- | ------ | ----------- |
| email | string | User email  |

### Password Reset Confirm

Reset user password to new provided password and emailed token.

Method: POST

Endpoint: /user/resetpassword/confirm/

Body:

| Field    | String | Description               |
| -------- | ------ | ------------------------- |
| password | string | new password              |
| token    | string | provided token from email |


---

# 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.kardiachain.io/docs/archived-docs/kardiaid/api.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.
