← Public packages
@kentcdodds/x
X API v2 helpers for tweets, search, legacy DMs, and encrypted X Chat via a Fly XDK sidecar.
src/send-chat.ts
24 lines · 1.1 KB · TypeScriptimport { sendChat } from './chat.ts'
import type { XSendChatParams } from './types.ts'
/**
* Send or dry-run an encrypted X Chat message. Sending requires confirm: true.
* Target one of: conversationId, participantId, or username.
*
* Encrypts on the Fly XDK sidecar (existing PIN / identity) and POSTs the
* ciphertext to api.x.com. X OAuth tokens never leave api.x.com.
*
* Alias targets (`to`/`userId`/`recipient`) and text (`message`/`body`/`content`) are mapped; unknown keys are rejected. Dry-run echoes `targetMode`.
*
* Pass optional `idempotencyKey` for retry-safe sends: same `(account, key)`
* within 7 days returns the prior successful result from package storage.
*
* @returns Sent chat payload, or a dry-run request description.
* @example
* import sendChat from 'kody:@kentcdodds/x/send-chat'
* const draft = await sendChat({ username: 'kentcdodds', text: 'Hello!', dryRun: true })
* // => { dryRun: true, method: 'POST', url: '...', requiresConfirm: true }
*/
export default async function sendChatEntrypoint(params: XSendChatParams = {}) {
return await sendChat(params)
}