Retrieve Asset URL by Asset ID

Once you’ve generated an asset using the Scenario API, it will be referenced in the job response by one or more assetIds. To access the final downloadable URL of the generated asset, you need to call the GET /assets/{assetId} endpoint.

This guide explains how to retrieve the URL of a generated asset step by step, with examples in multiple programming languages.

Endpoint

The endpoint to retrieve a specific asset is:

GET https://api.cloud.scenario.com/v1/assets/{assetId}

You need to provide the assetId obtained from the job’s metadata response.

Workflow Overview

  1. Trigger a generation job (e.g., txt2img, img2img, ControlNet, or IP-Adapter).
  2. Poll the job status using GET /jobs/{jobId} until the status is success.
  3. Extract the assetIds from the job metadata response.
  4. Call GET /assets/{assetId} for each assetId to retrieve its details, including the asset.url field containing the final asset URL.

Example Flow

1. Get assetIds from a completed job

When you poll a job until it’s completed, the response will look like this:

{
  "job": {
    "jobId": "job_abc123",
    "status": "success",
    "metadata": {
      "assetIds": [
        "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ"
      ]
    }
  }
}

Here, you need to take asset_1gHMbHjSjWYLyAnd7ZxzPkcQ and use it in the next step.


2. Fetch Asset URL using GET /assets/{assetId}

When you call the asset endpoint, you’ll get a detailed JSON response:

{
  "asset": {
    "id": "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ",
    "url": "https://cdn.scenario.com/assets/asset_1gHMbHjSjWYLyAnd7ZxzPkcQ.png",
    "createdAt": "2025-07-15T10:00:00Z",
    "metadata": {
      "prompt": "a mystical forest with glowing mushrooms"
    }
  }
}

The asset.url field is the direct downloadable URL of the generated asset.


Code Examples

Here’s how to fetch the URL in different programming languages.

cURL

curl -X GET \
  -u "YOUR_API_KEY:YOUR_API_SECRET" \
  https://api.cloud.scenario.com/v1/assets/asset_1gHMbHjSjWYLyAnd7ZxzPkcQ

Response:

{
  "asset": {
    "id": "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ",
    "url": "https://cdn.scenario.com/assets/asset_1gHMbHjSjWYLyAnd7ZxzPkcQ.png"
  }
}

Python

import requests

api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
asset_id = "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ"

url = f"https://api.cloud.scenario.com/v1/assets/{asset_id}"

response = requests.get(url, auth=(api_key, api_secret))

if response.status_code == 200:
    data = response.json()
    print("Asset URL:", data["asset"]["url"])
else:
    print(f"Error: {response.status_code} - {response.text}")

Node.js

const fetch = require("node-fetch");

const apiKey = "YOUR_API_KEY";
const apiSecret = "YOUR_API_SECRET";
const assetId = "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ";
const credentials = Buffer.from(`${apiKey}:${apiSecret}`).toString("base64");

async function getAssetUrl() {
  const url = `https://api.cloud.scenario.com/v1/assets/${assetId}`;
  const headers = {
    Authorization: `Basic ${credentials}`,
  };

  const response = await fetch(url, { headers });
  const data = await response.json();

  if (response.ok) {
    console.log("Asset URL:", data.asset.url);
  } else {
    console.error(`Error: ${response.status} - ${JSON.stringify(data)}`);
  }
}

getAssetUrl();

Full End-to-End Example

Here’s the complete flow in pseudo-steps:

  1. Trigger a generation job → receive jobId
  2. Poll GET /jobs/{jobId} until status is success
  3. Extract assetIds from job.metadata
  4. For each assetId, call GET /assets/{assetId}
  5. Retrieve asset.url for the downloadable asset