The Jules Task Queue system provides a comprehensive tRPC-based API for managing GitHub issue tasks, monitoring system health, and administering the queue system. The API is organized into three main routers located in src/server/api/routers/:
- Tasks Router (
tasks.ts) - Core task management operations - Admin Router (
admin.ts) - Administrative and monitoring functions - Webhook Router (
webhook.ts) - Webhook health and status checks
When deployed on Vercel: https://your-app.vercel.app/api/trpc
When self-hosted: http://localhost:3000/api/trpc (or your configured domain)
This API leverages GitHub App authentication, including user access tokens obtained via OAuth during installation. This ensures that actions performed by the system (e.g., label changes) are attributed to the user who authorized the app, allowing Jules to respond correctly.
For development, endpoints are open. In production, implement authentication middleware in the tRPC context (src/server/api/trpc.ts) to secure your API.
Purpose: Manage individual Jules tasks, view statistics, and perform task operations.
Purpose: Retrieve a paginated list of all Jules tasks with filtering options.
Input:
{
limit?: number; // Max items per page (default: 50, max: 100)
cursor?: number; // Task ID for pagination
flaggedOnly?: boolean; // Show only tasks flagged for retry
}Output:
{
items: JulesTask[];
nextCursor?: number;
}Example Usage:
# Get first 20 tasks
curl "https://your-app.vercel.app/api/trpc/tasks.list?input={\"limit\":20}"
# Get only flagged tasks
curl "https://your-app.vercel.app/api/trpc/tasks.list?input={\"flaggedOnly\":true}"Purpose: Retrieve detailed information about a specific task.
Input:
{
id: number; // Task ID
}Output:
JulesTask | null;Example Usage:
curl "https://your-app.vercel.app/api/trpc/tasks.getById?input={\"id\":123}"Purpose: Get comprehensive statistics about the task queue system.
Input: None
Output:
{
totalTasks: number;
queuedTasks: number;
activeTasks: number;
oldestQueuedTaskAge: number | null; // milliseconds
averageRetryCount: number;
maxRetryCount: number;
}Example Usage:
curl "https://your-app.vercel.app/api/trpc/tasks.stats"Purpose: Manually retry a specific flagged task.
Input:
{
id: number; // Task ID to retry
}Output:
{
success: boolean;
message: string;
}Example Usage:
curl -X POST "https://your-app.vercel.app/api/trpc/tasks.retry" \
-H "Content-Type: application/json" \
-d '{"id": 123}'Purpose: Manually update a task's retry status.
Input:
{
id: number;
flaggedForRetry: boolean;
}Output:
{
success: boolean;
task: JulesTask;
}Example Usage:
curl -X POST "https://your-app.vercel.app/api/trpc/tasks.updateStatus" \
-H "Content-Type: application/json" \
-d '{"id": 123, "flaggedForRetry": false}'Purpose: Administrative operations, bulk actions, and system monitoring.
Purpose: Trigger a manual retry of all flagged tasks (same as cron job).
Input: None
Output:
{
attempted: number;
successful: number;
failed: number;
skipped: number;
}Example Usage:
curl -X POST "https://your-app.vercel.app/api/trpc/admin.retryAll"Purpose: Clean up old completed tasks to maintain database hygiene.
Input:
{
olderThanDays?: number; // Default: 30 days
}Output:
{
deletedCount: number;
message: string;
}Example Usage:
# Clean up tasks older than 7 days
curl -X POST "https://your-app.vercel.app/api/trpc/admin.cleanup" \
-H "Content-Type: application/json" \
-d '{"olderThanDays": 7}'Purpose: Retrieve webhook and system operation logs.
Input:
{
limit?: number; // Default: 50, max: 200
eventType?: string; // Filter by event type
success?: boolean; // Filter by success status
}Output:
{
logs: WebhookLog[];
total: number;
}Example Usage:
# Get recent failed operations
curl "https://your-app.vercel.app/api/trpc/admin.logs?input={\"success\":false,\"limit\":10}"
# Get cron job executions
curl "https://your-app.vercel.app/api/trpc/admin.logs?input={\"eventType\":\"cron_retry_execution\"}"Purpose: Comprehensive system health check.
Input: None
Output:
{
status: "healthy" | "unhealthy";
database: "connected" | "disconnected";
services: {
github: boolean;
cron: boolean;
}
metrics: {
totalTasks: number;
queuedTasks: number;
recentErrors: number;
}
timestamp: string;
}Example Usage:
curl "https://your-app.vercel.app/api/trpc/admin.health"Purpose: Get all GitHub App installations.
Input: None
Output:
{
installations: Installation[];
count: number;
}Purpose: Get detailed information about a specific installation.
Input:
{
installationId: number;
}Output:
{
id: number;
accountLogin: string;
repositoryCount: number;
repositories: Repository[];
tasks: Task[];
// ... other installation details
}Purpose: Sync a specific installation with GitHub.
Input:
{
installationId: number;
}Output:
{
success: boolean;
message: string;
data?: Installation;
}Purpose: Sync all installations with GitHub.
Input: None
Output:
{
success: boolean;
message: string;
results: SyncResult[];
stats: { successful: number; failed: number; total: number; };
}Purpose: Get installation statistics.
Input: None
Output:
{
totalInstallations: number;
activeInstallations: number;
suspendedInstallations: number;
totalRepositories: number;
totalTasks: number;
recentInstallations: number;
healthyPercentage: number;
}Example Usage:
# List all installations
curl "https://your-app.vercel.app/api/trpc/admin.installations.list"
# Get installation details
curl "https://your-app.vercel.app/api/trpc/admin.installations.detail?input={\"installationId\":123}"
# Sync specific installation
curl -X POST "https://your-app.vercel.app/api/trpc/admin.installations.sync" \
-H "Content-Type: application/json" \
-d '{"installationId": 123}'
# Get installation statistics
curl "https://your-app.vercel.app/api/trpc/admin.installations.stats"Purpose: Monitor webhook system health and processing status.
Purpose: Check webhook processing system health.
Input: None
Output:
{
status: "healthy" | "unhealthy";
webhookSecret: boolean; // Whether secret is configured
recentProcessing: {
successful: number;
failed: number;
last24Hours: number;
}
timestamp: string;
}Example Usage:
curl "https://your-app.vercel.app/api/trpc/webhook.health"Create a simple monitoring script:
// monitor.js
async function getSystemStatus() {
const baseUrl = "https://your-app.vercel.app/api/trpc";
// Get overall health
const health = await fetch(`${baseUrl}/admin.health`).then((r) => r.json());
// Get task statistics
const stats = await fetch(`${baseUrl}/tasks.stats`).then((r) => r.json());
// Get recent logs
const logs = await fetch(`${baseUrl}/admin.logs?input={"limit":5}`).then(
(r) => r.json(),
);
console.log("System Health:", health);
console.log("Task Stats:", stats);
console.log("Recent Logs:", logs.logs);
}
getSystemStatus();// bulk-retry.js
async function retryAllTasks() {
const response = await fetch(
"https://your-app.vercel.app/api/trpc/admin.retryAll",
{
method: "POST",
headers: { "Content-Type": "application/json" },
},
);
const result = await response.json();
console.log("Retry Results:", result);
}
retryAllTasks();// task-manager.js
async function manageTask(taskId, shouldRetry) {
// Update task status
const updateResponse = await fetch(
"https://your-app.vercel.app/api/trpc/tasks.updateStatus",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id: taskId, flaggedForRetry: shouldRetry }),
},
);
if (shouldRetry) {
// Immediately retry the task
const retryResponse = await fetch(
"https://your-app.vercel.app/api/trpc/tasks.retry",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id: taskId }),
},
);
console.log("Retry Result:", await retryResponse.json());
}
}
// Flag task 123 for retry and execute immediately
manageTask(123, true);All endpoints return standardized error responses:
{
error: {
code: "INTERNAL_SERVER_ERROR" | "BAD_REQUEST" | "NOT_FOUND";
message: string;
data?: {
// Additional error context
};
}
}To test endpoints locally:
- Start the development server:
pnpm dev - Visit
http://localhost:3000/api/trpcfor the tRPC panel (if enabled) - Use the examples above with
http://localhost:3000as the base URL