messaging.sendMessage

Send a message in a chat.

Prerequisites

  • A Curviate API key, passed as apiKey when you construct the client. Quickstart shows how to create one.
  • A connected LinkedIn account. This resource is account-scoped: the account_id is injected automatically by the account-scoped accessor, so you pass it once to curviate.account(...) and every call below inherits it. Quickstart covers connecting one, and accounts.list returns the account_id of each account already connected.

Signature

sendMessage(chatId: string, body: SendMessageBody): Promise<SendMessageResult>

Example

import { Curviate } from "@curviate/sdk";
 
const curviate = new Curviate({
  apiKey: "cvt_live_...",
  baseUrl: "https://api.curviate.com",
});
 
const acc = curviate.account("acc_YOUR_ACCOUNT_ID");
const result = await acc.messaging.sendMessage("COMPANY_83734124_2-YTQ3ODU3Njgt", {
  text: "Thanks for reaching out!",
});
console.log(result.sent_as); // { kind: "company", company_id: "112013061", name: "Acme Inc" }

Parameters

NameTypeRequiredDescription
chatIdstringYesThe chat to send to. A COMPANY_ chat id (from the inboxes endpoints) sends as that company page instead of the connected member.
textstringNoMessage text (1-8000 chars). Optional when at least one attachment is supplied.
quote_idstringNoOptional message ID to quote or reply to.
attachmentsarrayNoOptional file attachments, base64-encoded: at most 5 MiB per file and 9 MiB for the whole request body (base64 adds about a third).

Returns

Resolves to SendMessageResult. Top-level fields: object, message_id, sent_as, safety_warning.

Error codes

CodeWhat it means, and what to do
UNAUTHORIZEDThe API key is missing, malformed, or revoked. Check the key you passed to the client.
INVALID_REQUESTA parameter failed validation. The message names the offending field; fix the request rather than retrying it.
RATE_LIMIT_ACCOUNTThis account's own quota is exhausted. Wait for the window in the Retry-After header, then retry.
RATE_LIMIT_TENANTThe tenant-wide quota is exhausted across all accounts. Slow the whole workload, not just this call.
PLATFORM_RATE_LIMITLinkedIn is throttling this account. Back off well beyond the hinted delay; sustained pressure risks the account.
PLATFORM_ERRORAn upstream failure, usually transient: retry once with backoff before treating it as a real error. Check the response first, though. When it carries retry_likely_to_succeed: false and retry_hint: {kind: "never"}, retrying cannot help and backing off only delays the real answer.
ACCOUNT_NOT_FOUNDNo connected account with that id belongs to this tenant. List your accounts to get a current id.
INTERNALAn unexpected server error. Retry once; if it persists, it is ours, not yours.
PAYLOAD_TOO_LARGEThree limits can trigger this. The platform's own ceiling on total request size is the lowest and the one you are most likely to hit: it starts rejecting at roughly 1 MB, so a handful of photo-sized images is refused even though it clears everything below. Above that, this API caps one attachment at 5 MiB of file content and the whole request body at 9 MiB. Attachments travel base64-encoded, which inflates them by about a third, so a 5 MiB file costs roughly 6.7 MiB of the body budget. Send fewer or smaller attachments; retrying unchanged will not help.
RECIPIENT_UNREACHABLEThe recipient cannot receive this message, typically because you are not connected and have no InMail credit.
RESOURCE_NOT_FOUNDThe id in the path does not exist, or is not visible to this account. Re-read it from the list endpoint that produced it.
UNSUPPORTED_MEDIA_TYPEThe request was not sent as JSON. Every endpoint takes application/json, including file attachments, which travel base64-encoded.

Every code above is a stable CurviateError.code you can branch on. The full list, the response envelope, and retry semantics are in the Error codes reference.

Notes

Note: See the Reply as a company page guide for the full discover-then-reply flow.

Next steps