# KycApi

{% hint style="info" %}
This class implements [`BasicApi`](broken://pages/xlI4X77sh7TTM0rFdmRn).
{% endhint %}

{% hint style="warning" %}
You need [`kyc:read`](/identity/scopes-and-claims.md#kyc) or [`kyc:write`](/identity/scopes-and-claims.md#kyc) to access some parts of this API.
{% endhint %}

{% hint style="info" %}
This is a JavaScript implementation of the [KYC API](/reference/kyc-api.md).
{% endhint %}

{% hint style="info" %}
For ease of use we recommend using the [`ApplicationReference`](broken://pages/EPAyUPEf3e2NaRcAMaM0) object for interaction instead.
{% endhint %}

## Interfaces

### `KycStatusResponse`

```typescript
interface KycStatusResponse {
    complete: boolean,
    success: boolean,
    distance: number,
    createdAt: string,
    completedAt: string,
    webhook: string|null
}
```

### `KycDetailsResponse`

```typescript
interface KycDetailsResponse {
    idCardPictureUrl: string,
    selfiePictureUrl: string
}
```

## Methods

### `constructor(app, endpoint)`

Create a KYC API object.

* `app` should be an instance of the [`ApplicationReference`](broken://pages/EPAyUPEf3e2NaRcAMaM0) object.
* `endpoint` should be the Vulos Identity endpoint.

```javascript
const kycApi = new KycApi(appRef, endpoint)
```

### `async status(kycId)`

Get the status of a KYC verification instance by ID.

The result implements the [`KycStatusResponse`](#undefined) interface.

{% hint style="info" %}
This method's response has the `kyc:status` [cache](/reference/identity-javascript-sdk/the-base-package/cache.md#addpolicy-key-lifespan) prefix.
{% endhint %}

```javascript
const status = await kycApi.status(kycId)
```

### `async list(page, pageSize)`

Get a list of all the KYC verification instance IDs.

* `page` defaults to 0;
* `pageSize` defaults to 10;

The result is an array of KYC Instance IDs.

{% hint style="info" %}
This method's response has the `kyc:list` [cache](/reference/identity-javascript-sdk/the-base-package/cache.md#addpolicy-key-lifespan) prefix.
{% endhint %}

```javascript
const first10 = await kycApi.list()
```

### `async upload(selfiePicture, idCardPicture)`

Upload KYC verification details for later use, both of the arguments must be objects that inherit from `Blob` (like `File`).

The result implements the [`KycDetailsResponse`](#undefined) interface.

```javascript
const details = await kycApi.upload(selfieFile, idCardFile);
```

### `async create(selfiePicture, idCardPicture, webhook)`

Make a KYC verification request, the first two arguments may be objects that inherit from `Blob` or URLs returned by the [`upload()`](#async-upload-selfiepicture-idcardpicture) method, the `webhook` argument is optional.

The result is the ID of the KYC Instance that was created.

{% hint style="warning" %}
The webhook must be in the application's redirect URLs otherwise the server will return the "Bad Request" response.
{% endhint %}

```javascript
const kycId = await kycApi.create(selfieFile, idCardFile, 'http://example.com/webhook');
```


---

# 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://dev.vulos.io/reference/identity-javascript-sdk/the-base-package/kyc/kycapi.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.
