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

# Get One-off Hosted Session Link

POST https://test.api.kota.io/hosted/sessions
Content-Type: application/json

Retrieve a hosted `link` to authenticate an `employee` with the Kota Hosted. This link is valid for a single use and expires after 60 minutes. The link opens on your platform's hosted domain. It opens on Kota's default hosted domain instead when your platform has no hosted configuration, or when the employee's `metadata` has `is_whitelabel` set to `"true"`.

Reference: https://docs.kota.io/api-reference/hosted-sessions/create-hosted-session

## Authentication

- `Authorization` header (bearer token, required) — Authorization header using the Bearer scheme

## Servers

- `https://test.api.kota.io` (test, default)
- `https://api.kota.io` (production)

## Request

### Body (application/json)

This endpoint expects a CreateSessionTokenLinkRequest.

- `employer_id` (string, required)
- `employee_id` (string, required)

## Response

### 200

OK

- `link` (string, required)
- `expiry` (datetime, required)

## Errors

### 404 Not Found Error

Not Found

- `type` (string, optional, nullable)
- `title` (string, optional, nullable)
- `status` (integer, optional, nullable)
- `detail` (string, optional, nullable)
- `instance` (string, optional, nullable)

## Examples

**Request**

```json
{
  "employer_id": "er_3b1333d87d9d4fd6ad83ba7f6b0e951a",
  "employee_id": "ee_3b1333d87d9d4fd6ad83ba7f6b0e951a"
}
```

**Response**

```json
{
  "link": "string",
  "expiry": "2024-12-01T00:00:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://test.api.kota.io/hosted/sessions"

payload = {
    "employer_id": "er_3b1333d87d9d4fd6ad83ba7f6b0e951a",
    "employee_id": "ee_3b1333d87d9d4fd6ad83ba7f6b0e951a"
}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://test.api.kota.io/hosted/sessions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"employer_id":"er_3b1333d87d9d4fd6ad83ba7f6b0e951a","employee_id":"ee_3b1333d87d9d4fd6ad83ba7f6b0e951a"}'
};

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

```go
package main

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

func main() {

	url := "https://test.api.kota.io/hosted/sessions"

	payload := strings.NewReader("{\n  \"employer_id\": \"er_3b1333d87d9d4fd6ad83ba7f6b0e951a\",\n  \"employee_id\": \"ee_3b1333d87d9d4fd6ad83ba7f6b0e951a\"\n}")

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

	req.Header.Add("Authorization", "Bearer <apiKey>")
	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
require 'uri'
require 'net/http'

url = URI("https://test.api.kota.io/hosted/sessions")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"employer_id\": \"er_3b1333d87d9d4fd6ad83ba7f6b0e951a\",\n  \"employee_id\": \"ee_3b1333d87d9d4fd6ad83ba7f6b0e951a\"\n}"

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://test.api.kota.io/hosted/sessions")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"employer_id\": \"er_3b1333d87d9d4fd6ad83ba7f6b0e951a\",\n  \"employee_id\": \"ee_3b1333d87d9d4fd6ad83ba7f6b0e951a\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://test.api.kota.io/hosted/sessions', [
  'body' => '{
  "employer_id": "er_3b1333d87d9d4fd6ad83ba7f6b0e951a",
  "employee_id": "ee_3b1333d87d9d4fd6ad83ba7f6b0e951a"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://test.api.kota.io/hosted/sessions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"employer_id\": \"er_3b1333d87d9d4fd6ad83ba7f6b0e951a\",\n  \"employee_id\": \"ee_3b1333d87d9d4fd6ad83ba7f6b0e951a\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "employer_id": "er_3b1333d87d9d4fd6ad83ba7f6b0e951a",
  "employee_id": "ee_3b1333d87d9d4fd6ad83ba7f6b0e951a"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://test.api.kota.io/hosted/sessions")! 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()
```