This tutorial assumes you already have an access token. If you do not, the First Call guide walks you from zero to one authenticated request in about five minutes.
What you’ll build
A command-line chatbot that, on each run:Finds unread chats
Lists every conversation that has unread messages, along with the fan’s
userUuid you need to reply.Reads the conversation
Pulls the most recent messages so the reply has context, and checks the last message actually came from the fan.
Drafts a reply
Turns the conversation into a short, on-brand reply. Start with a template, then swap in an LLM when you are ready.
Sends the reply
Posts the drafted text back into the chat and confirms with the returned
messageUuid.How it works
Three endpoints do the work. Everything is served fromhttps://api.fanvue.com, authenticated with a Bearer token, and every request must carry the X-Fanvue-API-Version header.
There is also a
GET /chats/unread endpoint, but it returns only counts (how many unread chats and messages you have), not the chats themselves. To get the list with each fan’s userUuid, use GET /chats with filter=unread, as shown below.Prerequisites
1
An access token
A Bearer access token for the creator’s account. Get one with the First Call guide if you do not have it yet. Access tokens are short-lived (typically one hour), so refresh yours if it has expired.
2
The right scopes
The token must be granted these OAuth scopes:
3
A runtime
Python 3.9+ (the example uses the
requests library) or Node.js 18+ (which has fetch built in). Pick one tab below.Step 1: Set up the API client
Every call shares the same base URL, Bearer token, and version header, so wrap them once. The client below exposes one helper per endpoint we need.- Python
- TypeScript (Node.js)
Install the one dependency, then create
fanvue.py:fanvue.py
Step 2: Find the unread chats
GET /chats?filter=unread returns a paginated list. Each item describes one conversation: the fan (user, including the user.uuid you reply to), how many messages are unread (unreadMessagesCount), and a preview of the lastMessage.
A trimmed response looks like this:
user.uuid field is the userUuid path parameter for the next two endpoints. Keep it.
Step 3: Read the conversation and draft a reply
For each unread chat, callGET /chats/{userUuid}/messages to pull recent history. Messages come back newest first, and every message carries a sender.uuid. Compare that against your own uuid from GET /users/me to confirm the latest message is from the fan and not a reply you already sent.
A trimmed messages response:
- Python
- TypeScript (Node.js)
draft.py
Step 4: Send the reply
POST /chats/{userUuid}/message posts your drafted text. The body needs a single text field (1 to 5000 characters). On success the API returns 201 with the new message’s UUID:
A send can fail with a
400 and a contactability error if the fan cannot currently be messaged (for example, they are not subscribed or have blocked messages). Catch that case per chat so one un-messageable fan does not stop the whole run.mediaUuids, a price (in cents, minimum 300) to make the message pay-to-view, and a templateUuid. This tutorial sends plain text only.
Step 5: Put it together
Now wire the four calls into one loop: identify yourself, fetch unread chats, and for each one read the history, draft a reply, and send it. SetFANVUE_TOKEN in your environment first.
- Python
- TypeScript (Node.js)
bot.py
Expected result
With three unread chats, a run prints something like:sent ... line is a real message now visible in the creator’s chat with that fan. Open the Fanvue inbox to confirm the replies landed. Run the script again and the chats you just answered no longer appear in the unread list, because your reply marked the conversation as read.
A note on what the spec does not cover
The Fanvue API gives you the conversation and lets you send a reply, but it does not write the reply for you. The quality of the draft is entirely up to the code indraft_reply. The TODO in Step 3 is where you plug in your own logic or an LLM. Everything else on this page (the endpoints, fields, and request shapes) is defined by the API and works as shown.
Next steps
Fanvue MCP Server
Prefer not to write code? Connect Fanvue to Claude, ChatGPT, or Cursor and ask your assistant to read and reply to chats in plain language.
API Reference
Browse the full chat surface: mass messages, templates, media attachments, custom lists, and more.