> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a realtime session

Mints a short-lived token for the workflow realtime Socket.IO endpoint. Connect with socket.io-client using `path: socketPath` and `auth: {token: sessionToken}`, then subscribe to topics (workflow-runs, run, activity, execution, contract). Returns 503 when the realtime transport is not enabled on the environment — fall back to the SSE stream endpoints.

` POST /v1/realtime/session `

Create a realtime session

Mints a short-lived token for the workflow realtime Socket.IO endpoint. Connect with socket.io-client using `path: socketPath` and `auth: {token: sessionToken}`, then subscribe to topics (workflow-runs, run, activity, execution, contract). Returns 503 when the realtime transport is not enabled on the environment — fall back to the SSE stream endpoints.

## Responses

### ` 200 ` — sessionToken + socketPath + expiresInSeconds

Content type: ` application/json `

- ` value `: type ` object `

### ` 403 ` — Forbidden

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

  - ` details `: type ` array `

    - ` array item `: type ` unknown `

  - ` message `: type ` string `

  - ` requestId `: type ` string `

### ` 503 ` — Service Unavailable

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

  - ` details `: type ` array `

    - ` array item `: type ` unknown `

  - ` message `: type ` string `

  - ` requestId `: type ` string `

## Request examples

### cURL

```curl
curl -X POST 'https://api.example.com/v1/realtime/session' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.example.com/v1/realtime/session', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN"
  }
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://api.example.com/v1/realtime/session', headers=headers)
print(response.json())
```

### Go

```go
package main

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

func main() {
	req, _ := http.NewRequest("POST", "https://api.example.com/v1/realtime/session", nil)
	req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
	result, _ := io.ReadAll(resp.Body)
	fmt.Println(string(result))
}
```