Quickstart
Make your first neuroflash API call in under 2 minutes.
Prerequisites
- A neuroflash account with API access
- Your
client_idandclient_secretfrom Service Accounts in the neuroflash app
Step 1: Get an Access Token
Exchange your credentials for an access token:
- cURL
- Python
- Node.js
- Go
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"
import requests
response = requests.post(
"https://id.neuroflash.com/oauth/v2/token",
data={
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"scope": "openid",
},
)
token = response.json()["access_token"]
const response = await fetch("https://id.neuroflash.com/oauth/v2/token", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "client_credentials",
client_id: "YOUR_CLIENT_ID",
client_secret: "YOUR_CLIENT_SECRET",
scope: "openid",
}),
});
const { access_token } = await response.json();
package main
import (
"encoding/json"
"net/http"
"net/url"
"strings"
)
func main() {
data := url.Values{
"grant_type": {"client_credentials"},
"client_id": {"YOUR_CLIENT_ID"},
"client_secret": {"YOUR_CLIENT_SECRET"},
"scope": {"openid"},
}
resp, _ := http.Post(
"https://id.neuroflash.com/oauth/v2/token",
"application/x-www-form-urlencoded",
strings.NewReader(data.Encode()),
)
defer resp.Body.Close()
var result struct {
AccessToken string `json:"access_token"`
}
json.NewDecoder(resp.Body).Decode(&result)
token := result.AccessToken
The response includes an access_token valid for approximately 4 hours. See Authentication for full details.
Step 2: Fetch Your Workspace
Most API endpoints require a workspace ID. Fetch your workspaces to get one:
- cURL
- Python
- Node.js
- Go
curl https://app.neuroflash.com/api/workspace-service/v1/workspaces \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
response = requests.get(
"https://app.neuroflash.com/api/workspace-service/v1/workspaces",
headers={"Authorization": f"Bearer {token}"},
)
workspaces = response.json()["data"]
workspace_id = workspaces[0]["id"]
print(f"Workspace ID: {workspace_id}")
const wsResponse = await fetch(
"https://app.neuroflash.com/api/workspace-service/v1/workspaces",
{
headers: { Authorization: `Bearer ${access_token}` },
}
);
const { data: workspaces } = await wsResponse.json();
const workspaceId = workspaces[0].id;
console.log(`Workspace ID: ${workspaceId}`);
req, _ := http.NewRequest("GET",
"https://app.neuroflash.com/api/workspace-service/v1/workspaces", nil)
req.Header.Set("Authorization", "Bearer "+token)
resp, _ = http.DefaultClient.Do(req)
defer resp.Body.Close()
var wsResult struct {
Data []struct {
ID string `json:"id"`
} `json:"data"`
}
json.NewDecoder(resp.Body).Decode(&wsResult)
workspaceID := wsResult.Data[0].ID
Example response:
{
"data": [
{
"id": "abc123",
"name": "My Workspace",
"role": "owner"
}
]
}
Step 3: Make Your First API Call
Use your workspace ID to list available demographic groups for digital twins:
- cURL
- Python
- Node.js
- Go
curl https://app.neuroflash.com/api/digital-twin-service/v1/static-groups \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
response = requests.get(
"https://app.neuroflash.com/api/digital-twin-service/v1/static-groups",
headers={"Authorization": f"Bearer {token}"},
)
groups = response.json()
for group in groups:
print(f"{group['name']} — {group['description']}")
const groupsResponse = await fetch(
"https://app.neuroflash.com/api/digital-twin-service/v1/static-groups",
{
headers: { Authorization: `Bearer ${access_token}` },
}
);
const groups = await groupsResponse.json();
groups.forEach((g) => console.log(`${g.name} — ${g.description}`));
req, _ = http.NewRequest("GET",
"https://app.neuroflash.com/api/digital-twin-service/v1/static-groups", nil)
req.Header.Set("Authorization", "Bearer "+token)
resp, _ = http.DefaultClient.Do(req)
defer resp.Body.Close()
var groups []struct {
Name string `json:"name"`
Description string `json:"description"`
}
json.NewDecoder(resp.Body).Decode(&groups)
for _, g := range groups {
fmt.Printf("%s — %s\n", g.Name, g.Description)
}
}
Example response:
[
{
"id": "gen-z",
"name": "Gen Z",
"description": "Born 1997–2012",
"twinsCount": 5
},
{
"id": "millennials",
"name": "Millennials",
"description": "Born 1981–1996",
"twinsCount": 5
}
]
You've just made your first neuroflash API call.
Next Steps
- Guide: Digital Twin Survey — Run surveys across demographic groups
- Guide: Text Generation — Generate content with AI models
- Guide: Image Generation — Create images from text prompts
- Authentication — Learn about token management and scopes