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
Section titled “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
Section titled “Workflow Overview”- Trigger a generation job (e.g.,
txt2img,img2img, ControlNet, or IP-Adapter). - Poll the job status using
GET /jobs/{jobId}until the status issuccess. - Extract the
assetIdsfrom the job metadata response. - Call
GET /assets/{assetId}for each assetId to retrieve its details, including theasset.urlfield containing the final asset URL.
Example Flow
Section titled “Example Flow”1. Get assetIds from a completed job
Section titled “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}
Section titled “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
Section titled “Code Examples”Here’s how to fetch the URL in different programming languages.
curl -X GET \ -u "YOUR_API_KEY:YOUR_API_SECRET" \ https://api.cloud.scenario.com/v1/assets/asset_1gHMbHjSjWYLyAnd7ZxzPkcQResponse:
{ "asset": { "id": "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ", "url": "https://cdn.scenario.com/assets/asset_1gHMbHjSjWYLyAnd7ZxzPkcQ.png" }}Python
Section titled “Python”from scenario_sdk import Scenario
client = Scenario( api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET",)
asset_id = "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ"
response = client.assets.retrieve(asset_id)print("Asset URL:", response.asset.url)TypeScript
Section titled “TypeScript”import Scenario from '@scenario-labs/sdk';
const client = new Scenario({ apiKey: 'YOUR_API_KEY', apiSecret: 'YOUR_API_SECRET',});
const assetId = 'asset_1gHMbHjSjWYLyAnd7ZxzPkcQ';
async function getAssetUrl() { const response = await client.assets.retrieve(assetId); console.log('Asset URL:', response.asset.url);}
getAssetUrl();Full End-to-End Example
Section titled “Full End-to-End Example”Here’s the complete flow in pseudo-steps:
- Trigger a generation job → receive
jobId - Poll
GET /jobs/{jobId}untilstatusissuccess - Extract
assetIdsfromjob.metadata - For each
assetId, callGET /assets/{assetId} - Retrieve
asset.urlfor the downloadable asset