API Reference
v1Generate realistic chat mockup images programmatically. Perfect for automating content creation, building integrations, or creating mockups at scale.
Authentication
All API requests require authentication using a Bearer token. Include your API key in the Authorization header.
Authorization: Bearer YOUR_API_KEYContact us to request API access for your account: maurice@getmockly.com.
Base URL
All API endpoints are relative to the following base URL:
https://www.getmockly.com/api/v1Generate Chat Image
/chat/imageGenerate a PNG image of a chat conversation. The image is rendered using the same engine that powers the Mockly web application, ensuring pixel-perfect results.
Request Body
platformstringrequiredThe messaging platform to render. One of: discord, imessage, instagram, line, messenger, microsoftTeams, reddit, signal, slack, snapchat, telegram, tiktok, tinder, wechat, whatsapp, x
senderUserrequiredThe user sending messages. Object with id (string), name (string), and optional image (base64 data URL).
receiversUser[]requiredArray of recipient users. Each with id, name, and optional image.
messagesMessage[]requiredArray of messages to display. See Message schema below.
conversationTypestringType of conversation: direct-message (default) or group-chat.
darkModebooleanEnable dark mode theme. Default: false
mobileViewbooleanRender in mobile dimensions. Default: true
showHeaderbooleanShow the chat header. Default: true
showFooterbooleanShow the message input footer. Default: true
timeNotationstringTime format: 12h or 24h (default).
transparentBackgroundbooleanRender with transparent background. Default: false
groupChatSettingsobjectFor group chats: object with name (string) and optional image (base64).
Message Schema
idstringrequiredUnique identifier for the message.
textstringMessage text content. Optional if the message contains only images.
timestampstringrequiredISO 8601 timestamp (e.g., 2025-01-15T10:30:00Z).
typestringrequiredMessage type: text, image, or mixed.
userIdstringrequiredID of the user who sent this message (must match sender or a receiver).
statusstringDelivery status: sent, delivered, or read.
imagesMessageImage[]Array of images attached to the message.
Response
On success, returns a JSON object with the base64-encoded PNG image:
{
"type": "success",
"data": {
"image": "iVBORw0KGgoAAAANSUhEUgAA...", // base64-encoded PNG
"mimeType": "image/png",
"sizeInBytes": 145832
}
}Code Examples
cURL
curl -X POST https://www.getmockly.com/api/v1/chat/image \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platform": "whatsapp",
"sender": {
"id": "sender-1",
"name": "Alice"
},
"receivers": [{
"id": "receiver-1",
"name": "Bob"
}],
"messages": [{
"id": "msg-1",
"text": "Hey! How are you?",
"timestamp": "2025-01-15T10:30:00Z",
"type": "text",
"userId": "sender-1"
}, {
"id": "msg-2",
"text": "I am doing great, thanks!",
"timestamp": "2025-01-15T10:31:00Z",
"type": "text",
"userId": "receiver-1"
}]
}'TypeScript / JavaScript
const response = await fetch("https://www.getmockly.com/api/v1/chat/image", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
platform: "whatsapp",
sender: { id: "sender-1", name: "Alice" },
receivers: [{ id: "receiver-1", name: "Bob" }],
messages: [
{
id: "msg-1",
text: "Hey! How are you?",
timestamp: "2025-01-15T10:30:00Z",
type: "text",
userId: "sender-1",
},
{
id: "msg-2",
text: "I am doing great, thanks!",
timestamp: "2025-01-15T10:31:00Z",
type: "text",
userId: "receiver-1",
},
],
}),
});
const data = await response.json();
if (data.type === "success") {
// data.data.image contains the base64-encoded PNG
const imageUrl = `data:${data.data.mimeType};base64,${data.data.image}`;
console.log("Image size:", data.data.sizeInBytes, "bytes");
}Python
import requests
import base64
response = requests.post(
"https://www.getmockly.com/api/v1/chat/image",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"platform": "whatsapp",
"sender": {"id": "sender-1", "name": "Alice"},
"receivers": [{"id": "receiver-1", "name": "Bob"}],
"messages": [
{
"id": "msg-1",
"text": "Hey! How are you?",
"timestamp": "2025-01-15T10:30:00Z",
"type": "text",
"userId": "sender-1",
},
{
"id": "msg-2",
"text": "I am doing great, thanks!",
"timestamp": "2025-01-15T10:31:00Z",
"type": "text",
"userId": "receiver-1",
},
],
},
)
data = response.json()
if data["type"] == "success":
# Save the image to a file
image_data = base64.b64decode(data["data"]["image"])
with open("chat_mockup.png", "wb") as f:
f.write(image_data)
print(f"Image saved! Size: {data['data']['sizeInBytes']} bytes")Error Handling
The API returns consistent error responses with a type: "error" field and a descriptive message.
Invalid or missing API key.
{
"type": "error",
"message": "Invalid API key"
}Invalid request body or validation errors.
{
"type": "error",
"message": "Invalid request body",
"errors": {
"platform": ["Invalid enum value"],
"messages": ["Required"]
}
}Server-side error during image generation. The message field will contain details.
Rate Limits
API requests are rate-limited to ensure fair usage. If you exceed the rate limit, you will receive a 429 Too Many Requests response. Contact us if you need higher limits for your use case: maurice@getmockly.com.