Docs · guides

Missions - User Guide

Schedule AI agents to run work automatically — daily reports, weekly audits, cron jobs, and manual mission tasks.

Missions

Missions are scheduled AI tasks. Set up a mission, assign it to an agent, and it runs automatically on your schedule.

Use missions for recurring work: daily reports, weekly SEO audits, content publishing, data monitoring, and more. Missions appear in the org sidebar and are global — not tied to a specific space.


Core Concepts

ConceptDescription
MissionA named recurring or manually started work stream
DescriptionWhat the mission is for and what good output looks like
ScheduleWhen to run: manual or cron
AgentOptional — runs the mission with this agent's role, model, skills, and MCP server access
WorkspaceOptional — gives the mission access to workspace files, MCP servers, secrets, and context
TaskA concrete mission item that can be started as work
HooksShell scripts that run before or after each mission execution to control or validate runs

Schedule Types

TypeDescriptionExample
ManualNo cron schedule. Start mission tasks when neededOne-time setup task
CronRecurring server-side schedule0 9 * * MON (Mondays at 9am)

Cron Examples

Cron ExpressionDescription
0 9 * * *Every day at 9:00 AM
0 9 * * MONEvery Monday at 9:00 AM
0 9 * * 1-5Weekdays at 9:00 AM
0 */6 * * *Every 6 hours
0 9 1 * *First of every month at 9:00 AM

Execution Model

Missions run via a job queue powered by BullMQ with Redis:

  • 3 concurrent workers process missions in parallel
  • Automatic retry: 2 attempts with exponential backoff on failure
  • Stalled job detection: jobs that stop responding are recovered automatically
  • Status flow: pending -> running -> completed / failed

Mission results create chat entries visible in the space (if a space is assigned). Mission runs use the mission's assigned workspace when one is set.


Create a Mission

Via Web App

  1. Navigate to the Missions section in the sidebar
  2. Click + New Mission
  3. Configure:
    • Title: "Weekly SEO Report"
    • Goal: "Analyze this week's search performance. Compare to last week. Send the summary."
    • Schedule: Cron — 0 9 * * MON
    • Agent: Select "Sarah" (optional)
    • Space: Select your SEO workspace (optional)
    • Max Turns: 100 (optional)
    • Team: auto (optional — controls subagent delegation)
  4. Save

Via CLI

teamday missions create \
  --title "Weekly SEO Report" \
  --description "Analyze this week's search performance, compare to last week, and summarize the findings." \
  --schedule-cron "0 9 * * MON" \
  --schedule-timezone "Europe/Bratislava" \
  --agent-id <agent-id> \
  --workspace-id <workspace-id> \
  --task-title "Prepare this week's SEO report"

Discover the current CLI contract:

teamday missions create --help
teamday missions start --help

Via API

curl -X POST "https://app.teamday.ai/api/missions" \
  -H "Authorization: Bearer $TEAMDAY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Weekly SEO Report",
    "description": "Analyze this week search performance, compare to last week, and summarize the findings.",
    "workspace_id": "workspace-abc123",
    "agent_id": "agent-sarah-id",
    "schedule_cron": "0 9 * * MON",
    "schedule_timezone": "Europe/Bratislava",
    "initial_task": {
      "title": "Prepare this week's SEO report"
    }
  }'

Response:

{
  "mission": {
    "id": "mission-xyz789",
    "title": "Weekly SEO Report",
    "status": "planning",
    "schedule_cron": "0 9 * * MON",
    "schedule_timezone": "Europe/Bratislava"
  }
}

Mission Examples

Daily Data Summary

{
  "title": "Daily Analytics Summary",
  "description": "Pull yesterday's Google Analytics data. Report total visitors, top 5 pages, and bounce-rate change. Save to reports/daily/.",
  "schedule_cron": "0 8 * * *",
  "schedule_timezone": "Europe/Bratislava"
}

Weekly Content Audit

{
  "title": "Weekly Content Audit",
  "description": "Check all blog posts published this week for SEO compliance. Verify meta descriptions, image alt text, and internal links. Report any issues.",
  "schedule_cron": "0 17 * * FRI",
  "schedule_timezone": "Europe/Bratislava"
}

One-Time Setup

{
  "title": "Initial SEO Baseline",
  "description": "Run a comprehensive SEO audit of example.com. Document current rankings, backlinks, and technical issues. Save the baseline report to reports/."
}

Managing Missions

Update a Mission

Pause, change the schedule, or update the description:

curl -X PATCH "https://app.teamday.ai/api/missions/mission-xyz789" \
  -H "Authorization: Bearer $TEAMDAY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "paused",
    "schedule_cron": "0 9 * * 1-5",
    "schedule_timezone": "Europe/Bratislava"
  }'

Mission Statuses

StatusDescription
pendingCreated, waiting for first scheduled run
runningCurrently executing
completedFinished successfully (one-time missions)
failedExecution failed (will retry if attempts remain)
pausedTemporarily stopped by user

Session Continuity

Missions support session continuity via the resumeSession flag. When enabled, each run resumes from the previous session's context using the stored lastSessionId, maintaining conversation history across runs.

This is useful for missions that build on previous results — like weekly reports that compare to last week, or monitoring tasks that track changes over time.


Agents and Missions

Binding an agent to a mission means:

  • The mission runs with the agent's system prompt (systemPrompt)
  • It uses the agent's model preference
  • It has access to the agent's skills and MCP server references

If no agent is bound, the mission runs with default settings.

Best Practice

Create dedicated agents for mission types:

teamday agents create \
  --name "Report Bot" \
  --role "Automated Reporting" \
  --system-prompt "You generate daily and weekly reports. Be concise. Use tables. Save reports to the reports/ directory with dated filenames."

Then bind it to multiple missions:

{"title": "Daily Sales Report", "agent_id": "report-bot-id", "schedule_cron": "0 8 * * *"}
{"title": "Weekly Performance Review", "agent_id": "report-bot-id", "schedule_cron": "0 9 * * MON"}

Writing Good Mission Descriptions

The mission description and task title are the instruction frame the agent receives. Write them like you'd brief a human colleague:

Vague (bad):

Check the website.

Specific (good):

Check example.com for broken links, missing meta descriptions, and pages with no H1 tag.
Save the results to reports/site-audit-{date}.md.
If critical issues are found, create a summary at the top.

Key tips:

  • State the objective clearly
  • Specify output format and location
  • Include thresholds or criteria when relevant
  • Mention what to do with the results

Hooks

Hooks are shell scripts that run at the boundary of each mission execution. Use them to skip runs when there is nothing to do, or to validate that the run produced expected output.

File placement

.teamday/missions/<mission-title-slug>/precheck.sh
.teamday/missions/<mission-title-slug>/postcheck.sh

The slug is your mission title lowercased with spaces replaced by hyphens — for example, a mission titled "Weekly SEO Report" uses .teamday/missions/weekly-seo-report/precheck.sh. Teamday also checks .teamday/missions/<mission-id>/ as a fallback when title-based lookup is ambiguous.

How hooks work

HookWhen it runsExit 0Non-zero
precheck.shAfter workspace sync, before the agent startsContinues the run normallyMarks the occurrence as skipped — logs stdout/stderr as the reason, syncs any workspace changes, does not start the agent
postcheck.shAfter the agent finishes, before artifact syncRun marked completedRun marked failed — hook output used as the error reason

Both scripts execute from the workspace root.

Environment variables

VariableValue
TEAMDAY_LAST_RUN_ATUnix timestamp of the previous scheduled occurrence, or 0 if this is the first run
TEAMDAY_SCHEDULED_RUN_ATUnix timestamp of the current occurrence
TEAMDAY_MISSION_IDMission ID
TEAMDAY_MISSION_TITLEMission title
TEAMDAY_MISSION_TASK_IDCurrent task ID
TEAMDAY_WORKSPACE_ROOTAbsolute path to the workspace root
TEAMDAY_CWDWorking directory for this run

Example: skip when no new files have arrived

#!/bin/sh
# precheck.sh — skip the mission run if no files changed since last run

if [ "$TEAMDAY_LAST_RUN_AT" = "0" ]; then
  echo "First run — proceeding"
  exit 0
fi

# Find any file newer than the last run
NEW=$(find "$TEAMDAY_WORKSPACE_ROOT" -newer /proc/1 -not -path '*/.git/*' | head -1)

if [ -z "$NEW" ]; then
  echo "No new files since last run at $TEAMDAY_LAST_RUN_AT — skipping"
  exit 1
fi

echo "New content found — proceeding"
exit 0

Make the script executable before committing:

chmod +x .teamday/missions/my-mission/precheck.sh

Next Steps