Skip to main content

Persistent Conversations

This guide shows you how to use the conversations API to run multi-turn chat sessions without re-sending the full message history on every request.

What you'll build

By the end of this guide, you will:

  • Create a persistent conversation
  • Send multi-turn messages without re-sending history
  • Retrieve the conversation and its full message history
  • Delete the conversation when done

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: Create a Conversation

Note: workspace_id goes in the JSON body for POST, not as a header.

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/conversations" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "workspace_id": "YOUR_WORKSPACE_ID" }'

Response:

{
"uuid": "ebb3fbeb-69ed-41e9-bcb5-1ec8a643566e",
"workspace_id": "b481b98b-a7ed-4d72-a1f2-8b2ae3a57854",
"created_at": "2026-04-08T15:44:47.383172"
}

Step 4: Send a Message

The conversation service stores your message history — you do not need to re-send previous turns. Each request only needs to contain the new user message.

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "messages": [{ "role": "user", "content": "What makes neuroflash unique?" }] }'

Response:

{
"id": "gen-1775000000-AbCdEfGh",
"object": "chat.completion",
"model": "openai/gpt-4.1-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Neuroflash is unique because it combines brand-aware AI content generation with European data privacy standards and multi-language support."
},
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 12, "completion_tokens": 28, "total_tokens": 40, "words_used": 22 }
}

Step 5: Send a Follow-up

Send another message to the same conversation — no need to re-send history. The context from step 4 is retained on the server.

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "messages": [{ "role": "user", "content": "Can you give me an example?" }] }'

Step 6: Retrieve the Conversation

workspace_id required on GET and DELETE

The conversations service enforces workspace-scoped ownership. The workspace_id query parameter is required on all GET and DELETE requests. Omitting it or using the wrong workspace returns 403 Forbidden.

curl "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}?workspace_id=YOUR_WORKSPACE_ID" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Step 7: Get Message History

curl "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}/messages?workspace_id=YOUR_WORKSPACE_ID" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response:

{
"messages": [
{ "role": "user", "content": "What makes neuroflash unique?" },
{ "role": "assistant", "content": "Neuroflash is unique due to..." }
],
"next_cursor": null
}

Step 8: Delete the Conversation

curl -X DELETE "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}?workspace_id=YOUR_WORKSPACE_ID" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Next Steps