# Create a session (via workflows)

### URL

<mark style="color:green;">**POST**</mark> `https://api.complycube.com/v1/flow/sessions`

Creates a session.

{% hint style="info" %}
This enables you to create a session using workflows, which is the **recommended integration approach**.
{% endhint %}

### Headers

<table><thead><tr><th width="277">Name</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>Content-Type</code><mark style="color:red;">*</mark></td><td>string</td><td>The content-type must always be set to <code>application/json</code>.</td></tr><tr><td><code>Authorization</code><mark style="color:red;">*</mark></td><td>string</td><td>The API <code>live</code> or <code>test</code> key</td></tr></tbody></table>

### Body

<table><thead><tr><th width="278">Name</th><th width="113">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>clientId</code><mark style="color:red;">*</mark></td><td>string</td><td>The ID of the client.</td></tr><tr><td><code>workflowTemplateId</code><mark style="color:red;">*</mark></td><td>string</td><td>The ID of the workflow template. This automatically invokes its <strong>active version</strong>. If no version is active, the request will fail.</td></tr><tr><td><code>successUrl</code><mark style="color:red;">*</mark></td><td>array</td><td>The URL to which ComplyCube should send clients when KYC and identity verification is complete.</td></tr><tr><td><code>cancelUrl</code><mark style="color:red;">*</mark></td><td>array</td><td>The URL the client will be directed to if they decide to cancel and return to your website.</td></tr><tr><td><code>theme</code></td><td>string</td><td><p>The UI theme to apply. Valid values include:</p><ol><li><code>light</code> (default)</li><li><code>dark</code></li></ol></td></tr><tr><td><code>supportEmail</code></td><td>string</td><td>The support email address that appears on the UI for your clients. When not provided, no email address will be displayed.</td></tr><tr><td><code>shortUrl</code></td><td>boolean</td><td><p>Indicates whether the generated URL should be shortened. Short URLs are useful for specific use cases, such as sending links via SMS. When not provided, this defaults to <strong>false</strong>.</p><p>It is recommended to keep the default unless you have a specific need for a short URL.</p></td></tr></tbody></table>

### 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_request = {   
        'clientId': 'CLIENT_ID', 
        'workflowTemplateId': 'WORKFLOW_TEMPLATE_ID',
        'successUrl':'https://wwww.yoursite.com/success',
        'cancelUrl':'https://wwww.yoursite.com/cancel'
        }
   
session = ccapi.flow.create(**flow_request)
```

{% endtab %}

{% tab title="PHP" %}

```php
use ComplyCube\ComplyCubeClient;

$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');
$fsess = $ccapi->flow()->createSession(
                           ['clientId' => 'CLIENT_ID', 
                           'workflowTemplateId' => 'WORKFLOW_TEMPLATE_ID',
                           '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 = "CLIENT_ID",
  workflowTemplateId = "WORKFLOW_TEMPLATE_ID",
  successUrl = "https://www.yoursite.com/success",
  cancelUrl = "https://www.yoursite.com/cancel"
};

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

{% endtab %}
{% endtabs %}

### Example response

{% tabs %}
{% tab title="Success (200)" %}
{% code overflow="wrap" %}

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

{% endcode %}
{% endtab %}

{% tab title="Invalid Request (400)" %}

```json
{
    "type": "invalid_request",
    "message": "'clientId' is invalid",
    "param": "clientId"
}
```

{% endtab %}
{% endtabs %}


---

# 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.complycube.com/documentation/api-reference/other-resources/hosted-solution/create-a-session.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.
