API & Automation

TeamDay provides multiple ways to integrate AI agents into your workflows: a REST API, a CLI tool, and scheduled missions.


Access Methods

MethodBest For
API Keys & AuthenticationDirect API calls, CI/CD pipelines, custom integrations
CLI ToolTerminal workflows, shell scripts, interactive management
MissionsRecurring scheduled tasks (cron, continuous)

Quick Examples

Run an Agent via API

curl -X POST "https://us.teamday.ai/api/v1/agents/<id>/execute" \
  -H "Authorization: Bearer $TEAMDAY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "Generate the daily sales report"}'

Run an Agent via CLI

teamday agents exec <id> "Generate the daily sales report" --space <space-id>

Schedule a Recurring Task

curl -X POST "https://us.teamday.ai/api/v1/missions" \
  -H "Authorization: Bearer $TEAMDAY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Daily Report",
    "goal": "Generate the daily sales report and save to reports/",
    "schedule": {"type": "cron", "value": "0 8 * * *"}
  }'

Provision a Workspace (Script)

#!/bin/bash
# Automated workspace setup
result=$(teamday spaces create --name "$1" --format json)
id=$(echo "$result" | jq -r '.space.id // .id')
teamday spaces add-skill "$id" core:research-assistant
teamday spaces set-secret "$id" API_KEY="$API_KEY"
echo "Ready: $id"

Integration Patterns

CI/CD Pipeline

Run an agent as part of your deployment process:

# GitHub Actions
- name: Post-deploy analysis
  env:
    TEAMDAY_API_TOKEN: ${{ secrets.TEAMDAY_TOKEN }}
  run: |
    teamday agents exec $AGENT_ID \
      "The deployment to production just completed. Run a quick health check." \
      --space $SPACE_ID --no-stream

Webhook-Triggered

Call the TeamDay API from any webhook handler:

// Express webhook handler
app.post('/webhook/new-lead', async (req, res) => {
  const { leadEmail, leadName } = req.body;

  await fetch('https://us.teamday.ai/api/v1/agents/AGENT_ID/execute', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.TEAMDAY_API_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      message: `New lead: ${leadName} (${leadEmail}). Research this person and their company.`,
      spaceId: 'SPACE_ID',
    }),
  });

  res.json({ status: 'ok' });
});

Cron-Based Automation

Use Missions for recurring tasks without external infrastructure:

ScheduleMission Example
Daily 8amGenerate analytics report
Mondays 9amWeekly SEO audit
HourlyMonitor error rates
1st of monthMonthly performance review

Next Steps