sendMessage
Client function: send a private message. 403 unless the thread is mutually open.
import { sendMessage } from 'flowstack-sdk'Non-React client function backing useMessages().send. Sends body to toUserKey. The backend pins from to the caller's JWT identity and returns 403 unless the thread is mutually consented (open). config must carry an appScope.
Signature
sendMessage(credentials, toUserKey, body, config?): Promise<ApiResponse<{ message_id: string; created_at: string }>>Parameters
| Param | Type | Notes | Description |
|---|---|---|---|
credentials | FlowstackCredentials | required, since 0.2.2 | The authenticated sender's credentials. |
toUserKey | string | required, since 0.2.2 | The recipient's user key. |
body | string | required, since 0.2.2 | Message text. Stored and returned verbatim as untrusted input. |
config | FlowstackClientConfig | required, since 0.2.2 | Client config. Must include appScope. |
Returns
| Field | Type | Description |
|---|---|---|
| — | Promise<ApiResponse<{ message_id: string; created_at: string }>> | { ok, data: { message_id, created_at }, error }. ok is false (403) if the thread is not mutually open. |
Examples
Send a message
const res = await sendMessage(credentials, toUserKey, 'hey there', { appScope });
if (!res.ok) console.error(res.error); // e.g. thread not openWarningReturns 403 unless BOTH parties have consented via
openThread. There is no way to message a user who has not opened a thread with you.See also
useMessages · openThread · listMessages
Source: README.md#private-messaging-dms · Also available in llms-full.txt and registry.json.