The Messages API handles all message-related operations including creating messages, managing fragments (generated code), and handling attachments.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Jackson57279/zapdev/llms.txt
Use this file to discover all available pages before exploring further.
Data Model
Message
Unique identifier for the message
The text content of the message
Who sent the message:
USER or ASSISTANTMessage type:
RESULT, ERROR, or STREAMINGMessage status:
PENDING, STREAMING, or COMPLETEThe project this message belongs to
Timestamp when the message was created (milliseconds)
Timestamp when the message was last updated (milliseconds)
Fragment
Unique identifier for the fragment
The message this fragment belongs to
E2B sandbox URL where the code runs
Display title for the fragment
File structure with paths as keys and content as values
Additional metadata about the fragment (optional)
Framework used:
NEXTJS, ANGULAR, REACT, VUE, or SVELTEAttachment
Unique identifier for the attachment
The message this attachment belongs to
Attachment type:
IMAGE, FIGMA_FILE, or GITHUB_REPOURL of the attachment
File size in bytes
Image width in pixels (optional)
Image height in pixels (optional)
Related import ID if from Figma/GitHub (optional)
Metadata from the import source (optional)
Queries
list
Get all messages for a project with fragments and attachments.The project ID to get messages for
The fragment associated with this message (if any)
All attachments for this message
"Unauthorized"
get
Get a single message by ID.The message ID to retrieve
"Message not found" or "Unauthorized"
getFragment
Get the fragment for a message.The message ID to get the fragment for
null if no fragment exists
Authentication: Required. User must own the project.
Throws: "Message not found" or "Unauthorized"
getFragmentById
Get a fragment by its ID (public API access).The fragment ID to retrieve
"Fragment not found"
getFragmentByIdAuth
Get a fragment by ID with authorization check.The fragment ID to retrieve
The fragment object
The associated message object
The associated project object
"Fragment not found", "Message not found", or "Unauthorized"
getAttachments
Get all attachments for a message.The message ID to get attachments for
"Message not found" or "Unauthorized"
listForUser
List messages for a specific user (for background jobs/Inngest).The Clerk user ID
The project ID
fragment and attachments fields
Throws: "Unauthorized"
Mutations
create
Create a new message.The project ID
The message content
Message role:
USER or ASSISTANTMessage type:
RESULT, ERROR, or STREAMINGMessage status (defaults to
COMPLETE)Id<"messages"> - The newly created message ID
Authentication: Required. User must own the project.
Throws: "Unauthorized"
updateStatus
Update a message’s status.The message ID to update
New status:
PENDING, STREAMING, or COMPLETEId<"messages"> - The updated message ID
Authentication: Required. User must own the project.
Throws: "Message not found" or "Unauthorized"
updateMessage
Update a message’s content and optionally its status.The message ID to update
New message content
New status (optional)
"Message not found" or "Unauthorized"
createFragment
Create or update a fragment for a message.The message ID
E2B sandbox URL
Display title for the fragment
File structure (paths as keys, content as values)
Framework:
NEXTJS, ANGULAR, REACT, VUE, or SVELTEAdditional metadata (optional)
Id<"fragments"> - The fragment ID (creates new or updates existing)
Authentication: Required. User must own the project.
Throws: "Message not found" or "Unauthorized"
addAttachment
Add an attachment to a message.The message ID
Attachment type:
IMAGE, FIGMA_FILE, or GITHUB_REPOURL of the attachment
File size in bytes
Image width in pixels (optional)
Image height in pixels (optional)
Related import ID (optional)
Source metadata (optional)
Id<"attachments"> - The newly created attachment ID
Authentication: Required. User must own the project.
Throws: "Message not found" or "Unauthorized"
createForUser
Create a message with an explicit user ID (for use from actions).The Clerk user ID
The project ID
Message content
Message role
Message type
Message status (optional, defaults to
COMPLETE)Id<"messages"> - The newly created message ID
Throws: "Unauthorized"
createFragmentForUser
Create a fragment for a specific user (for use from background jobs/Inngest).The Clerk user ID
The message ID
E2B sandbox URL
Display title
File structure
Framework
Additional metadata (optional)
Id<"fragments"> - The fragment ID
Throws: "Message not found" or "Unauthorized"
Actions
createWithAttachments
Create a message with attachments (for message form flow).The message content
The project ID (as string)
Optional array of attachment objects
Attachment URL
File size in bytes
Image width (optional)
Image height (optional)
Attachment type (optional, defaults to
IMAGE)Import ID (optional)
Source metadata (optional)
The newly created message ID
The project ID
The message content
"You have run out of credits"
Note: This action automatically checks and consumes 1 credit before creating the message.
Database Schema
Themessages table has the following indexes:
fragments table:
attachments table: