Docs⌘ K  Search
Docs/Memory/User profiles
Profiles

User Profiles

Build user profiles through dialectic conversations. Hebbrix learns user preferences, interests, and personality traits to personalize AI responses.

01. How Profiles Work

Learned from conversations

Profiles are built automatically: facts a user states in chat turns (with features.learning, on by default) and in memories you process are added to that user's profile.

Dialectic Chat

Use the dialectic endpoint to have focused conversations that extract specific profile information.

02. Profile Fields

Profiles can store any structured data. Common fields include:

name
preferences
interests
expertise
communication_style
goals
timezone
language
industry
role
personality_traits
custom_fields

03. Endpoints

04. Per-Fact CRUD

Beyond the bulk PATCH, every profile fact can be read, created, edited, or removed individually. Each of these also honours the multi-tenant user_id and collection_id scoping described below.

05. Code Examples

Get User Profile

Python
import requests

# GET /v1/profile
# Flat convenience fields (name/timezone/language) live at the top
# level; all other facts sit under the "profile.static" and
# "profile.dynamic" buckets.
r = requests.get(
    "https://api.hebbrix.com/v1/profile",
    headers={"Authorization": "Bearer <your-api-key>"},
)
data = r.json()

print(f"Name: {data.get('name')}")
print(f"Timezone: {data.get('timezone')}")
print(f"Language: {data.get('language')}")

# Every other fact lives under profile.static (long-lived) or
# profile.dynamic (short-lived). Each entry is {key, value, confidence, ...}.
for fact in data["profile"]["static"]:
    print(f"  static · {fact['key']} = {fact['value']}")
for fact in data["profile"]["dynamic"]:
    print(f"  dynamic · {fact['key']} = {fact['value']}")

Dialectic Conversation

Python (Dialectic)
import requests

# POST /v1/profile/dialectic: ask natural-language questions about the user.
# Send the prompt as `user_message` (preferred); legacy `message` / `question`
# are still accepted.
r = requests.post(
    "https://api.hebbrix.com/v1/profile/dialectic",
    headers={"Authorization": "Bearer <your-api-key>"},
    json={"user_message": "What are this user's main professional interests?"},
)
body = r.json()

# Preferred response fields
print(body["assistant_message"])   # the LLM answer
print(body["session_id"])          # echo back in the next turn for continuity

# Legacy alias (same value as assistant_message)
# body["response"] is also available for older integrations.

# Continue the conversation: reuse session_id to link turns
r2 = requests.post(
    "https://api.hebbrix.com/v1/profile/dialectic",
    headers={"Authorization": "Bearer <your-api-key>"},
    json={
        "user_message": "Tell me more about how they like to communicate.",
        "session_id": body["session_id"],
    },
)

Update Profile Manually

Python (Manual Update)
import requests

# PATCH /v1/profile: bulk-update profile facts. Body is a flat
# {fact_key: fact_value} dict. Existing facts are updated; new ones
# are created as "static" / "other" automatically.
r = requests.patch(
    "https://api.hebbrix.com/v1/profile",
    headers={"Authorization": "Bearer <your-api-key>"},
    json={
        "name": "John Doe",
        "timezone": "UTC",
        "language": "en",
        "role": "Senior Engineer",
        "company": "Acme Inc",
    },
)

body = r.json()
print(body["status"])     # "success"
print(body["updated"])    # count of facts updated in place
print(body["created"])    # count of new facts created
print(body["message"])    # e.g. "Updated 3, created 2 profile facts"

06. cURL Example

GET/v1/profile
curl -X GET "https://api.hebbrix.com/v1/profile" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

07. Profile Injection in Chat

When a chat completion names its end user, that user's profile is injected automatically:

Python
import os
import requests

BASE = "https://api.hebbrix.com/v1"
H = {"Authorization": f"Bearer {os.environ['HEBBRIX_API_KEY']}"}

# POST /v1/chat/completions: name the end user (OpenAI's user field) and
# keep features.user_profile=True to have that user's profile facts
# injected into the context automatically. Without user (or collection_id)
# the call is answered without memory or profile.
r = requests.post(
    f"{BASE}/chat/completions",
    headers=H,
    json={
        "model": "gpt-5-nano",
        "user": "user-123",  # each end user gets their own profile
        "messages": [
            {"role": "user", "content": "Recommend a book for me"},
        ],
        "features": {
            "memory": True,
            "user_profile": True,  # inject profile context
        },
    },
)

# The assistant sees the caller's profile and gives a personalized answer
print(r.json()["choices"][0]["message"]["content"])

08. Multi-Tenant Scoping (user_id)

If you run a multi-tenant SaaS where many end-users share one Hebbrix account, pass each end user's user_id on every profile read and write (the same value you tag their memories with). A read with user_id returns only that end user's facts, so one end-user's profile never leaks into another's. A collection_id narrows a read to one collection; it is not an end-user boundary on its own.

Isolation model

  • A fact written without a user_id is an account-level fact.
  • A read with user_id returns only facts derived from that end user's memories (plus facts you wrote for them); with collection_id as well, only those tagged to or derived from that collection.
  • A read without user_id returns account-level facts only, never all end users'. A collection that holds end-user data refuses a read without user_id with 400 end_user_scope_required.

Agent scope

A fact learned under an agent_id belongs to that agent. A read scoped to an agent sees the facts learned without an agent plus that agent's own, never another agent's, however long ago they were stored. A read with no agent sees user-level facts only, so pass the agent's agent_id to read what it learned. This applies to search with include_profile: true, POST /v1/profile (and GET /v1/profile with the agent_id query parameter) and chat.

The profile that search returns with include_profile: true names the exact scope it was read for in profile.scope (collection_id, end_user_id, agent_id) and says in profile.projection whether recent writes of that scope are in it yet: status is pending while a fact may still appear or change (pending_writes counts the unfinished writes, capped: true when there are at least that many), ready once every accepted write is reflected, and failed when nothing is pending and failed_writes writes will not be reflected unless their batch is retried (failure.reason says why; POST /v1/memories/batches/{id}/retry restarts it). A small write normally reaches the profile within seconds of becoming searchable. profile.status: "ok" means only that the read succeeded. To read the profile a write produced, poll every retry_after_seconds (2 s, backing off to about 10 s) until projection.status is ready or failed, as in the chatbot memory guide. For one specific write, read stages.profile on its readiness_url.

Where it applies

GET /v1/profile, GET /v1/profile/facts (query param), PATCH /v1/profile and POST /v1/profile/facts (body key).

Preview before you write

Send dry_run: true on PATCH /v1/profile to get a preview of the planned changes (would_update / would_create) without persisting anything.

Scoped Write with Dry-Run Preview

Python (Multi-Tenant Scoping)
import requests

BASE = "https://api.hebbrix.com/v1"
H = {"Authorization": "Bearer <your-api-key>"}

# The end user's id in your app, and a collection you created
# (POST /v1/collections returns its id).
USER_ID = "user-123"
COLLECTION = "YOUR_COLLECTION_ID"

# 1) PREVIEW: dry_run returns the planned changes WITHOUT persisting.
preview = requests.patch(
    f"{BASE}/profile",
    headers=H,
    json={
        "role": "Product Manager",
        "timezone": "America/New_York",
        "user_id": USER_ID,           # reserved key: whose facts these are
        "collection_id": COLLECTION,  # reserved key: tags the facts
        "dry_run": True,              # reserved key: preview only
    },
).json()

print(preview["status"])         # "preview"
print(preview["would_update"])   # N facts that would be updated in place
print(preview["would_create"])   # N facts that would be created
print(preview["collection_id"])  # the collection you passed
print(preview["changes"])        # [...] per-fact diff, nothing written yet

# 2) REAL WRITE: drop dry_run (or set it False) to persist the facts
#    for this end user, so they stay isolated.
written = requests.patch(
    f"{BASE}/profile",
    headers=H,
    json={
        "role": "Product Manager",
        "timezone": "America/New_York",
        "user_id": USER_ID,
        "collection_id": COLLECTION,
    },
).json()
print(written["status"])   # "success"
print(written["updated"], written["created"])

# 3) SCOPED READ: only this end user's facts come back; another
#    end-user's profile never leaks in.
profile = requests.get(
    f"{BASE}/profile",
    headers=H,
    params={"user_id": USER_ID, "collection_id": COLLECTION},
).json()

for fact in profile["profile"]["static"]:
    print(f"  {fact['key']} = {fact['value']}")
Ask the docs
reading · this page

Hi! I'm the Hebbrix docs assistant. Ask me anything about this page: setup, code examples, endpoints, pricing, or integrations.