Twins
Base URL: https://app.neuroflash.com/api/digital-twin-service
Retrieve individual digital twin personas from static groups.
List Static Group Twins
/v1/workspaces/{workspace_id}/static-groups/{group_key}/twinsList all twins in a static group with pagination.
Optionally filter by specific twin IDs using the twinIds query parameter. Sorted by name in the specified order.
Requires authentication.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
group_key | string | Yes | The static group key (e.g., gen_z, millennials) |
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number (1-based) |
size | integer | 20 | Number of elements per page |
order | string | — | Sort order by name |
twinIds | string | — | Comma-separated list of twin IDs to filter for |
Response
dataarray<object>List of twins for this page
idstringUnique identifiercreatedAtstringTimestamp when the record was createdupdatedAtstringTimestamp when the record was last updatedcreatedByUserIdobjectID of the user who created this recordtargetAudienceIdobjectTarget audience ID (either this or staticGroupKey must be set)staticGroupKeyobjectKey of the associated static group (either this or targetAudienceId must be set)subjectIdstringID of the subject this twin is based onnamestringFull name of the digital twintitleobjectDescriptive title for the digital twinageobjectAge of the digital twingenderobjectGender of the digital twinlocationobjectLocation of the digital twinjobTitleobjectJob title of the digital twinselfDescriptionobjectSelf-description of the digital twin from survey responses_linksobjectHATEOAS links (e.g., avatarUrl)pageobjectPagination metadata.
sizeintegerNumber of elements per pagetotalElementsintegerTotal number of matching elementstotalPagesintegerTotal number of pagescurrentPageintegerCurrent page number (1-based)Example
- cURL
- Python
- Node.js
- Go
curl "https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/{workspace_id}/static-groups/{group_key}/twins" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
response = requests.get(
f"https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/{workspace_id}/static-groups/{group_key}/twins",
headers={"Authorization": f"Bearer {token}"},
).json()
const response = await fetch(
`https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/${workspaceId}/static-groups/${groupKey}/twins`,
{ headers: { Authorization: `Bearer ${token}` } }
).then((r) => r.json());
req, _ := http.NewRequest("GET", "https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/"+workspaceID+"/static-groups/"+groupKey+"/twins", nil)
req.Header.Set("Authorization", "Bearer "+token)
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
Response:
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"createdByUserId": "12345",
"targetAudienceId": "aud_12345",
"staticGroupKey": "millennials",
"subjectId": "550e8400-e29b-41d4-a716-446655440000",
"name": "Jens Bauer",
"title": "Tech-Savvy Millennial",
"age": 28,
"gender": "Male",
"location": "Berlin, Germany",
"jobTitle": "Software Engineer",
"selfDescription": "I'm a tech enthusiast who loves innovation and problem-solving.",
"_links": {}
}
],
"page": {
"size": 0,
"totalElements": 0,
"totalPages": 0,
"currentPage": 0
}
}
Chat With Twin
/v1/workspaces/{workspace_id}/twins/{twin_id}/chat-completionsChat with a digital twin with conversation context.
Messages Format:
- User messages: Standard format with
role="user"andcontent - Assistant messages: Previous twin responses for conversation context
Response Format:
- Without
responseFormat: Returns default{"answer": "...", "reason": "..."} - With
responseFormat: Returns structure matching your custom JSON schematypemust be"json_schema"schemamust not be empty
Important: useVerbalizedSampling and responseFormat are mutually exclusive.
Example 1: Single Turn, Default Response Format
Request:
{
"messages": [
{"role": "user", "content": "What do you think about remote work?"}
]
}
Response:
{
"answer": "I believe remote work offers great flexibility...",
"reason": "As someone who values work-life balance, I appreciate..."
}
Example 2: Multi-turn Conversation, Default Response Format
Request:
{
"messages": [
{"role": "user", "content": "What do you think about remote work?"},
{"role": "assistant", "content": "I believe remote work offers great flexibility and helps with work-life balance."},
{"role": "user", "content": "What challenges do you see?"}
]
}
Response:
{
"answer": "The main challenge is maintaining team collaboration and spontaneous interactions that happen naturally in an office.",
"reason": "Based on my previous point about flexibility, I recognize there's a tradeoff with in-person connection."
}
Example 3: Single Turn, Custom Response Format
Request:
{
"messages": [
{"role": "user", "content": "Rate your enthusiasm for AI on a scale of 1-10"}
],
"responseFormat": {
"type": "json_schema",
"json_schema": {
"name": "enthusiasm_rating",
"schema": {
"type": "object",
"properties": {
"rating": {"type": "number", "minimum": 1, "maximum": 10},
"explanation": {"type": "string"}
},
"required": ["rating", "explanation"],
"additionalProperties": false
}
}
},
"useVerbalizedSampling": false
}
Response:
{
"rating": 9,
"explanation": "I'm highly enthusiastic about AI's potential to solve complex problems..."
}
Requires authentication via x-gateway-token header (or x-local-* headers in local dev).
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | string | Yes | |
twin_id | string | Yes |
Request Body
messagesarray<object>YesConversation history
rolestringYesRole: 'user' or 'assistant'contentstringYesMessage contentresponseFormatobjectNoStructured output format using JSON schema. If null, uses default schema with 'answer' and 'reason' fields.temperatureobjectNoSampling temperature for response generationuseWebSearchobjectNoWeb search mode: 'never', 'auto', or 'always'useVerbalizedSamplingobjectNoGenerate 5 probability-weighted response options (tau=0.10). Mutually exclusive with custom responseFormat.Example
- cURL
- Python
- Node.js
- Go
curl -X POST "https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/{workspace_id}/twins/{twin_id}/chat-completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messages": [],
"responseFormat": {},
"temperature": {},
"useWebSearch": {},
"useVerbalizedSampling": {}
}'
import requests
response = requests.post(
f"https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/{workspace_id}/twins/{twin_id}/chat-completions",
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},
json={
"messages": [],
"responseFormat": {},
"temperature": {},
"useWebSearch": {},
"useVerbalizedSampling": {}
},
).json()
const response = await fetch(
`https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/${workspaceId}/twins/${twinId}/chat-completions`,
{
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"messages": [],
"responseFormat": {},
"temperature": {},
"useWebSearch": {},
"useVerbalizedSampling": {}
}),
}
).then((r) => r.json());
body, _ := json.Marshal(map[string]any{
"messages": []any{},
"responseFormat": map[string]any{},
"temperature": map[string]any{},
"useWebSearch": map[string]any{},
"useVerbalizedSampling": map[string]any{},
})
req, _ := http.NewRequest("POST", "https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/"+workspaceID+"/twins/"+twinID+"/chat-completions", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
Response:
{}
Get Twin
/v1/workspaces/{workspace_id}/twins/{twin_id}Get a single digital twin by ID.
Returns global twins (static groups) or workspace-specific twins that belong to the user's workspace.
Requires authentication.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | string | Yes | The workspace ID |
twin_id | string | Yes | The twin ID to retrieve |
Response
idstringUnique identifiercreatedAtstringTimestamp when the record was createdupdatedAtstringTimestamp when the record was last updatedcreatedByUserIdobjectID of the user who created this recordtargetAudienceIdobjectTarget audience ID (either this or staticGroupKey must be set)staticGroupKeyobjectKey of the associated static group (either this or targetAudienceId must be set)subjectIdstringID of the subject this twin is based onnamestringFull name of the digital twintitleobjectDescriptive title for the digital twinageobjectAge of the digital twingenderobjectGender of the digital twinlocationobjectLocation of the digital twinjobTitleobjectJob title of the digital twinselfDescriptionobjectSelf-description of the digital twin from survey responses_linksobjectHATEOAS links (e.g., avatarUrl)Example
- cURL
- Python
- Node.js
- Go
curl "https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/{workspace_id}/twins/{twin_id}" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
response = requests.get(
f"https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/{workspace_id}/twins/{twin_id}",
headers={"Authorization": f"Bearer {token}"},
).json()
const response = await fetch(
`https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/${workspaceId}/twins/${twinId}`,
{ headers: { Authorization: `Bearer ${token}` } }
).then((r) => r.json());
req, _ := http.NewRequest("GET", "https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/"+workspaceID+"/twins/"+twinID+"", nil)
req.Header.Set("Authorization", "Bearer "+token)
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
Response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"createdByUserId": "12345",
"targetAudienceId": "aud_12345",
"staticGroupKey": "millennials",
"subjectId": "550e8400-e29b-41d4-a716-446655440000",
"name": "Jens Bauer",
"title": "Tech-Savvy Millennial",
"age": 28,
"gender": "Male",
"location": "Berlin, Germany",
"jobTitle": "Software Engineer",
"selfDescription": "I'm a tech enthusiast who loves innovation and problem-solving.",
"_links": {}
}