Skip to main content

Digital Twin Survey

This guide walks you through running an audience survey using digital twins — from authentication to interpreting group opinions.

Digital twins are AI personas grounded in real demographic data. You can ask them questions individually or as a group, and get responses that reflect their demographic profile, values, and perspectives.

What you'll build

By the end of this guide, you will:

  • Authenticate with the neuroflash API
  • Fetch your workspace
  • Browse available demographic groups
  • List twins in a group
  • Ask a single twin a question
  • Get group opinions from multiple twins

Prerequisites

  • A neuroflash account with API access
  • Your client_id and client_secret (see Authentication)

Step 1: Authenticate

First, obtain an access token:

curl -X POST https://id.neuroflash.com/oauth/v2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "scope=openid"

Step 2: Get Your Workspace

Fetch your available workspaces and select the first one. The workspace ID is required for most API calls:

curl "https://app.neuroflash.com/api/workspace-service/v1/workspaces" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Step 3: Browse Static Groups

neuroflash provides pre-built demographic groups with ready-to-use digital twins. List the available groups:

curl "https://app.neuroflash.com/api/digital-twin-service/v1/static-groups" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response:

[
{
"key": "gen_z",
"label": "Gen Z",
"description": "Generation Z (born 1997-2012)"
},
{
"key": "millennials",
"label": "Millennials",
"description": "Millennials (born 1981-1996)"
},
{
"key": "gen_x",
"label": "Generation X",
"description": "Generation X (born 1965-1980)"
},
{
"key": "baby_boomers",
"label": "Baby Boomers",
"description": "Baby Boomers (born 1946-1964)"
},
{
"key": "gen_alpha",
"label": "Generation Alpha",
"description": "Generation Alpha (born 2010+)"
}
]

Step 4: List Twins in a Group

Pick the first group and get the individual digital twins within it:

curl "https://app.neuroflash.com/api/digital-twin-service/v1/workspaces/{workspace_id}/static-groups/gen_z/twins?page=1&size=5" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response:

{
"data": [
{
"id": "a1b2c3d4-...",
"name": "Jens Bauer",
"title": "Tech-Savvy Millennial",
"age": 34,
"gender": "male",
"location": "Munich",
"jobTitle": "Software Engineer",
"staticGroupKey": "millennials",
"_links": {
"avatarUrl": "https://storage.googleapis.com/..."
}
}
],
"page": {
"size": 5,
"totalElements": 20,
"totalPages": 4,
"currentPage": 1
}
}

Step 5: Ask a Single Twin

Now ask an individual twin a question. The twin responds in character, based on its demographic profile:

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": [
{
"role": "user",
"content": "What do you think about electric vehicles? Would you buy one?"
}
]
}'

Response:

{
"answer": "I'm definitely considering it for my next car. The tech has gotten really good, and with charging infrastructure improving in Munich, it makes sense both financially and environmentally.",
"reason": "As a tech-savvy millennial software engineer, Jens is drawn to innovative technology and is environmentally conscious. His urban Munich location provides good charging infrastructure, making EVs practical."
}
Verbalized Sampling

By default, useVerbalizedSampling is true. This means the twin generates 5 probability-weighted candidate responses and selects the most representative one, producing more consistent and reliable answers.

Next Steps