Skip to main content

Target Audience Lifecycle

This guide walks you through the full lifecycle of a target audience: bootstrapping from a URL, creating, updating, and deleting.

What you'll build

  • Bootstrap a demographic profile from a URL
  • Create a target audience from that profile
  • Retrieve, update, and delete it

Prerequisites

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

Step 1: Authenticate

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

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

Step 3: Bootstrap from a URL (fastest path)

This returns a prepared demographic profile, not a saved audience. Pass the response fields directly to the create endpoint in the next step.

curl -X POST "https://app.neuroflash.com/api/audience-service/v1/workspaces/{workspace_id}/target-audiences-url-imports" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"audienceModelId": "538b1efc6f88ad88feebf7acd8c618facb54fe82",
"urls": ["https://your-brand.com"]
}'

Step 4: Create the Audience

Gender distribution must sum to 1.0

The four genderDistribution fields (female, male, nonBinary, preferNotToSay) are all required and their values must sum to exactly 1.0. The API returns a 400 error if any field is missing or the sum is incorrect.

curl -X POST "https://app.neuroflash.com/api/audience-service/v1/workspaces/{workspace_id}/target-audiences" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"country": "US",
"genderDistribution": {
"female": 0.5,
"male": 0.4,
"nonBinary": 0.07,
"preferNotToSay": 0.03
},
"interests": ["AI", "content marketing"],
"maxAge": 45,
"minAge": 25,
"name": "Marketing leaders",
"nativeLanguage": "en",
"needs": ["scale content production"],
"painPoints": ["manual workflows"],
"residence": "Berlin",
"shared": true
}'

Step 5: Get the Audience

curl "https://app.neuroflash.com/api/audience-service/v1/workspaces/{workspace_id}/target-audiences/{target_audience_id}" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Step 6: Update the Audience

Full profile required on every update

The update endpoint uses PUT semantics — you must supply the complete demographic profile on every call, even if you only want to change one field. Fetch the audience first, then re-send all existing values with your change applied.

curl -X PUT "https://app.neuroflash.com/api/audience-service/v1/workspaces/{workspace_id}/target-audiences/{target_audience_id}" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "...": "full demographic profile here" }'

Step 7: Delete the Audience

Ownership

Only the user who created a target audience can update or delete it. Attempting to modify a resource owned by another user returns 403 Forbidden.

curl -X DELETE "https://app.neuroflash.com/api/audience-service/v1/workspaces/{workspace_id}/target-audiences/{target_audience_id}" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

The genderDistribution Object

All four keys are required and the values must sum to exactly 1.0:

KeyDescription
femaleFraction identifying as female
maleFraction identifying as male
nonBinaryFraction identifying as non-binary
preferNotToSayFraction preferring not to disclose

A common starting point: female: 0.5, male: 0.4, nonBinary: 0.07, preferNotToSay: 0.03.