Skip to main content

Job Types & Examples

QuedUp supports two main types of jobs: one-time jobs for immediate or future execution, and recurring jobs for regular tasks. This guide covers both types with practical examples and use cases.

One-time Jobs

One-time jobs execute once at a specified time in the future. Perfect for delayed processing, reminders, or scheduled events.

Basic One-time Job

Send a welcome email 5 minutes after user registration:
{
  "name": "Welcome Email",
  "url": "https://api.yourapp.com/send-welcome-email",
  "method": "POST",
  "run_at": "2024-01-15T10:05:00Z",
  "headers": {
    "Authorization": "Bearer your-api-key",
    "Content-Type": "application/json"
  },
  "body": "{\"user_id\": \"12345\", \"email\": \"[email protected]\"}"
}

Future Event Scheduling

Schedule a follow-up task for 24 hours later:
{
  "name": "Follow-up Survey",
  "url": "https://api.yourapp.com/send-survey",
  "method": "POST",
  "run_at": "2024-01-16T10:00:00Z",
  "body": "{\"user_id\": \"12345\", \"survey_type\": \"follow_up\"}"
}

Delayed Processing

Process uploaded files after a delay:
{
  "name": "Process Upload",
  "url": "https://api.yourapp.com/process-file",
  "method": "POST",
  "run_at": "2024-01-15T10:30:00Z",
  "headers": {
    "X-File-ID": "file_abc123"
  },
  "body": "{\"file_path\": \"/uploads/document.pdf\"}"
}

Recurring Jobs

Recurring jobs execute on a schedule defined by cron expressions. Ideal for maintenance tasks, data synchronization, and regular processing.

Daily Jobs

Run a daily database backup at 2 AM:
{
  "name": "Daily Database Backup",
  "url": "https://api.yourapp.com/backup-database",
  "method": "POST",
  "schedule": "0 2 * * *",
  "headers": {
    "Authorization": "Bearer your-backup-key"
  },
  "body": "{\"backup_type\": \"full\", \"retention_days\": 30}"
}

Hourly Jobs

Check system health every hour:
{
  "name": "Health Check",
  "url": "https://api.yourapp.com/health-check",
  "method": "GET",
  "schedule": "0 * * * *"
}

Weekly Jobs

Generate weekly reports every Monday at 9 AM:
{
  "name": "Weekly Analytics Report",
  "url": "https://api.yourapp.com/generate-report",
  "method": "POST",
  "schedule": "0 9 * * 1",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": "{\"report_type\": \"weekly\", \"date_range\": \"last_7_days\"}"
}

Monthly Jobs

Clean up old files on the first day of each month:
{
  "name": "Monthly Cleanup",
  "url": "https://api.yourapp.com/cleanup-files",
  "method": "POST",
  "schedule": "0 0 1 * *",
  "body": "{\"cleanup_type\": \"old_files\", \"older_than_days\": 90}"
}

Advanced Examples

Data Synchronization

Sync data between services every 15 minutes:
{
  "name": "User Data Sync",
  "url": "https://api.yourapp.com/sync-users",
  "method": "POST",
  "schedule": "*/15 * * * *",
  "headers": {
    "X-Sync-Source": "crm",
    "X-Sync-Target": "analytics"
  },
  "body": "{\"sync_type\": \"incremental\", \"last_sync\": \"auto\"}"
}

API Rate Limit Management

Process queued requests every 5 minutes to respect rate limits:
{
  "name": "Process API Queue",
  "url": "https://api.yourapp.com/process-queue",
  "method": "POST",
  "schedule": "*/5 * * * *",
  "headers": {
    "X-Queue-Type": "api_requests"
  },
  "body": "{\"batch_size\": 100, \"rate_limit\": \"1000/hour\"}"
}

Multi-step Workflow

Trigger a complex workflow with multiple steps:
{
  "name": "Monthly Billing Process",
  "url": "https://api.yourapp.com/start-billing-workflow",
  "method": "POST",
  "schedule": "0 8 1 * *",
  "body": "{\"workflow_id\": \"monthly_billing\", \"steps\": [\"calculate\", \"invoice\", \"notify\"]}"
}

Common Use Cases

  • Inventory Sync: Sync inventory with suppliers every hour
  • Order Processing: Process pending orders every 15 minutes
  • Price Updates: Update product prices daily
  • Abandoned Cart: Send reminder emails after 24 hours
  • Usage Reports: Generate daily usage reports
  • Billing: Process monthly subscriptions
  • Data Backup: Backup user data nightly
  • Cleanup: Remove expired sessions weekly
  • Publishing: Publish scheduled content
  • SEO: Generate sitemaps daily
  • Analytics: Sync analytics data hourly
  • Backup: Backup content weekly
  • Health Checks: Monitor service health every 5 minutes
  • Log Rotation: Rotate logs daily
  • Metrics Collection: Collect system metrics every minute
  • Security Scans: Run security scans weekly

Cron Expression Reference

* * * * *

# Every 5 minutes
*/5 * * * *

# Every 15 minutes
*/15 * * * *

# Every hour
0 * * * *

# Every 2 hours
0 */2 * * *

# Every day at midnight
0 0 * * *

# Every day at 2 AM
0 2 * * *

# Every weekday at 9 AM
0 9 * * 1-5

# Every Sunday at 10 AM
0 10 * * 0

# Every first day of the month
0 0 1 * *

# Every Monday
0 0 * * 1

Best Practices

Job Naming

Use descriptive names that clearly indicate the job’s purpose:
{
  "name": "Daily User Analytics Sync",
  "name": "Weekly Database Maintenance",
  "name": "Monthly Billing Process",
  "name": "Hourly Health Check"
}

Error Handling

Design your endpoints to handle failures gracefully:
  • Return appropriate HTTP status codes (200 for success, 4xx/5xx for errors)
  • Log errors for debugging
  • Make operations idempotent when possible

Scheduling Considerations

  • Avoid Overlap: Don’t schedule jobs too frequently to prevent overlap
  • Peak Hours: Consider your application’s peak usage times
  • Dependencies: Account for dependencies between jobs
  • Testing: Test schedules with one-time jobs first

Resource Management

  • Timeout Handling: Ensure endpoints respond within 15 minutes. Jobs running longer than this will be terminated and retried according to the retry policy.
  • Rate Limiting: Respect external API rate limits
  • Batch Processing: Process data in batches to avoid overwhelming systems
Start with simple one-time jobs to test your endpoints, then move on to recurring jobs once you’re comfortable with the platform.