Button

Use a button on an image to trigger an action.

The Button Model

A job completion from imagine will return a button object. You can subsequently invoke follow up actions on the same image by using the buttonMessageId and button from the previous response.

Properties

  • Name
    buttonMessageId
    Type
    string
    Description

    The message ID of the image that contains the button. You need this to invoke the follow up action.

  • Name
    button
    Type
    string
    Description

    A button ID from the image. You need this to invoke the follow up action.


POST/v1/button

Invoke a Button

After an image generation, you can use the response and the button model in order to perform various actions including reroll, upscaling and inpainting.

Optional attributes

  • Name
    ref (optional)
    Type
    string
    Description

    A unique identifier for the job.

  • Name
    webhookOverride (optional)
    Type
    string
    Description

    A webhook URL to override the default webhook for this job.

Request

POST
/v1/button
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer {token}");

var raw = JSON.stringify({
  "button": "U1",
  "buttonMessageId": "button-message-id",
  "ref": "your-ref",
  "webhookOverride": "https://your-webhook.com"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.justimagineapi.org/v1/button", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Response

{
  "messageId": "message-id",
}

GET/v1/message/:messageId

Get The Completion Response

The completion response will automatically be sent to your webhook when the image is ready. You can see more about getting messages here.