> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ofauth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send a message

> Send text, media, and paid content to one fan

Send a free or paid message to one fan and save the returned message ID. Use a [mass message](https://docs.ofauth.com/v3/guides/how-to/mass-message.md) when you need multiple recipients or scheduled delivery.

## Before you start

Ask the user to [authorize your app](https://docs.ofauth.com/v3/guides/link.md) with `messages:write`, which lets your app send messages. Use the returned access token and select a linked account the user shared. You also need the fan’s numeric OnlyFans user ID.

Install the [TypeScript SDK](https://docs.ofauth.com/v3/sdk/typescript.md) version 4. Create a client on your server:

```typescript theme={null}
import { OFAuthClient } from "@ofauth/onlyfans-sdk"

const client = new OFAuthClient({
	accessToken: process.env.ACCESS_TOKEN!,
	linkedAccountId: process.env.LINKED_ACCOUNT_ID!
})
```

Use this client for the rest of this guide. The SDK sends the access token and linked account ID for you.

## Select a recipient

Use the fan's numeric OnlyFans ID in the URL. If you do not have it, read [fans](https://docs.ofauth.com/v3/guides/fans.md) or [chats](https://docs.ofauth.com/v3/guides/messaging.md) with the read permission listed in that guide. For the example below, that ID is `123456`.

## Send text

```typescript theme={null}
const message = await client.access.chats.messages.send({
	userId: 123456,
	body: { text: "**Welcome!**\n\nThanks for subscribing." }
})
```

The response contains the created message, with no `data` field around it. Save `message.id` with the recipient. You have finished when that record contains the message ID.

If you do not know whether the request succeeded, check the conversation with `messages:read`. Follow [error recovery](https://docs.ofauth.com/v3/api-reference/errors.md) before trying again. A timeout can happen after the message was sent.

To reply to one message, add its ID as the string `replyToMessageId`. To send text or HTML unchanged, set `isMarkdown: false`. See [Text formatting](https://docs.ofauth.com/v3/guides/how-to/text-formatting.md).

## Read the recent conversation (optional)

If you need context before sending, request `messages:read` when the user authorizes your app. Then read recent messages. Skip this request when you already know the recipient and message.

```typescript theme={null}
const history = await client.access.chats.messages.list({
	userId: 123456,
	limit: 10
})
```

Process `history.items`. Follow `history.page.nextCursor` for older messages while `history.page.hasMore` is true.

## Attach media and set a price

[Upload new media](https://docs.ofauth.com/v3/guides/how-to/upload-media.md) or choose existing Vault IDs. Pass this object as `body` to `client.access.chats.messages.send({ userId: 123456, body })`:

```json theme={null}
{
	"text": "A preview and the full set",
	"mediaItems": [789, 790, 791],
	"price": 9.99,
	"previewMediaCount": 1,
	"isLockedText": false
}
```

The first attachment is the free preview. The remaining attachments require purchase. Set `price` from 0 to 200. Set `previewMediaCount` to a whole number from zero to the number of attachments. When charging, keep some text or media paid.

To include release forms for people in the media, add `releaseForms: { "users": [123456], "partners": [], "guests": [] }`. Use numeric IDs in these arrays. See [Media references](https://docs.ofauth.com/v3/guides/media-items.md) for supported attachment formats and single-use upload references.

## Delete a sent message

Delete the selected message with the same fan ID in the path and body:

```typescript theme={null}
await client.access.chats.messages.unsend({
	userId: 123456,
	messageId: 987654,
	body: { withUserId: 123456 }
})
```

Wait for the call to succeed before removing the message from your app.

For multiple recipients, use [mass messages](https://docs.ofauth.com/v3/guides/how-to/mass-message.md). Handle [errors](https://docs.ofauth.com/v3/api-reference/errors.md) before retrying a send, particularly when it is unclear whether the message was sent.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.