API Integration
The package ships its own Axios-based REST client, pointed at the apiUrl you provide. You can pass additional query-string parameters into any of its GET (and optionally POST/PATCH) requests without forking the package.
Required backend endpoints
The client-side chat UI expects your backend to expose REST endpoints for the following operations (paths shown are the package's internal defaults):
Passing extra query parameters
By default, queryParams apply only to GET requests (queryParamApis defaults to ['get']). Login and other write operations are unaffected unless you opt in with queryParamApis={['all']}.
Pattern 1 - same params on every GET request
Use when every GET call should receive the same extra keys (for example a branch or tenant id). Write operations stay untouched unless you change queryParamApis.
<ChatMain {...chatConfig} queryParams={{ branchId: "12" }} // queryParamApis default = ['get']/>Pattern 2 - different params per GET endpoint
Prefer queryParamsByApi when each endpoint needs its own filters. Keys must match the API key table above (for example conversations, messages, presignedUrls).
<ChatMain {...chatConfig} queryParamsByApi={{ conversations: { branchId: "12" }, messages: { locale: "en" }, users: { orgId: "x" }, }}/>Pattern 3 - params on a single endpoint only
Narrow shared queryParams to one API by setting queryParamApis to that key instead of the default ['get'].
<ChatMain {...chatConfig} queryParams={{ branchId: "12" }} queryParamApis={["conversations"]}/>queryParamApis values
All valid queryParamsByApi keys
queryParamsByApi accepts an object keyed by API identifier. The 16 keys below are the complete list of identifiers it recognizes - every REST call the package makes is addressable by one of these keys.
// Correct - specific keys inside queryParamsByApiqueryParamsByApi={{ conversations: { branchId: "12" }, createGroup: { orgId: "x" }, presignedUrls: { bucket: "chat-uploads" },}} // Correct - 'all' / 'get' used only with queryParamApisqueryParamApis={["all"]} // every request receives queryParamsqueryParamApis={["get"]} // default: every GET request receives queryParams // Incorrect - 'all' / 'get' are not queryParamsByApi keysqueryParamsByApi={{ all: { branchId: "12" } }} // ignoredCustom metadata (metadata.<key>)
A param named metadata.<key> stays in the URL as a filter on GET (?metadata.jobId=J1) and moves into the body's metadata object on POST / PATCH ({ metadata: { jobId: "J1" } }). Other params on that request stay in the URL. So the key you store is the same key you filter by later:
<ChatMain {...chatConfig} queryParamsByApi={{ createGroup: { "metadata.jobId": jobId }, // POST body → metadata.jobId conversations: { "metadata.jobId": jobId }, // GET → ?metadata.jobId=… }}/>- Several keys work at once; a list stays a list in the body and is sent as repeated keys on GET ("any of").
- A
metadatavalue the package already put in the body wins; the others are merged in. - File uploads (
FormData) are not changed. - The backend must store
metadatafor that endpoint - group create and client-user login do. Messages sent over the socket don't go through these params.
Imperative helpers
Prefer the ChatMain props when the values are known at render time. Use these setters when credentials or filters arrive asynchronously after mount (for example after a host-app login completes) and you need to update the shared API client without remounting the whole tree.
import { setChatQueryParams, setChatQueryParamApis, setChatQueryParamsByApi,} from "@convo-sco/sdk-react"; setChatQueryParams({ branchId: "12" });setChatQueryParamApis(["conversations"]);setChatQueryParamsByApi({ messages: { locale: "en" } });