LiveWing
CMS API

AI Agent

Interact with the CMS AI assistant programmatically to automate workspace setup and management.

The CMS AI agent can create collections, define field schemas, set up production templates, and manage data — all from a natural language prompt. The API endpoint provides the same capabilities as the in-app chat, suitable for scripted automation.

Send Message

Send a natural language message to the CMS AI agent and receive a response.

POST /api/cms/agent/message

Auth: readwrite

Request:

curl -X POST https://ideal-heron-677.convex.site/api/cms/agent/message \
  -H "Authorization: Bearer lw_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Create a Teams collection with fields for name, abbreviation, logo, and primary color",
    "threadPurpose": "api"
  }'
FieldTypeRequiredDescription
messagestringYesThe prompt to send to the AI agent
threadPurposestringNoThread identifier for conversation continuity (default: "api")

Response:

{
  "threadId": "a1b2c3d4-...",
  "response": "I've created a Teams collection with the following fields:\n\n| Field | Key | Type |\n|---|---|---|\n| Team Name | name | text |\n| Abbreviation | abbreviation | text |\n| Logo | logo | image |\n| Primary Color | primaryColor | color |\n\nThe collection is ready to use. You can start adding teams."
}

Conversation Threads

The agent maintains conversation context within a thread. Use threadPurpose to organize conversations:

  • "api" (default) — general-purpose API thread
  • "setup" — workspace setup and onboarding
  • "production:j572prod1..." — per-production context

Messages sent to the same threadPurpose continue the same conversation. The agent remembers what it previously created and can reference prior context.

# First message — agent proposes schema
curl -X POST .../api/cms/agent/message \
  -H "Authorization: Bearer lw_your_key" \
  -H "Content-Type: application/json" \
  -d '{"message": "Set up my workspace for college football broadcasts"}'

# Second message — agent remembers the first
curl -X POST .../api/cms/agent/message \
  -H "Authorization: Bearer lw_your_key" \
  -H "Content-Type: application/json" \
  -d '{"message": "Yes, create those collections and the Game template"}'

What the Agent Can Do

The agent has tools for:

  • Schema design — propose and create collections with typed fields
  • Field management — add fields to existing collections
  • Data entry — create and update collection items
  • Production templates — define production types with bindings and control surfaces
  • Production management — create productions, set bindings

Example Workflows

Set up a workspace from scratch

curl -X POST .../api/cms/agent/message \
  -H "Authorization: Bearer lw_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "I run a high school football broadcast. I need to track teams, players, and game scores. Set up my workspace."
  }'

The agent will propose a schema (Teams, Players, Scoreboard collections + a Game production template), then execute on confirmation.

Bulk data entry

curl -X POST .../api/cms/agent/message \
  -H "Authorization: Bearer lw_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Add these teams: Dallas Cowboys (DAL, #003594), Philadelphia Eagles (PHI, #004C54), New York Giants (NYG, #0B2265)"
  }'

Add fields to existing collections

curl -X POST .../api/cms/agent/message \
  -H "Authorization: Bearer lw_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Add a conference field (select: NFC, AFC) and a division field (select: East, West, North, South) to the Teams collection"
  }'

Limitations

  • The agent runs synchronously — the response is returned when the agent finishes (typically 3-10 seconds)
  • Schema changes (collection creation, field additions) require confirmation by default when used in the web UI, but the API agent executes directly
  • Monthly AI token limits apply per workspace
  • Maximum message length: 4000 characters

On this page