DELETE
/
jobs
/
{job_id}
curl -X DELETE "https://visionapi.unsiloed.ai/jobs/b2094b38-e432-44b6-a5d0-67bed07d5de1" \
  -H "X-API-Key: your-api-key"
{
  "message": "Job b2094b38-e432-44b6-a5d0-67bed07d5de1 deleted"
}

Overview

The Delete Job endpoint removes a job and its associated data from the system. This is useful for cleaning up completed jobs or cancelling jobs that are no longer needed.

Deleting a job will permanently remove all associated data including results. This action cannot be undone.

Request

job_id
string
required

The unique identifier of the job to delete

X-API-Key
string

API key for authentication (optional for some endpoints)

Response

message
string

Confirmation message that the job was deleted

curl -X DELETE "https://visionapi.unsiloed.ai/jobs/b2094b38-e432-44b6-a5d0-67bed07d5de1" \
  -H "X-API-Key: your-api-key"
{
  "message": "Job b2094b38-e432-44b6-a5d0-67bed07d5de1 deleted"
}

When to Delete Jobs

Bulk Cleanup Example

Here’s an example of cleaning up old completed jobs:

import requests
from datetime import datetime, timedelta

def cleanup_old_jobs(api_key, days_old=7):
    """Delete jobs older than specified days"""
    
    headers = {"X-API-Key": api_key}
    
    # This would require a list jobs endpoint (not currently implemented)
    # For now, you would need to track job IDs manually
    old_job_ids = [
        "job1_id_here",
        "job2_id_here",
        "job3_id_here"
    ]
    
    deleted_count = 0
    
    for job_id in old_job_ids:
        try:
            # Check job status first
            status_response = requests.get(
                f"https://visionapi.unsiloed.ai/jobs/{job_id}",
                headers=headers
            )
            
            if status_response.status_code == 200:
                job = status_response.json()
                
                # Parse created_at timestamp
                created_at = datetime.fromisoformat(job['created_at'].replace('Z', '+00:00'))
                cutoff_date = datetime.now(created_at.tzinfo) - timedelta(days=days_old)
                
                if created_at < cutoff_date and job['status'] in ['COMPLETED', 'FAILED']:
                    # Delete the old job
                    delete_response = requests.delete(
                        f"https://visionapi.unsiloed.ai/jobs/{job_id}",
                        headers=headers
                    )
                    
                    if delete_response.status_code == 200:
                        print(f"Deleted job: {job_id}")
                        deleted_count += 1
                    else:
                        print(f"Failed to delete job {job_id}: {delete_response.text}")
                        
        except Exception as e:
            print(f"Error processing job {job_id}: {e}")
    
    print(f"Cleanup complete. Deleted {deleted_count} jobs.")

# Usage
cleanup_old_jobs("your-api-key", days_old=7)

Best Practices

Check Status First: Before deleting, check the job status to ensure you don’t accidentally delete a job that’s still processing.

Save Results: Always retrieve and save important results before deleting completed jobs.

Regular Cleanup: Implement regular cleanup routines to manage storage costs and keep your job list manageable.

Permanent Action: Job deletion is permanent and cannot be undone. Make sure you have saved any important results.

Error Handling

Rate Limits

  • Delete Operations: Limited to prevent abuse
  • Bulk Operations: Consider implementing delays between bulk deletions

Deletion operations are generally not rate-limited as strictly as other operations, but excessive deletion requests may be throttled.