Cancel Midjourney job

December 2023 (October 7, 2024)

Table of contents

  1. Request Headers
  2. Query Parameter
  3. Responses
  4. Model
  5. Examples
  6. Try It

Cancel execution of job created by

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

Request Headers
Authorization: Bearer {API token}
Query Parameter

jobid is required, use value returned by

Responses
  • {
        "jobid": "<jobid>",
        "status": "cancelled"
    }   "code": 200
    
  • 400 Bad Request

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

    {
        "error": "Unauthorized",
        "code": 401
    }
    
  • 402 Payment Required

    {
        "error": "Account has no subscription or subscription expired",
        "code": 402
    }
    
  • 404 Not Found

    {
        "error": "Unable to locate job <jobid>",
        "code": 404
    }
    
Model
{ // TypeScript, all fields are optional
  jobid: string, 
  status: 'created' | 'started' | 'moderated' | 'progress' | 
          'completed' | 'failed' | 'cancelled',
  error: string,
  errorDetails: string,
  code: number
}
Examples
  • curl https://api.useapi.net/v2/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/v2/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/v2/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