---
title: "Get User Context"
method: GET
path: "/api/v1/users/context/{user_id}"
tags: ["context"]
---

# Get User Context

`GET /api/v1/users/context/{user_id}`

## Path parameters

- `user_id` union, required — The ID of the user
  - string, uuid4
  - string, uuid5

## Query parameters

- `max_token_size` integer — Max token size of returned Context
- `prefer_topics` string[] — Rank prefer topics at first to try to keep them in filtering, default order is by updated time
- `only_topics` string[] — Only return profiles with these topics, default is all
- `max_subtopic_size` integer — Max subtopic size of the same topic in returned Context
- `topic_limits_json` string — Set specific subtopic limits for topics in JSON, for example {"topic1": 3, "topic2": 5}. The limits in this param will override `max_subtopic_size`.
- `profile_event_ratio` number — Profile event ratio of returned Context
- `require_event_summary` boolean — Whether to require event summary in returned Context
- `chats_str` string — Pass the recent chats to enable context search. Memobase will use those chats to search for relevant events. It's a list of chats in OpenAI Message format, for example: [{"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi"}]. **NOTICE** - It will increase your latency by 0.1-1 seconds, because Memobase will use Embedding to search for relevant profiles and events. - It will cost your Memobase tokens, roughly 100~200 tokens per chat based on the profile size. - The profiles in the context will not be searched by the `chats_str`. - If you want also search profiles, see `full_profile_and_only_search_event` query parameter.
- `event_similarity_threshold` number — Event similarity threshold of returned Context
- `time_range_in_days` integer — Only allow events within the past few days, default is 180
- `customize_context_prompt` string — Customize context prompt template. - use `{profile_section}` to refer to the profile section - use `{event_section}` to refer to the event section For example: ``` # Memory Unless the user has relevant queries, do not actively mention those memories in the conversation. ## User Background: {profile_section} ## Latest Events: {event_section} ```
- `full_profile_and_only_search_event` boolean — If you pass `chats_str` and set this to `False`, Memobase will search for relevant profiles and events at the same time. **NOTICE** - It will increase your latency by 2-5(based on the profile size) seconds, because Memobase will use LLM and Embedding to search for relevant profiles and events. - It will cost your Memobase tokens, roughly 100~1000 tokens per chat based on the profile size.
- `fill_window_with_events` boolean — If set to `True`, Memobase will fill the token window with the rest events.

## Response `200`

Successful Response

- UserContextDataResponse
  - `data` ContextData
    - `context` string, required — Context string
  - `errno` 0 | 400 | 401 | 403 | 404 | 405 | 409 | 422 | 500 | 501 | 502 | 503 | 504 | 520
  - `errmsg` string — Error message, empty when success

## Other responses

- `422` — Validation Error

## Changes

- **2025-09-01** `c5d39efe16d8` — 1 info
  - for the `path` request parameter `user_id`, the type/format was generalized from `string`/`` to ``/``
- **2025-07-12** `0f9b630d3b07` — 1 breaking, 1 info
  - for the `query` request parameter `time_range_in_days`, default value was changed from `21` to `180`
  - added the new optional `query` request parameter `fill_window_with_events`
- **2025-07-06** `5bed9e705467` — 2 info
  - added the new optional `query` request parameter `full_profile_and_only_search_event`
  - added the new optional `query` request parameter `time_range_in_days`
- **2025-07-03** `2a5f964464a5` — 1 info
  - added the new optional `query` request parameter `customize_context_prompt`
- **2025-05-19** `f0f4a1940afe` — 1 breaking
  - for the `query` request parameter `event_similarity_threshold`, default value was changed from `0.3` to `0.2`

[Full history](https://skmtc.dev/memodb-io/apis/memobase-api/changes/api/v1/users/context/:user_id/get.md)

---

[API](https://skmtc.dev/memodb-io/apis/memobase-api.md) · [All operations](https://skmtc.dev/memodb-io/apis/memobase-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/memodb-io/memobase-api/revisions/4543f130c8e0/schema)
