Cancel job

Table of contents

  1. Request Headers
  2. Query Parameters
  3. Responses
  4. Examples
  5. Try It

Important
We will be officially sunsetting v1. Starting from March 1, 2024 all calls will be routed to v2 endpoints. Although this change will be transparent to our customers we strongly advise you to update your code to use the v2 endpoints as they provide many more options.

Cancel execution of job created by

https://api.useapi.net/v1/jobs/cancel/?jobid=jobid

Request Headers
Authorization: Bearer {API token}
Query Parameters
Responses
  • {
        "jobid": "<jobid>",
        "status": "cancelled"
    }   "code": 200
    
  • 400 Bad Request

    {
        "error": "Query param jobid not provided",
        "code": 400
    }
    
  • 401 Unauthorized

    {
        "error": "Unauthorized",
        "code": 401
    }
    
  • 404 Not Found

    {
        "error": "Unable to locate job <jobid>",
        "code": 404
    }
    
Examples
  • curl https://api.useapi.net/v1/jobs/cancel/?jobid=\
       -H "Accept: application/json" \
       -H "Authorization: Bearer …" 
    
  • const token = "API token";
    const jobid = "jobid returned by jobs/imagine or jobs/button";      
    const apiUrl = `https://api.useapi.net/v1/jobs/cancel/?jobid=${jobid}`; 
    const response = await fetch(apiUrl, {
      headers: {
        "Authorization": `Bearer ${token}`,
      },
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    token = "API token"
    jobid = "jobid returned by jobs/imagine or jobs/button"
    apiUrl = f"https://api.useapi.net/v1/jobs/cancel/?jobid={jobid}"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    response = requests.get(apiUrl, headers=headers)
    print(response, response.json())
    
Try It