Skip to Content
WorkflowsAutomating with the Cloud API

Automating with the Cloud API

Use the Cloud API to trigger agents from build systems, cron jobs, or other services—no manual intervention required.

Example: GitHub Actions workflow

name: testbase on: push: branches: [main] jobs: run-cloud-agent: runs-on: ubuntu-latest env: TESTBASE_API_KEY: ${{ secrets.TESTBASE_API_KEY }} TESTBASE_API_URL: https://testbase-cloud-api-310716408703.us-central1.run.app steps: - uses: actions/checkout@v4 - name: Install dependencies run: npm install computer-agents @testbase/cloud - name: Execute agent run: node ./scripts/run-cloud-agent.mjs

run-cloud-agent.mjs:

import { TestbaseCloud } from '@testbase/cloud'; import { run } from 'computer-agents'; const cloud = new TestbaseCloud({ apiKey: process.env.TESTBASE_API_KEY, apiUrl: process.env.TESTBASE_API_URL }); const agent = await cloud.createCloudAgent({ name: 'CI Worker', agentType: 'worker', workspace: './', persistContainer: false }); await cloud.uploadFile(agent.containerId, '/workspace/.env', process.env.APP_ENV || ''); const result = await run(agent, 'Run tests and summarize failures'); console.log(result.finalOutput); await cloud.deleteContainer(agent.containerId);

Example: raw HTTP integration

API="https://testbase-cloud-api-310716408703.us-central1.run.app" KEY="tb_prod_..." # Create container container=$(curl -s -X POST "$API/api/v1/containers" \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -d '{ "agentType": "worker", "workspace": "/workspace", "model": "gpt-4o-mini", "reasoningEffort": "low" }') id=$(echo "$container" | jq -r '.id') url=$(echo "$container" | jq -r '.cloudRunServiceUrl') # Upload bootstrap file curl -X PUT "$API/api/v1/containers/$id/files" \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -d '{ "path": "/workspace/README.md", "content": "# Hello" }' # Kick off task via container endpoint curl -X POST "$url/execute" \ -H "Content-Type: application/json" \ -d '{ "task": "Generate release notes" }' # Fetch artefacts curl "$API/api/v1/containers/$id/files?path=/workspace" \ -H "Authorization: Bearer $KEY" # Clean up curl -X DELETE "$API/api/v1/containers/$id" \ -H "Authorization: Bearer $KEY"

Automation tips

  • Retry idempotent operations: container creation, file uploads, and MCP updates can be retried safely if you receive 5xx responses.
  • Tag runs: store CI build IDs in your own database keyed by containerId to map outputs back to commits.
  • Parallelize carefully: each container has isolated storage, but remember that API keys govern quotas. Spread large batches across multiple keys/environments.
  • Alert on health: poll GET /api/v1/containers/:id/health in long automations and surface alerts when healthy flips to false.

Automation turns TestBase into a programmable platform—integrate it wherever you run scripted workflows.

Last updated on