> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Initialize a client session

POST https://api.runtype.com/v1/client/init
Content-Type: application/json

Exchange a client token for a browser chat session. Validates the token + request `Origin`, resolves the target flow or agent, and returns the session id plus widget display config. Pass an existing `sessionId` for legacy resume, or a visitor-authorized `conversationId` returned by the history list to reopen a conversation across sessions or verified devices.

Reference: https://docs.runtype.com/api-reference/runtype-api/client-runtime/initialize-a-client-session

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Body (application/json)

This endpoint expects a Client Runtime_initializeAClientSession_Request.

- `Client Runtime_initializeAClientSession_Request`
  - ClientRuntimeInitializeAClientSessionRequest0
  - ClientRuntimeInitializeAClientSessionRequest1
  - ClientRuntimeInitializeAClientSessionRequest2
  - ClientRuntimeInitializeAClientSessionRequest3

## Response

### 200

Session created

- `config` (V1ClientInitPostResponsesContentApplicationJsonSchemaConfig, required) — Widget display config, read from the client token's stored config. Always returned, with null standing in for an unset welcome message or theme.
- `conversationId` (string, required) — The durable conversation record this session reads and writes. Returned by every successful branch — a fresh mint, a legacy `sessionId` replay, and a `conversationId` resume all report the record they landed on. Persist THIS rather than the session id: a session is short-lived, the conversation is what a returning browser reopens. It is not a credential; history access is still scoped by the visitor secret.
- `conversationRevision` (string, required) — Opaque change token for `conversationId` at the moment this session was created. Compare it for equality and nothing else — it is unordered and unparseable. It changes on every transcript mutation, including a display-projection finalization that deliberately leaves `updatedAt` untouched, so a second device or a reloaded tab can tell whether the transcript it holds is still current.
- `expiresAt` (string, required) — ISO-8601 session idle-expiry timestamp.
- `sessionId` (string, required) — The created (or resumed) client session ID.
- `app` (V1ClientInitPostResponsesContentApplicationJsonSchemaApp, optional) — Present instead of `flow` for a Runtype App token whose manifest declares record namespaces but no flows or agents. Exactly one of `flow` and `app` is returned.
- `durableRecovery` (V1ClientInitPostResponsesContentApplicationJsonSchemaDurableRecovery, optional) — Returned when the request negotiates `durableRecovery`. Older servers omit it; clients must then keep ordinary streaming behavior.
- `flow` (V1ClientInitPostResponsesContentApplicationJsonSchemaFlow, optional) — Resolved flow or agent for this session. Present on every response except the data-only Runtype App branch, which returns `app` instead. Retained for compatibility: `id` always carries the same value as the canonical top-level `targetId`, which new clients should read instead.
- `targetId` (string, optional) — The flow or agent this session executes against, resolved server-side. Canonical replacement for `flow.id`, and the exact key to pass as `targetId` when listing or deleting this conversation's history. Matches the value stored on the conversation record; an agent-only token resolves to its agent id. Absent only on the data-only Runtype App branch, which is not chat-capable.
- `visitor` (V1ClientInitPostResponsesContentApplicationJsonSchemaVisitor, optional) — The browser's anonymous visitor identity. Present when the request opts into visitor history (or supplies a visitor token, identity proof, or conversation id). Authenticates the `/client/conversations*` history routes, which the site-wide client token alone cannot reach.

## Errors

### 400 Bad Request Error

Validation error / flow required or not allowed

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 401 Unauthorized Error

Invalid client token, or an `identityProof` was supplied that failed verification (`invalid_identity_proof`, fail-closed: nothing is bound). Identity-proof rejections carry `errorDescription` naming the reason.

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of V1ClientInitPostResponsesContentApplicationJsonSchemaDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.
- `errorDescription` (string, optional) — Why the supplied `identityProof` was refused (for example an expired assertion, an unknown issuer, or a proof minted for another tenant). Diagnostic text for the embedding site, not a value to branch on.

### 403 Forbidden Error

Client token inactive or origin not allowed

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 404 Not Found Error

Referenced flow, agent, or visitor-authorized conversation not found, or a saved agent with no runnable live version (AGENT_NOT_DEPLOYED). Conversations outside the visitor scope also answer 404.

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### ClientRuntimeInitializeAClientSessionRequest0

- `token` (string, required)
- `durableRecovery` (boolean, optional)
- `flowId` (string, optional)
- `identityProof` (V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf0IdentityProof, optional) — Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.
- `visitorHistory` (boolean, optional)
- `visitorToken` (string, optional)

### ClientRuntimeInitializeAClientSessionRequest1

- `sessionId` (string, required)
- `token` (string, required)
- `durableRecovery` (boolean, optional)
- `flowId` (string, optional)
- `identityProof` (V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf1IdentityProof, optional) — Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.
- `visitorHistory` (boolean, optional)
- `visitorToken` (string, optional)

### ClientRuntimeInitializeAClientSessionRequest2

- `conversationId` (string, required)
- `token` (string, required)
- `visitorToken` (string, required)
- `durableRecovery` (boolean, optional)
- `flowId` (string, optional)
- `identityProof` (V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf2IdentityProof, optional) — Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.
- `visitorHistory` (boolean, optional)

### ClientRuntimeInitializeAClientSessionRequest3

- `conversationId` (string, required)
- `identityProof` (V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf3IdentityProof, required) — Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.
- `token` (string, required)
- `durableRecovery` (boolean, optional)
- `flowId` (string, optional)
- `visitorHistory` (boolean, optional)
- `visitorToken` (string, optional)

### V1ClientInitPostResponsesContentApplicationJsonSchemaConfig

Widget display config, read from the client token's stored config. Always returned, with null standing in for an unset welcome message or theme.

- `placeholder` (string, required) — Composer placeholder text. Defaults to 'Type your message...' when the client token sets none.
- `welcomeMessage` (string, required, nullable) — Opening message to render before the visitor's first turn. Null when the client token sets none.
- `theme` (any, optional) — Persona theme tokens stored on the client token, passed through verbatim. Null when unthemed.

### V1ClientInitPostResponsesContentApplicationJsonSchemaApp

Present instead of `flow` for a Runtype App token whose manifest declares record namespaces but no flows or agents. Exactly one of `flow` and `app` is returned.

- `id` (string, required) — Runtype App id backing this session.

### V1ClientInitPostResponsesContentApplicationJsonSchemaDurableRecovery

Returned when the request negotiates `durableRecovery`. Older servers omit it; clients must then keep ordinary streaming behavior.

- `enabled` (boolean, required) — Whether this initialized client-token session has the visitor credential and the durable-turns opt-in needed to use the durable execution reconnect route. The opt-in is the chat surface `behavior.durableTurns.enabled` for a surface-bound token and `config.durableTurns.enabled` for a standalone token. Reporting only: individual turns still self-identify as durable through replay cursors.
- `steer` (boolean, optional) — Whether the native durable target supports non-interrupting user-message delivery.

### V1ClientInitPostResponsesContentApplicationJsonSchemaFlow

Resolved flow or agent for this session. Present on every response except the data-only Runtype App branch, which returns `app` instead. Retained for compatibility: `id` always carries the same value as the canonical top-level `targetId`, which new clients should read instead.

- `id` (string, required) — Resolved flow or agent ID for this session.
- `description` (string, optional, nullable) — Flow description, null when the flow has none. Flow sessions only.
- `name` (string, optional) — Flow name. Present only for a flow session; the agent branch returns `id` alone because the widget does not render either field.

### V1ClientInitPostResponsesContentApplicationJsonSchemaVisitor

The browser's anonymous visitor identity. Present when the request opts into visitor history (or supplies a visitor token, identity proof, or conversation id). Authenticates the `/client/conversations*` history routes, which the site-wide client token alone cannot reach.

- `endUserId` (string, required, nullable) — The verified end user (`eu_…`) this browser is bound to, when an `identityProof` was admitted. Null while anonymous. Cross-device reads still require a fresh `identityProof` on that request; the stored binding alone remains exact-browser scoped.
- `expiresAt` (string, required) — ISO-8601 sliding idle-expiry for this visitor.
- `id` (string, required) — Durable anonymous visitor id (`cvis_…`).
- `identityStatus` (enum, required) — What the server did with a supplied `identityProof` on THIS request. `not_provided`: none was sent. `admitted`: it was verified and produced the end-user scope. `ignored`: one was sent but end-user admission is not enabled for this token owner, so it was never evaluated and the session is plain browser scope. Init still succeeds on `ignored` so chat degrades gracefully, but a widget must not offer verified cross-device history or a verified erase in that state (the history routes refuse such a request outright with 503 `identity_proof_not_admitted`). Reporting only: it confers no authority and carries no identity value.
  - Allowed values: `not_provided`, `admitted`, `ignored`
- `token` (string, optional) — The raw visitor secret (`cvt_…`). Returned ONLY when this init newly mints a visitor. Store it and send it back as `visitorToken` on the next init; it is unrecoverable afterwards. Reset itself returns no replacement; the next history-capable init mints one.

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

### V1ClientInitPostResponsesContentApplicationJsonSchemaDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf0IdentityProof

Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.

- string
- V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf0IdentityProof1

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf1IdentityProof

Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.

- string
- V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf1IdentityProof1

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf2IdentityProof

Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.

- string
- V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf2IdentityProof1

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf3IdentityProof

Customer-native auth proof for the Identity Exchange, as a bare token string or the `{ provider, token }` object `/v1/client/chat` accepts. The integration is selected by the verified issuer, not by `provider`: in the object form `provider` is a consistency hint (a hint that disagrees with the matched integration is rejected), and the bare string carries no hint. A Runtype-hosted `rt_eu_` token is sent as the bare string.

- string
- V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf3IdentityProof1

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf0IdentityProof1

Customer-native auth proof for the Identity Exchange. When present and the surface has a matching integration, the verified tenant/end-user replace any body-asserted tenant/endUser (which are never trusted for web-embedded callers). When Identity Exchange admission is disabled for the caller, the proof is accepted but ignored and confers no trust.

- `provider` (string, required)
- `token` (string, required)

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf1IdentityProof1

Customer-native auth proof for the Identity Exchange. When present and the surface has a matching integration, the verified tenant/end-user replace any body-asserted tenant/endUser (which are never trusted for web-embedded callers). When Identity Exchange admission is disabled for the caller, the proof is accepted but ignored and confers no trust.

- `provider` (string, required)
- `token` (string, required)

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf2IdentityProof1

Customer-native auth proof for the Identity Exchange. When present and the surface has a matching integration, the verified tenant/end-user replace any body-asserted tenant/endUser (which are never trusted for web-embedded callers). When Identity Exchange admission is disabled for the caller, the proof is accepted but ignored and confers no trust.

- `provider` (string, required)
- `token` (string, required)

### V1ClientInitPostRequestBodyContentApplicationJsonSchemaOneOf3IdentityProof1

Customer-native auth proof for the Identity Exchange. When present and the surface has a matching integration, the verified tenant/end-user replace any body-asserted tenant/endUser (which are never trusted for web-embedded callers). When Identity Exchange admission is disabled for the caller, the proof is accepted but ignored and confers no trust.

- `provider` (string, required)
- `token` (string, required)

## Examples

### Initialize with the token default flow

**Request**

```json
{
  "token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef"
}
```

**Response**

```json
{
  "config": {
    "placeholder": "string",
    "welcomeMessage": "string",
    "theme": null
  },
  "conversationId": "string",
  "conversationRevision": "string",
  "expiresAt": "string",
  "sessionId": "string",
  "app": {
    "id": "string"
  },
  "durableRecovery": {
    "enabled": true,
    "steer": true
  },
  "flow": {
    "id": "string",
    "description": "string",
    "name": "string"
  },
  "targetId": "string",
  "visitor": {
    "endUserId": "string",
    "expiresAt": "string",
    "id": "string",
    "identityStatus": "not_provided",
    "token": "string"
  }
}
```

**SDK Code**

```python Initialize with the token default flow
import requests

url = "https://api.runtype.com/v1/client/init"

payload = { "token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Initialize with the token default flow
const url = 'https://api.runtype.com/v1/client/init';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"token":"ct_live_flow01k7_0123456789abcdef0123456789abcdef"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Initialize with the token default flow
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/client/init"

	payload := strings.NewReader("{\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Initialize with the token default flow
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/client/init")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\"\n}"

response = http.request(request)
puts response.read_body
```

```java Initialize with the token default flow
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/client/init")
  .header("Content-Type", "application/json")
  .body("{\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\"\n}")
  .asString();
```

```php Initialize with the token default flow
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/client/init', [
  'body' => '{
  "token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Initialize with the token default flow
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/client/init");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Initialize with the token default flow
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/client/init")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Reopen a history conversation as a returning visitor

**Request**

```json
{
  "conversationId": "record_01jq8z6k2re9v0w1m3n5p7s9t2",
  "token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef",
  "visitorHistory": true,
  "visitorToken": "cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a"
}
```

**Response**

```json
{
  "config": {
    "placeholder": "string",
    "welcomeMessage": "string",
    "theme": null
  },
  "conversationId": "string",
  "conversationRevision": "string",
  "expiresAt": "string",
  "sessionId": "string",
  "app": {
    "id": "string"
  },
  "durableRecovery": {
    "enabled": true,
    "steer": true
  },
  "flow": {
    "id": "string",
    "description": "string",
    "name": "string"
  },
  "targetId": "string",
  "visitor": {
    "endUserId": "string",
    "expiresAt": "string",
    "id": "string",
    "identityStatus": "not_provided",
    "token": "string"
  }
}
```

**SDK Code**

```python Reopen a history conversation as a returning visitor
import requests

url = "https://api.runtype.com/v1/client/init"

payload = {
    "conversationId": "record_01jq8z6k2re9v0w1m3n5p7s9t2",
    "token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef",
    "visitorHistory": True,
    "visitorToken": "cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Reopen a history conversation as a returning visitor
const url = 'https://api.runtype.com/v1/client/init';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"conversationId":"record_01jq8z6k2re9v0w1m3n5p7s9t2","token":"ct_live_flow01k7_0123456789abcdef0123456789abcdef","visitorHistory":true,"visitorToken":"cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Reopen a history conversation as a returning visitor
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/client/init"

	payload := strings.NewReader("{\n  \"conversationId\": \"record_01jq8z6k2re9v0w1m3n5p7s9t2\",\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\",\n  \"visitorHistory\": true,\n  \"visitorToken\": \"cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Reopen a history conversation as a returning visitor
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/client/init")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"conversationId\": \"record_01jq8z6k2re9v0w1m3n5p7s9t2\",\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\",\n  \"visitorHistory\": true,\n  \"visitorToken\": \"cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a\"\n}"

response = http.request(request)
puts response.read_body
```

```java Reopen a history conversation as a returning visitor
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/client/init")
  .header("Content-Type", "application/json")
  .body("{\n  \"conversationId\": \"record_01jq8z6k2re9v0w1m3n5p7s9t2\",\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\",\n  \"visitorHistory\": true,\n  \"visitorToken\": \"cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a\"\n}")
  .asString();
```

```php Reopen a history conversation as a returning visitor
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/client/init', [
  'body' => '{
  "conversationId": "record_01jq8z6k2re9v0w1m3n5p7s9t2",
  "token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef",
  "visitorHistory": true,
  "visitorToken": "cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Reopen a history conversation as a returning visitor
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/client/init");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"conversationId\": \"record_01jq8z6k2re9v0w1m3n5p7s9t2\",\n  \"token\": \"ct_live_flow01k7_0123456789abcdef0123456789abcdef\",\n  \"visitorHistory\": true,\n  \"visitorToken\": \"cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Reopen a history conversation as a returning visitor
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "conversationId": "record_01jq8z6k2re9v0w1m3n5p7s9t2",
  "token": "ct_live_flow01k7_0123456789abcdef0123456789abcdef",
  "visitorHistory": true,
  "visitorToken": "cvt_EXAMPLEONLYnotARealVisitorSecret0123456789a"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/client/init")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```