Retrieve the seed.

October 7, 2024

Table of contents

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

Retrieve the seed and four separate upscaled images for the following completed jobs:

https://api.useapi.net/v2/jobs/seed_async

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
Request Body
{
    "jobid": "jobid",
    "discord": "Discord token",
    "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.

  • 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.

  • 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.

    If you specify the optional parameter replyUrl the API will call the provided replyUrl with task progress updates until the task is complete or fails.

    {
        "jobid": "<jobid>",
        "verb": "seed_async",
        "status": "started",
        "created": "2023-09-09T20:19:57.073Z",
        "updated": "2023-09-09T20:19:58.536Z",
        "parentJobId": "<jobid>",
        "discord": "<ABC…secured…xyz>",
        "channel": "<Discord channel id>",
        "replyUrl": "https://webhook.site/abc",
        "replyRef": "<your optional reference id>",
        "code": 200
    }
    

    If the seed was already retrieved for the provided jobid API will return the original job along with the seed as shown below. You can extract seed value from field seed.value and generated images from seed.attachments array.

    {
        "jobid": "<jobid>",
        "verb": "imagine|button|blend",
        "status": "completed",
        "created": "2023-09-09T02:04:49.667Z",
        "updated": "2023-09-09T02:04:53.490Z",
        "content": "**Steampunk cat --s 750 --v 5.2** - <@Discord user id> (fast)",
        "attachments": [
           {
              "id": "<id>",
              "url": "<image url>",
              "proxy_url": "<original image proxy url>",
              "width": 2048,
              "height": 2048,
              "size": 1234567,
              "placeholder_version": 1,
              "placeholder": "<placeholder>",
              "filename": "<image file name>",
              "content_type": "<image content-type>"
           }
        ],    
        "seed": {
            "content": "**<prompt>**\n**Job ID**: <Job ID>n**seed** <seed>",
            "value": 123456789,
            "attachments": [
              {
                  "id": "<id 1>",
                  "url": "<image 1 url>",
                  "proxy_url": "<image 1 proxy url>",
                  "width": 1024,
                  "height": 1024,
                  "size": 12345,
                  "placeholder_version": 1,
                  "placeholder": "<placeholder 1>",
                  "filename": "<image 1 file name>",
                    "content_type": "<image 1 content-type>"
                },
                {
                  "id": "<id 2> …the rest of JSON object omitted for brevity…",
                },
                {
                  "id": "<id 3> …the rest of JSON object omitted for brevity…",
                },
                {
                  "id": "<id 4> …the rest of JSON object omitted for brevity…",
                }
            ]
        }, 
        "prompt": "Steampunk cat",
        "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",
        "code": 200
    }
    
  • 400 Bad Request

    {
        "error": 
          "<jobid> is missing"
          "<replyRef | replyUrl> is too long"
          "Parent job must be completed"
          "Job of type <verb> not supported"
          "<discord | channel> is missing"
        "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 parent job <jobid>",
        "code": 404
    }
    
  • 596 Pending mod message

    API detected Midjourney pending moderation message and CAPTCHA account verification requests. 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": "seed_async",
        "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>",
        "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
  parentJobId: string,
  verb: 'seed_async' | 'imagine' | 'button' | 'blend',
  status: 'started' | 'failed',
  seed: { 
    value: number, // Parsed seed number
    content: string // Original content message returned by Midjourney for a seed request
    attachments: { // Seed images
      id: string,
      url: string,
      proxy_url: string,
      width: number,
      height: number,
      size: number,
      placeholder_version: number,
      placeholder: string,
      filename: string,
      content_type: string}[],
  },
  created: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC
  updated: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC
  discord: string, // Provided for debugging purposes only, contains the first 3 and the last 3 characters of the original value
  channel: string,
  replyUrl: string,
  replyRef: string,
  messageId: string,
  content: string, // Contains message generated by Midjourney reflecting current generation parameters and progress
  attachments: {
    id: string,
    url: string,
    proxy_url: string,
    width: number,
    height: number,
    size: number,
    placeholder_version: number,
    placeholder: string,
    filename: string,
    content_type: string}[], 
  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/seed_async \
         -d '{"jobid": "…"}'
    
  • const apiUrl = "https://api.useapi.net/v2/jobs/seed_async"; 
    const token = "API token";
    const jobid = "Completed jobs/imagine, jobs/button or jobs/blend jobid";      
    const data = { 
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json' }
    };
    data.body = JSON.stringify({ jobid });
    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/seed_async" 
    token = "API token"
    jobid = "Completed jobs/imagine, jobs/button or jobs/blend jobid"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    body = {
        "jobid": f"{jobid}", 
    }
    response = requests.post(apiUrl, headers=headers, json=body)
    print(response, response.json())
    
Try It