Skip to Content
Quickstart

Quickstart

Send your first member message to Bella in three steps:

  1. Register the member (PUT /api/v1/members/{external_member_id})
  2. Open a thread (POST /api/v1/members/{external_member_id}/threads)
  3. Send a message (POST /api/v1/threads/{id}/messages)

Before you start

Sign in to the dashboard ↗ and grab two things (or follow the dashboard setup guide if you haven’t created them yet):

  • An integration key (bella_sk_live_…) from Integration keys.
  • Your assistant ID (asst_…) from Coach.

Set them in your terminal so you can copy and run the examples below:

export BELLA_API_URL="https://api.bellacoach.ai" export BELLA_API_KEY="bella_sk_live_..." export BELLA_ASSISTANT_ID="asst_..."

Send your first message

Step 1: Register the member and submit onboarding answers

Tell Bella about the member using your own ID in the URL (usr_94821 in this example).

If usr_94821 is new, Bella creates the record (201 Created). If already registered, Bella updates their details (200 OK).

Include their onboarding answers (from GET /api/v1/onboarding/questions) in the onboarding array. All configured phases must be "completed" before opening a thread:

curl -X PUT "$BELLA_API_URL/api/v1/members/usr_94821" \ -H "Authorization: Bearer $BELLA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "nickname": "Sarah", "onboarding": [ { "id": "date_of_birth", "value": ["1992-06-14"] }, { "id": "stage_of_life", "value": ["pregnancy"] }, { "id": "due_date", "value": ["2026-11-20"] }, { "id": "goals", "value": ["Feel stronger", "More energy"] } ] }'

Response (201 Created)

{ "id": "mem_8f3a1c9e4b2d7061a5c8e2f1", "external_member_id": "usr_94821", "nickname": "Sarah", "source": "partner_api", "onboarding_status": [ { "name": "pre-payment", "status": "completed" }, { "name": "post-payment", "status": "completed" } ], "onboarding": [ { "id": "date_of_birth", "value": ["1992-06-14"] }, { "id": "stage_of_life", "value": ["pregnancy"] }, { "id": "due_date", "value": ["2026-11-20"] }, { "id": "goals", "value": ["Feel stronger", "More energy"] } ], "created_at": "2026-08-02T10:15:30Z" }

Step 2: Open a thread

Start a conversation for usr_94821 with your assistant (asst_…). Save the returned thr_… ID to send messages to this conversation.

curl -X POST "$BELLA_API_URL/api/v1/members/usr_94821/threads" \ -H "Authorization: Bearer $BELLA_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"assistant\": \"$BELLA_ASSISTANT_ID\" }"

Response (201 Created)

{ "id": "thr_9c41f0b7a2d64e83b15c7f20", "external_member_id": "usr_94821", "assistant": "asst_4d9e2a7b1c8f3052e6a9c4b0", "created_at": "2026-08-02T10:16:00Z" }

Step 3: Send a message

Post the member’s message to the thread. Because you passed due_date in Step 1, Bella calculates their current week and trimester automatically.

By default ("stream": false), the endpoint waits for completion and returns JSON:

curl -X POST "$BELLA_API_URL/api/v1/threads/thr_9c41f0b7a2d64e83b15c7f20/messages" \ -H "Authorization: Bearer $BELLA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "text": "How should I adjust my core workouts right now?", "stream": false }'

Response (200 OK)

{ "thread": "thr_9c41f0b7a2d64e83b15c7f20", "message": { "id": "msg_7d02edd7fc430c94162cba02", "role": "coach", "text": "At 24 weeks into your second trimester, adjusting core work is about managing pressure through your abdomen and pelvic floor. Swap sit-ups, crunches, and long front planks for incline planks, Pallof presses, and bird-dogs, and exhale gently on the effort rather than holding your breath.", "created_at": "2026-11-08T23:08:00.123456Z" } }

Stream the reply (stream: true)

To stream replies live, set "stream": true. Bella returns Server-Sent Events (text/event-stream):

  1. status events: display labels (Thinking, Reading your notes, Searching, Replying) for typing indicators while the coach prepares an answer.
  2. delta events: incremental text chunks as words generate.
  3. done event: signals that generation is complete and the message is saved.
curl -N -X POST "$BELLA_API_URL/api/v1/threads/thr_9c41f0b7a2d64e83b15c7f20/messages" \ -H "Authorization: Bearer $BELLA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "text": "Can I still do barbell deadlifts?", "stream": true }'

Streamed response (200 OK, text/event-stream)

event: status data: {"event":"status","step":"thinking","label":"Thinking"} event: status data: {"event":"status","step":"reading_your_notes","label":"Reading your notes"} event: status data: {"event":"status","step":"searching","label":"Searching"} event: status data: {"event":"status","step":"replying","label":"Replying"} event: delta data: {"event":"delta","text":"Yes, if you've been deadlifting comfortably "} event: delta data: {"event":"delta","text":"and don't have pelvic pain or medical restrictions, "} event: delta data: {"event":"delta","text":"you can keep deadlifting in your second trimester with a few tweaks."} event: done data: {"event":"done","thread":"thr_9c41f0b7a2d64e83b15c7f20","message":{"id":"msg_8b31a0e5f2c41a9d7e3052c1","role":"coach","text":"Yes, if you've been deadlifting comfortably and don't have pelvic pain or medical restrictions, you can keep deadlifting in your second trimester with a few tweaks.","created_at":"2026-11-08T23:08:00.123456Z"}}

See the Streaming replies guide for production TypeScript and Python parsers.

Next steps

Last updated on