Skip to content
ProspectAPIs

API reference / People writes

Send a direct message

Written and maintained by The ProspectAPIs team

POST/v1/messages

POST /v1/messages is the ProspectAPIs operation sendMessage, in the People writes group of the REST API. Send a direct message from your connected account. $0.03 per action, with or without an attachment, and for a message to a person outside your network (inmail: true with a subject, which also spends one of the account's credits; 409 no_inmail_credits when none is left, nothing sent). An attachment or an inmail send answers 503 temporarily_unavailable, with nothing charged, until it is switched on. Acts on your own connected account (connect one first with POST /v1/accounts/session). Billed per call once the write product is live; while it is not yet on sale the call is free (GET /pricing reports people_writes.available). Cost: $0.03 per action. Send your API key as a Bearer token in the Authorization header.

The quickstart shows this call in context, next to the first requests most integrations make.

Parameters

Parameters of POST /v1/messages
NameInTypeDescription
Idempotency-KeyheaderstringOptional, 1 to 255 printable ASCII characters. A retry with the same key and body within 24 hours gets the first answer back with Idempotent-Replayed: true and is never charged again. The same key with a different body is 422; a retry while the first call is still running is 409.

Request body

JSON.

Request body of POST /v1/messages
FieldTypeDescription
person_ref requiredstringThe person reference from a profile or search result. At most 4000 characters.
text requiredstringThe message text. At most 8000 characters.
attachmentanyOne file, at most 20 MB, of an allowed type (PDF, Word, PowerPoint, Excel, plain text, JPEG, PNG, GIF): an https url we fetch (it must answer the file itself, no redirect), or data as base64 with its filename and mime_type.
inmailbooleantrue to message a person outside your network; needs subject.
subjectstringThe subject line, with inmail: true only. At most 200 characters.
Example body
{
  "person_ref": "person ref",
  "text": "text"
}

Responses

Response codes of POST /v1/messages
StatusMeaning
200Done. Our neutral confirmation.
202Your connected account is signed out or needs a reconnect: the write is queued and sent, through the same pacing, once the account is connected again. Charged only when sent. See GET /v1/writes/queued.
400The request was invalid (e.g. a bad filter or input); nothing was charged.
401The API key is missing or invalid.
402Out of credits. The body carries top_up_url; nothing was charged.
404No such record for this account.
409No account is connected. Connect one with POST /v1/accounts/session, then retry.
422The connected account is signed out. Connect it again, then retry.
429Too many requests; retry after the window.
503This action is temporarily unavailable. Nothing was changed.

Every error answers with the same JSON body, an error string and sometimes a code; the errors page lists each status and when it happens. A per-key 429 carries Retry-After; see rate limits.

200 response fields

Done. Our neutral confirmation. The body is a PeopleWriteResult.

Fields of the 200 response
FieldTypeDescription
data requiredobjectOur neutral confirmation of the action taken.
Response headers
HeaderMeaning
RateLimit-LimitRequests this API key may make per minute.
RateLimit-RemainingRequests left in the current one-minute window.
RateLimit-ResetSeconds until the current window resets.

Code samples

Each sample sends the same request. Set PROSPECTAPIS_KEY in your environment first. Values come from the spec's examples; replace them with your own.

curl
curl -X POST https://api.prospectapis.com/v1/messages \
  -H "Authorization: Bearer $PROSPECTAPIS_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "person_ref": "person ref", "text": "text" }'
JavaScript (fetch)
const res = await fetch("https://api.prospectapis.com/v1/messages", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROSPECTAPIS_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "person_ref": "person ref",
    "text": "text"
  }),
});
if (!res.ok) throw new Error(`${res.status}: ${(await res.json().catch(() => ({}))).error ?? res.statusText}`);
const data = await res.json();
console.log(data);
Python (requests)
import os, requests

res = requests.post(
    "https://api.prospectapis.com/v1/messages",
    headers={"Authorization": f"Bearer {os.environ['PROSPECTAPIS_KEY']}"},
    json={
        "person_ref": "person ref",
        "text": "text",
    },
    timeout=30,
)
res.raise_for_status()
data = res.json()
print(data)

Billing

Billing reserves before it serves: the call holds what it may cost, serves at most what that hold covers, and refunds the rest when the response closes. Any non-2xx answer refunds the whole hold, so a failed call costs nothing. The response reports your balance in X-Credits-Remaining.

Previous operation: List conversations (live). Next operation: Remaining message credits. Every operation, grouped by area, is on the API reference index.

Create a free account to get a key, then run the samples above with your own values (this call acts for real, so use real inputs).

Was this page helpful?