Midjourney upscale or create variations and enhance or modify buttons

Table of contents

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

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/v2/jobs/button

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
Request Body
{
    "jobid": "jobid",
    "button": "button",
    "prompt": "required for button Custom Zoom",
    "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 button.

  • prompt is optional, it is required for Custom Zoom button, see Custom Zoom.
    When Remix Mode is active, the buttons V1, V2, V3, V4, Vary (Strong), Vary (Subtle), ⬅️, ➡️, ⬆️, ⬇️ and 🔄 also accept a prompt.

  • discord is optional, if provided will override discord value of referenced above jobid, see Setup Midjourney for details. If the channel corresponding to the jobid mentioned above has an account configured under account/midjourney, the current account’s discord value will be used if it is not explicitly provided. This ensures that even jobs executed some time ago can still be successfully executed by this endpoint, even after possible changes to the account’s discord value.

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

  • replyUrl is optional, if not provided value from account will be used.
    Place here your callback URL. API will call the provided replyUrl once job completed or failed.
    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>",
        "discord": "<ABC…secured…xyz>",
        "channel": "<Discord channel id>",
        "server": "<Discord server id>",
        "maxJobs": 3,
        "replyUrl": "https://webhook.site/abc",
        "replyRef": "<your optional reference id>",
        "content": "<Discord message content>",
        "messageId": "<Discord message id>",
        "timestamp": "2023-09-09T20:19:57.926000+00:00",
        "code": 200
    }
    
  • 400 Bad Request

    {
        "error": 
          "button <button> not supported"
          "<jobid | button> is missing"
          "<replyRef | replyUrl> is too long"
        "code": 400
    }
    
    {
        "error": "button <button> not found in job <jobid> buttons <array>",
        "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
    }
    
  • 409 Conflict

    {
      "error": "Button <U1 | U2 | U3 | U4> already executed by job <jobid>",
      "button": "<button>",
      "jobid": "<jobid>",
      "code": 409
    }
    
  • 422 Unprocessable Content

    Moderated message or invalid prompt params.

    {
        "error": "Action needed to continue",
        "errorDetails": "Sorry! Our AI moderators feel your prompt might be against our community standards.",
        "jobid": "<jobid>",
        "status": "moderated",
        "code": 422
    }
    
    {
        "error": "Invalid parameter",
        "errorDetails": "Unrecognized parameter(s): `size`",
        "jobid": "<jobid>",
        "status": "moderated",
        "code": 422
    }
    
  • 429 Too Many Requests

    Wait in a loop for at least 10..30 seconds and retry again.

    There are two possible cases for API response 429.

    1. 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
      }
      
    2. The API received an HTTP status 429 from the Discord API when it attempted to POST to the /interactions endpoint. Under normal circumstances, this should be a rare occurrence because the API is designed to strictly adhere to Discord rate limits. However, in certain scenarios, Discord may still issue a 429 response.
      {
       "error": "Discord /interactions failed with HTTP status 429",
       "errorDetails": "{\"global\":true,\"message\":\"You are being rate limited.\",\"retry_after\":10}",
       "code": 429
      }
      
  • 504 Job queued

    Job queued. The API will not be able to track the progress of this job, although it will still be processed by Midjourney. You may want to adjust the maxJobs number to a lower value for the next several minutes.

    You should not receive this error under normal circumstances unless you have specified a maxJobs parameter higher than your Midjourney subscription supports, or if you are using the Midjourney bot outside of API interactions. On occasions when Midjourney is releasing new updates or experiencing technical issues, jobs may be paused for an extended period of time. Our API will mark all jobs running over 30 minutes as failed. When Midjourney comes back online, it will attempt to complete previously paused jobs, and you may encounter a conflict if you try to submit a new job at the same time. Although this happens very rarely, we have decided to add an extra layer to ensure such cases are detected.

    {
        "error": "Job queued",
        "jobid": "<jobid>",
        "status": "failed",
        "code": 504
    }
    
  • 596 Pending mod message

    API detected Midjourney pending moderation message. All API calls will be halted and returned 569 response status code until you clear this field by posting to account/midjourney/channel/reset. We will also send you an email when this error ocurred. The best course of action is to log into your Discord account and acknowledge the Midjourney moderation message to prevent a potential ban on your Midjourney account.

    {
        "jobid": "<jobid>",
        "verb": "button",
        "button": "V1",
        "parentJobId": "<jobid>",
        "status": "failed",
        "created": "2023-09-09T02:04:49.667Z",
        "updated": "2023-09-09T02:04:53.490Z",
        "discord": "<ABC…secured…xyz>",
        "channel": "<Discord channel id>",
        "server": "<Discord server id>",
        "maxJobs": 3,
        "replyUrl": "https://webhook.site/abc",
        "replyRef": "<your optional reference id>",
        "messageId": "<Discord message id>",
        "timestamp": "2023-09-09T02:04:51.926000+00:00",
        "error": "Pending mod message",
        "errorDetails": "You have a pending moderation message. Please acknowledge it before using the bot further.",
        "code": 596
    }
    
    {
        "error": "Your Discord account has received a pending moderation message from Midjourney. Please address this issue and reset the /account pendingModMessage before making any new API calls.",
        "code": 596
    }
    
Model
{ // TypeScript, all fields are optional
  jobid: string, // Use returned jobid value to retrieve job status and results
  verb: 'button',
  status: 'started' | 'moderated' | 'failed',
  created: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC
  updated: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC
  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)' | 'Upscale (Subtle)' | 'Upscale (Creative)' |
          'Redo Upscale (2x)' | 'Redo Upscale (4x)' | 'Redo Upscale (Subtle)' | 'Redo Upscale (Creative)' |
          'Make Variations' | 'Remaster' | 'Custom Zoom',
  prompt: string, // Required for button Custom Zoom https://docs.midjourney.com/docs/zoom-out#custom-zoom
  parentJobId: string,
  discord: string, // Provided for debugging purposes only, contains the first 3 and the last 3 characters of the original value
  channel: string,
  server: string,
  maxJobs: number,
  replyUrl: string,
  replyRef: string,
  messageId: string,
  content: string, // Contains message generated by Midjourney reflecting current generation parameters and progress
  timestamp: string,
  error: string,
  errorDetails: string,
  executingJobs: string[],
  code: number
}
Examples
  • curl -H "Accept: application/json" \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer …" \
         -X POST https://api.useapi.net/v2/jobs/button \
         -d '{"jobid": "…", "button": "…"}'
    
  • const apiUrl = "https://api.useapi.net/v2/jobs/button"; 
    const token = "API token";
    const jobid = "Completed jobs/imagine, jobs/button or jobs/blend 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/v2/jobs/button" 
    token = "API token"
    jobid = "Completed jobs/imagine, jobs/button or jobs/blend 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