Midjourney upscale or create variations and enhance or modify buttons

Table of contents

  1. Request Headers
  2. Request Body
  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.

Use this endpoint to execute Midjourney upscale or create variations and enhance or modify button commands. Results obtained as a callback via optional parameter replyUrl or by querying jobs/?jobid=jobid endpoint.

Your current Midjourney Settings and Presets will be used, log in to your Discord Midjourney account to adjust them to your liking.

It is important not to use the Midjourney account setup for API access for any purposes other than its intended use, such as executing /imagine or any other Midjourney commands manually or in conjunction with any other automation tools. The useapi.net API internally tracks the usage of the Midjourney account, including the number of currently active executions. Using it for other activities may cause API to function incorrectly.

https://api.useapi.net/v1/jobs/button

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
Request Body
{
    "jobid": "jobid",
    "button": "button",
    "discord": "Discord token",
    "maxJobs": 3,
    "replyUrl": "Place your call back URL here",
    "replyRef": "Place your reference id here"
}
  • jobid is required, jobid of successfully completed (status set to completed) jobs/imagine, jobs/button or jobs/blend job.

  • button is required, button from buttons array of job referenced via jobid above, see buttons.

  • discord is optional, if provided will override discord value of referenced above jobid, see Setup Midjourney for details.

  • maxJobs is optional, if not provided defaulted to 3.
    This value should be same or less than your Midjourney subscription plan Maximum Concurrent Jobs. Currently it should be 3 or less for Basic and Standard plans and 12 or less for Pro and Mega plans.
    Important Specifying higher number than supported by your Midjourney subscription will prevent API from functioning properly.

  • replyUrl is optional, place here your callback URL. API will call provided replyUrl once generation completed.
    Maximum length 1024 characters.
    We recommend using sites like webhook.site to test callback URL functionality.

  • replyRef is optional, place here your reference id which will be stored and returned along with this job response / result.
    Maximum length 1024 characters.

Responses
  • 200 OK

    Use returned jobid to retrieve job status and results.

    {
        "jobid": "<jobid>",
        "verb": "button",
        "status": "started",
        "created": "2023-09-09T20:19:57.073Z",
        "updated": "2023-09-09T20:19:58.536Z",
        "button": "V1",
        "parentJobId": "<jobid>",
        "channel": "<Discord channel id>",
        "server": "<Discord server id>",
        "maxJobs": 3,
        "code": 200
    }
    
    Model
    {
        jobid: string,
        verb: 'button',
        status: 'started',
        created: Date,
        updated: Date,
        button: 'U1' | 'U2' | 'U3' | 'U4' | 'V1' | 'V2' | 'V3' | 'V4' |
                '⬅️' | '➡️' | '⬆️' | '⬇️' | '🔄' |
                'Vary (Strong)' | 'Vary (Subtle)' | 'Zoom Out 1.5x' | 'Zoom Out 2x' | 'Make Square' |
                'Upscale (2x)' | 'Upscale (4x)' | 'Redo Upscale (2x)' | 'Redo Upscale (4x)' | 
                'Make Variations' | 'Remaster',
        channel: string,
        server: string,
        maxJobs: number,
        code: 200
    }
    
  • 400 Bad Request

    {
        "error": "button <button> not supported",
        "code": 400
    }
    
    {
        "error": "button <button> not found in job <jobid> buttons <array>",
        "code": 400
    }
    
  • 401 Unauthorized

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

    {
        "error": "Unable to locate job <jobid>",
        "code": 404
    }
    
  • 409 Conflict

    {
      "error": "Button <U1 | U2 | U3 | U4> already executed by job <jobid>",
      "button": "<button>",
      "jobid": "<jobid>",
      "code": 409
    }
    
  • 412 Precondition Failed

    {
        "error": "<jobid | button> is missing",
        "code": 412
    }
    
  • 413 Content Too Large

    {
        "error": "<replyRef | replyUrl> is too long",
        "code": 413
    }
    
  • 429 Too Many Requests

    API query is full and can not accept new jobs/button requests. Size of query defined by maxJobs optional parameter. Wait in a loop for at least 10..30 seconds and retry again.

    {
        "error": "Maximum of <maxJobs> jobs executing in parallel supported",
        "executingJobs": [
          "<jobid>",
          "<jobid>",
          "<jobid>"
        ],
        "code": 429
    }
    
Examples
  • curl -H "Accept: application/json" \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer …" \
         -X POST https://api.useapi.net/v1/jobs/button \
         -d '{"jobid": "…", "button": "…"}'
    
  • const apiUrl = "https://api.useapi.net/v1/jobs/button"; 
    const token = "API token";
    const jobid = "Completed jobs/imagine or jobs/button jobid";      
    const button = "Button from buttons array of above jobid";      
    const data = { 
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json' }
    };
    data.body = JSON.stringify({ 
      jobid, button
    });
    const response = await fetch(apiUrl, data);
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    apiUrl = "https://api.useapi.net/v1/jobs/button" 
    token = "API token"
    jobid = "Completed imagine or button jobid"
    button = "Button from buttons array of above jobid"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    body = {
        "jobid": f"{jobid}", 
        "button": f"{button}"
    }
    response = requests.post(apiUrl, headers=headers, json=body)
    print(response, response.json())
    
Try It