# Hosted Solution Guide

## Overview

**ComplyCube Flow** is our secure, fully hosted KYC and identity verification solution. It provides a customizable, branded page that allows you to verify customers quickly with minimal code.

When you initiate a Flow session, a unique ComplyCube URL is generated. Redirect your customers to this page to collect consent and complete the verification process. Once finished, they are redirected back to your chosen URL.

<figure><img src="https://2950143584-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsw26JqCBnT6AEIbxAYyk%2Fuploads%2Fn1mltFwc0jCsIluJaK20%2Fhosted_solution.png?alt=media&#x26;token=cdc837b8-5a3f-457b-a6e9-90536c816665" alt=""><figcaption><p>ComplyCube Hosted Solution</p></figcaption></figure>

Flow makes it simple to deliver a first-class KYC experience:

* **Fast to integrate**: Go live quickly with minimal engineering effort.
* **UX-optimized**: Guided, conversion-focused flows with built-in error handling.
* **Mobile ready**: Fully responsive design that works seamlessly across devices.
* **International**: Multi-language support for global coverage.
* **Customizable**: Configure verifications, stages, colors, and branding (logo and text).
* **Data-compliant**: Simplified compliance, as sensitive PII never resides on your infrastructure.

## Interactive demo

{% @arcade/embed flowId="DQYWw1OnvTXJpuguEsVp" url="<https://app.arcade.software/share/DQYWw1OnvTXJpuguEsVp>" fullWidth="false" %}

## Integration steps

The steps below demonstrate how to add the Hosted Solution to your web application.

{% stepper %}
{% step %}

#### **Create a client**

Every verification flow starts with a **client** (i.e. customer). Use the API to [create the client](https://app.gitbook.com/s/kAhgmUKSf8CFUFVL3GEe/core-resources/clients/create-a-client).

**Example request**

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

```bash
curl -X POST https://api.complycube.com/v1/clients \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "type": "person",
          "email": "john.doe@example.com",
          "personDetails":{
               "firstName": "John",
               "lastName" :"Doe"
          }
        }'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const { ComplyCube } = require("@complycube/api");

const complycube = new ComplyCube({ apiKey: "<YOUR_API_KEY>" });

const client = await complycube.client.create({
  type: "person",
  email: "john.doe@example.com",
  personDetails: {
    firstName: "John",
    lastName: "Doe"
  }
});
```

{% endtab %}

{% tab title="Python" %}

```python
from complycube import ComplyCubeClient
cc_api = ComplyCubeClient(api_key='<YOUR_API_KEY>')

new_client = {
    'type':'person',
    'email':'john.doe@example.com',
    'personDetails': {
        'firstName':'John',
        'lastName':'Doe'
    }
}

client = cc_api.clients.create(**new_client)
```

{% endtab %}

{% tab title="PHP" %}

```php
use ComplyCube\ComplyCubeClient;

$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');

$result = $ccapi->clients()->create([
    'type' => 'person',
    'email' => 'john@doe.com',
    'personDetails' => [
        'firstName' => 'John',
        'lastName' => 'Doe'
    ]
]);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using ComplyCube.Net;
using ComplyCube.Net.Resources.Clients;

var clientApi = new ClientApi(new ComplyCubeClient("<YOUR_API_KEY>"));
var newClient = new ClientRequest {
  type = "person",
  email = "john@doe.com",
  personDetails = new PersonDetails {
    firstName = "John",
    lastName = "Doe"
  }
}

var client = await clientApi.CreateAsync(newclientRequest);
```

{% endtab %}
{% endtabs %}

The response will contain an `id` (the Client ID). It is required for the next step.
{% endstep %}

{% step %}

#### Generate a hosted page session

A **hosted page session** creates a unique ComplyCube URL that you can use to redirect your customer to complete their identity verification.

This solution can be integrated in two ways: through [workflows](https://app.gitbook.com/s/KyFKMqftsmT6qln9zo5y/compliance-studio/workflows) for complete verification journeys, or with **check-driven integration** for fine-grained control.

Sample snippets for both approaches are provided below:

{% tabs %}
{% tab title="Workflow Integration (Recommended)" %}
**How it works**

Use workflows to run complete KYC journeys with minimal code.

For a workflow integration, you need to provide a **workflow template ID**. You can copy this from your [workflow templates page](https://portal.complycube.com/workflowTemplates) in the Portal. The Hosted Solution will then run the **active** version of the selected workflow automatically.

**Example request**

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

```bash
curl -X POST https://api.complycube.com/v1/flow/sessions \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "clientId":"CLIENT_ID",
          "workflowTemplateId": "WORKFLOW_TEMPLATE_ID",
          "successUrl": "https://www.yoursite.com/success",
          "cancelUrl": "https://www.yoursite.com/cancel"
        }'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const { ComplyCube } = require("@complycube/api");

const complycube = new ComplyCube({ apiKey: "<YOUR_API_KEY>" });

const session = await complycube.flow.createSession("CLIENT_ID", {
    workflowTemplateId: "WORKFLOW_TEMPLATE_ID",
    successUrl: "https://www.yoursite.com/success",
    cancelUrl: "https://www.yoursite.com/cancel"
});
```

{% endtab %}

{% tab title="Python" %}

```python
from complycube import ComplyCubeClient
cc_api = ComplyCubeClient(api_key='<YOUR_API_KEY>')

flow_session = {
    'clientId': client.id,
    'workflowTemplateId': 'WORKFLOW_TEMPLATE_ID',
    'successUrl':'https://wwww.yoursite.com/success',
    'cancelUrl':'https://wwww.yoursite.com/cancel'
}

session = cc_api.flow.create(**flow_session)
```

{% endtab %}

{% tab title="PHP" %}

```php
use ComplyCube\ComplyCubeClient;

$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');
$session = $ccapi->flow()->createSession([
    'clientId' => $clientId,
    'workflowTemplateId' => 'WORKFLOW_TEMPLATE_ID',
    'successUrl' => 'https://www.yoursite.com/success',
    'cancelUrl' => 'https://www.yoursite.com/cancel'
]);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using ComplyCube.Net;
using ComplyCube.Net.Resources.FlowSessions;

var fSession = new FlowSessionApi(new ComplyCubeClient("<YOUR_API_KEY>"));

var flowSession = new FlowSessionRequest {
  clientId = aClient.id,
  workflowTemplateId = "WORKFLOW_TEMPLATE_ID",
  successUrl = "http://complycube.com",
  cancelUrl = "http://complycube.com"
};

var result = fSession.CreateAsync(flowSession).Result;
```

{% endtab %}
{% endtabs %}

**Example response**

{% code overflow="wrap" %}

```javascript
{
    "redirectUrl": "https://id.complycube.com/test_ODdkNjhiOTU0MzY4YmE5NjRmMDMyY2E5MWYwZjgxNjMzZTcyMWJmNzU2YjZmNDQ4NmFjMTU0ZGZhYTU5MmNhY2NiNjI3ZDE4YWJkYmU2M2M3ZWYzZTlmM2M3MzgxMmM3NzZhMjVlYmQyNDI0ODdkOWQ3M2JiMjkxZTYxNzdhYmExMGEzOGRhYmM2OTIwMjgyYmEzZGY3ZDY0NWZhMjcwN2RlMTFkOTcxZWNhOWI2Zjg0NjllZGNkODVjYzMzMDA5YjdlMWY5OGIwMmZjY2UzNGI2YTMxOGQxNGZmNGFhYjczNzU0YmYwMjFkMzU1M2FjMjQ4ZDQ2ZjJjZTY4YWY0MzIxNjVlMDRjOTIyYTExMTlmMWU3YTYwMDY1NGJmYWM0NTA2MDE5NTg5NTkxYzA4MzYyYTUyM2I0NDM4OGExNWIyMTIzYTBhNDc0NDA4NWM2ZTQwMmNjMGVjMTk2YW"
}
```

{% endcode %}
{% endtab %}

{% tab title="Check-Driven Integration" %}
**How it works**

Run specific verification checks directly for finer control.

For a check-driven integration, you specify one or more check types. The Hosted Solution will create a session that runs only the selected checks.

**Example request**

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

```bash
curl -X POST https://api.complycube.com/v1/flow/sessions \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "clientId":"CLIENT_ID",
          "checkTypes": ["extensive_screening_check", "identity_check", "document_check"],
          "successUrl": "https://www.yoursite.com/success",
          "cancelUrl": "https://www.yoursite.com/cancel"
        }'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const { ComplyCube } = require("@complycube/api");

const complycube = new ComplyCube({ apiKey: "<YOUR_API_KEY>" });

const session = await complycube.flow.createSession("CLIENT_ID", {
    checkTypes: [
      "extensive_screening_check",
      "identity_check",
      "document_check"
    ],
    successUrl: "https://www.yoursite.com/success",
    cancelUrl: "https://www.yoursite.com/cancel",
    theme: "light"
});
```

{% endtab %}

{% tab title="Python" %}

```python
from complycube import ComplyCubeClient
cc_api = ComplyCubeClient(api_key='<YOUR_API_KEY>')

flow_session = {
    'clientId': client.id,
    'checkTypes':[
        'extensive_screening_check',
        'identity_check',
        'document_check'
    ],
    'successUrl':'https://wwww.yoursite.com/success',
    'cancelUrl':'https://wwww.yoursite.com/cancel',
    'theme': 'light'
}

session = cc_api.flow.create(**flow_session)
```

{% endtab %}

{% tab title="PHP" %}

```php
use ComplyCube\ComplyCubeClient;

$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');
$session = $ccapi->flow()->createSession([
    'clientId' => $clientId,
    'checkTypes' => [
        'extensive_screening_check',
        'identity_check',
        'document_check'
    ],
    'successUrl' => 'https://www.yoursite.com/success',
    'cancelUrl' => 'https://www.yoursite.com/cancel',
    'theme' => 'light'
]);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using ComplyCube.Net;
using ComplyCube.Net.Resources.FlowSessions;

var fSession = new FlowSessionApi(new ComplyCubeClient("<YOUR_API_KEY>"));

var flowSession = new FlowSessionRequest {
  clientId = aClient.id,
  checkTypes = new string[] {
    "extensive_screening_check",
    "identity_check",
    "document_check"
  },
  successUrl = "http://complycube.com",
  cancelUrl = "http://complycube.com"
};

var result = fSession.CreateAsync(flowSession).Result;
```

{% endtab %}
{% endtabs %}

**Example response**

{% code overflow="wrap" %}

```javascript
{
    "redirectUrl": "https://flow.complycube.com/test_ODdkNjhiOTU0MzY4YmE5NjRmMDMyY2E5MWYwZjgxNjMzZTcyMWJmNzU2YjZmNDQ4NmFjMTU0ZGZhYTU5MmNhY2NiNjI3ZDE4YWJkYmU2M2M3ZWYzZTlmM2M3MzgxMmM3NzZhMjVlYmQyNDI0ODdkOWQ3M2JiMjkxZTYxNzdhYmExMGEzOGRhYmM2OTIwMjgyYmEzZGY3ZDY0NWZhMjcwN2RlMTFkOTcxZWNhOWI2Zjg0NjllZGNkODVjYzMzMDA5YjdlMWY5OGIwMmZjY2UzNGI2YTMxOGQxNGZmNGFhYjczNzU0YmYwMjFkMzU1M2FjMjQ4ZDQ2ZjJjZTY4YWY0MzIxNjVlMDRjOTIyYTExMTlmMWU3YTYwMDY1NGJmYWM0NTA2MDE5NTg5NTkxYzA4MzYyYTUyM2I0NDM4OGExNWIyMTIzYTBhNDc0NDA4NWM2ZTQwMmNjMGVjMTk2YW?theme=light"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

#### Redirect the customer to the URL

Redirect your customer to the `redirectUrl` generated in the previous step.

Once the customer has provided all their details on the hosted solution:

1. ComplyCube will perform all the relevant checks .
2. The customer will be redirected back to the specified `successUrl`.

You can retrieve the outcomes and breakdown of the checks via the API or Web Portal. If you have [set up webhooks](https://docs.complycube.com/documentation/integration-resources/webhooks), a notification will be sent upon completing each check.
{% endstep %}
{% endstepper %}

## Next steps

Follow the full [Hosted Solution integration](https://app.gitbook.com/s/lv7UhJvTbxeq4s3KwQpn/web-integrations/hosted-solution-quick-guide) guide to explore its features and **customization** options.
