> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quedup.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Job Types

> Explore different job configurations and use cases

# 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:

```json theme={null}
{
  "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\": \"user@example.com\"}"
}
```

### Future Event Scheduling

Schedule a follow-up task for 24 hours later:

```json theme={null}
{
  "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:

```json theme={null}
{
  "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:

```json theme={null}
{
  "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:

```json theme={null}
{
  "name": "Health Check",
  "url": "https://api.yourapp.com/health-check",
  "method": "GET",
  "schedule": "0 * * * *"
}
```

### Weekly Jobs

Generate weekly reports every Monday at 9 AM:

```json theme={null}
{
  "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:

```json theme={null}
{
  "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:

```json theme={null}
{
  "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:

```json theme={null}
{
  "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:

```json theme={null}
{
  "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

<AccordionGroup>
  <Accordion title="E-commerce">
    * **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
  </Accordion>

  <Accordion title="SaaS Applications">
    * **Usage Reports**: Generate daily usage reports
    * **Billing**: Process monthly subscriptions
    * **Data Backup**: Backup user data nightly
    * **Cleanup**: Remove expired sessions weekly
  </Accordion>

  <Accordion title="Content Management">
    * **Publishing**: Publish scheduled content
    * **SEO**: Generate sitemaps daily
    * **Analytics**: Sync analytics data hourly
    * **Backup**: Backup content weekly
  </Accordion>

  <Accordion title="DevOps & Monitoring">
    * **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
  </Accordion>
</AccordionGroup>

## Cron Expression Reference

<CodeGroup>
  ```bash Every Minute theme={null}
  * * * * *

  # 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
  ```
</CodeGroup>

## Best Practices

### Job Naming

Use descriptive names that clearly indicate the job's purpose:

```json theme={null}
{
  "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

<CardGroup cols={2}>
  <Card title="Getting Started" icon="rocket" href="/getting-started">
    Create your first job
  </Card>

  <Card title="Concepts" icon="lightbulb" href="/concepts">
    Learn how QuedUp works
  </Card>
</CardGroup>

<Tip>
  Start with simple one-time jobs to test your endpoints, then move on to recurring jobs once you're comfortable with the platform.
</Tip>
