Docs / built-apps / sendMessage

sendMessage

utilitysince 0.2.2

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

ParamTypeNotesDescription
credentialsFlowstackCredentialsrequired, since 0.2.2The authenticated sender's credentials.
toUserKeystringrequired, since 0.2.2The recipient's user key.
bodystringrequired, since 0.2.2Message text. Stored and returned verbatim as untrusted input.
configFlowstackClientConfigrequired, since 0.2.2Client config. Must include appScope.

Returns

FieldTypeDescription
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 open
WarningReturns 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.