# KYC Details

## Get Documents

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/kyc/documents/`

This API endpoint will return kyc document data with verify status.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

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

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "documents": {
            "<document_key>": {
                "type": "<doc_type>",
                "doc_type": "<doc_key>",
                "doc_name": "<doc_name>",
                "verify_status": <verify_status>,
                "note": "<note>",
                "data":"<base64_data>"
            },
            ...
        },
        "kyc_verify_status": <kyc_verify_status>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

## Upload Documents

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/kyc/documents/`

This API endpoint will upload user kyc documents.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name      | Type   | Description                                                                                                      |
| --------- | ------ | ---------------------------------------------------------------------------------------------------------------- |
| document  | string | ID Proof :- Allowed file formats includes: Documents(.PDF) and Images (.JPG, .PNG) and maximum size: 8MB.        |
| document1 | string | Utility Bills:- Allowed file formats includes: Documents(.PDF) and Images (.JPG, .PNG) and maximum size: 8MB.    |
| document2 | string | Account statement:-Allowed file formats includes: Documents(.PDF) and Images (.JPG, .PNG) and maximum size: 8MB. |

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

```
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'document': {
      'value': fs.createReadStream('<file_path>'),
      'options': {
        'filename': '<file_name>',
        'contentType': null
      }
    },
    'document1': {
      'value': fs.createReadStream('<file_path>'),
      'options': {
        'filename': '<file_name>'
        'contentType': null
      }
    },
    'document2': {
      'value': fs.createReadStream('<file_path>'),
      'options': {
        'filename': '<file_name>',
        'contentType': null
      }
    }
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('document'=> new CURLFILE('<file_path>'),'document1'=> new CURLFILE('<file_path>'),'document2'=> new CURLFILE('<file_path>')),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld                                             | Description                                                                                            |
| ----------- | ---------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| 401         | Request Failed   |                                                   | <p>Please upload all required KYC documents and submit the form.</p><p>Maximum upload size is 8MB.</p> |
| 400         | Validation Error | <p>document,</p><p>document1,</p><p>document2</p> | File type '\<file\_type>' is not allowed. Allowed types are: 'image/png, application/pdf, image/jpeg'. |

## Delete Document

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/user/kyc/documents/`

This API endpoint will delete a kyc document.

#### Query Parameters

| Name        | Type   | Description                                     |
| ----------- | ------ | ----------------------------------------------- |
| remove\_doc | string | Document key: document, document1 or document2. |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

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

```
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'apikey: apikey',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | FIeld       | Description                                                                                             |
| ----------- | ---------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |             | <p>Sorry! Some error occurred. You can not remove your document now.</p><p>KYC Documents not found.</p> |
| 400         | Validation Error | remove\_doc | <p>This field is required and it may not be blank.</p><p>Invalid document key.</p>                      |
