Uploads & assets
Upload files with signed tickets, confirm media and manage source assets and processed versions.
Check upload limits
Section titled “Check upload limits”Read the allowed formats and size/dimension/duration limits before sending a file. Upload acceptance does not guarantee every tool can process that source; individual tools have their own limits.
/api/v1/assets/upload-limitsRequest example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request GET 'https://www.chaozapi.com/api/v1/assets/upload-limits' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/upload-limits', { method: 'GET', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/upload-limits", method="GET", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("GET", "https://www.chaozapi.com/api/v1/assets/upload-limits", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::GET, "https://www.chaozapi.com/api/v1/assets/upload-limits") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/upload-limits")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("GET", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://www.chaozapi.com/api/v1/assets/upload-limits");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
imageobjectrequiredExpand fields / variants
maxAspectinteger · int64requiredmaxBytesinteger · int64requiredmaxDurationMsinteger · int64requiredmaxFrameRateinteger · int64requiredmaxFramesinteger · int64requiredmaxPixelsinteger · int64requiredmaxSideinteger · int64requiredminSideinteger · int64required
videoobjectrequiredExpand fields / variants
maxAspectinteger · int64requiredmaxBytesinteger · int64requiredmaxDurationMsinteger · int64requiredmaxFrameRateinteger · int64requiredmaxFramesinteger · int64requiredmaxPixelsinteger · int64requiredmaxSideinteger · int64requiredminSideinteger · int64required
Request an upload ticket
Section titled “Request an upload ticket”Send the file name, MIME type and exact byte length. Replace 123456 in the example with the size of your file. The 201 response contains assetId, uploadUrl, method, headers (an array of name/value pairs), fileField and expiresAt. Save this response locally as ticket.json for the next step; it contains a temporary signed URL, so keep it private.
/api/v1/assets/uploadsPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
Idempotency-Keyoptional | header | stringmaxLength: 128 · pattern: "^[A-Za-z0-9._:-]+$" |
Request body fields · application/json
estDurationMsinteger · int64optionalminimum: 0
estHeightinteger · int64optionalminimum: 1 · maximum: 65536
estWidthinteger · int64optionalminimum: 1 · maximum: 65536
mimeTypestringrequiredmultipartbooleanoptionalnamestringrequiredresumablebooleanoptionalroutingMode"auto" | "cloud"optionalserviceHintstringoptionalmaxLength: 64
sizeBytesinteger · int64required
Request example
# Set GLACIER_IDEMPOTENCY_KEY once per logical task; reuse it AND the body on retries.curl --include --fail-with-body --silent --show-error --max-time 60 \ --request POST 'https://www.chaozapi.com/api/v1/assets/uploads' \ --header "Authorization: Bearer $GLACIER_API_KEY" \ --header "Idempotency-Key: $GLACIER_IDEMPOTENCY_KEY" \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "input.png", "mimeType": "image/png", "sizeBytes": 123456}'// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const idempotencyKey = process.env.GLACIER_IDEMPOTENCY_KEY;if (!idempotencyKey) throw new Error('Set a stable GLACIER_IDEMPOTENCY_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/uploads', { method: 'POST', headers: { Authorization: `Bearer ${key}`, 'Idempotency-Key': idempotencyKey, 'Content-Type': 'application/json', }, body: JSON.stringify({ "name": "input.png", "mimeType": "image/png", "sizeBytes": 123456}), signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}headers["Idempotency-Key"] = os.environ["GLACIER_IDEMPOTENCY_KEY"]headers["Content-Type"] = "application/json"request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/uploads", method="POST", headers=headers, data="""{ "name": "input.png", "mimeType": "image/png", "sizeBytes": 123456}""".encode("utf-8"),)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "strings" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } idem := os.Getenv("GLACIER_IDEMPOTENCY_KEY") if idem == "" { panic("Set a stable GLACIER_IDEMPOTENCY_KEY") } req, err := http.NewRequest("POST", "https://www.chaozapi.com/api/v1/assets/uploads", strings.NewReader(`{ "name": "input.png", "mimeType": "image/png", "sizeBytes": 123456}`)) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) req.Header.Set("Idempotency-Key", idem) req.Header.Set("Content-Type", "application/json") client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::POST, "https://www.chaozapi.com/api/v1/assets/uploads") .bearer_auth(env::var("GLACIER_API_KEY")?) .header("Idempotency-Key", env::var("GLACIER_IDEMPOTENCY_KEY")?) .header("Content-Type", "application/json") .body(r#"{ "name": "input.png", "mimeType": "image/png", "sizeBytes": 123456}"#) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/uploads")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .header("Idempotency-Key", Objects.requireNonNull(System.getenv("GLACIER_IDEMPOTENCY_KEY"))) .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("""{ "name": "input.png", "mimeType": "image/png", "sizeBytes": 123456}""")) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://www.chaozapi.com/api/v1/assets/uploads");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);request.Headers.Add("Idempotency-Key", Environment.GetEnvironmentVariable("GLACIER_IDEMPOTENCY_KEY") ?? throw new InvalidOperationException("Set a stable GLACIER_IDEMPOTENCY_KEY"));request.Content = new StringContent("""{ "name": "input.png", "mimeType": "image/png", "sizeBytes": 123456}""", Encoding.UTF8, "application/json");using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 201
assetIdstringrequiredchunkSizeinteger · int64requiredcosobjectoptionalExpand fields / variants
bucketstringrequiredexpiredTimeinteger · int64requiredkeystringrequiredregionstringrequiredsessionTokenstringrequiredstartTimeinteger · int64requiredtmpSecretIdstringrequiredtmpSecretKeystringrequired
estimatedQueueSecondsinteger · int64optionalexpiresAtstring · date-timerequiredfileFieldstring | nullrequiredformFieldsstring[][]optionalExpand fields / variants
stringheadersstring[][]requiredExpand fields / variants
stringmethod"PUT" | "POST"requirednodeIdstringoptionalroutestringoptionalrouteGenerationinteger · int64optionalstatus"pending" | "preparing" | "ready" | "failed"optionaluploadUrlstringrequired
Include Idempotency-Key and persist it with the body before sending. The same account, key and parameters recover the same assetId; different parameters return 409 IDEMPOTENCY_CONFLICT. Upload and task keys have separate namespaces. The header remains optional for existing clients; without it, each request creates another asset.
Public API uploads default to COS. Omit routingMode or pass "cloud" to keep that behavior. If COS is unavailable, the API returns 503 UPLOAD_STORAGE_UNAVAILABLE. New clients can pass "routingMode":"auto" to let the service choose a GPU node or COS based on capacity. Send the file using the returned uploadUrl and method.
Send the file bytes
Section titled “Send the file bytes”These examples use the default PUT ticket and stream input.png to the returned URL. Use the exact returned headers. This is a storage request: it has no API-key header and does not go through /api/v1.
# Save the upload-ticket response as ticket.json. Requires jq.# The ticket must be for input.png with its exact byte length.test "$(jq -r '.method' ticket.json)" = PUT || exit 1headers=()while IFS= read -r header; do headers+=(--header "$header"); done < <( jq -r '.headers[] | .[0] + ": " + .[1]' ticket.json)curl --fail-with-body --silent --show-error --max-time 1800 \ --request PUT "$(jq -r '.uploadUrl' ticket.json)" \ "${headers[@]}" --upload-file input.png// Node.js 22+; example.mjsimport { readFile, stat } from 'node:fs/promises';import { createReadStream } from 'node:fs';const ticket = JSON.parse(await readFile('ticket.json', 'utf8'));if (ticket.method !== 'PUT') throw new Error('Request a default PUT ticket');const headers = Object.fromEntries(ticket.headers);headers['Content-Length'] = String((await stat('input.png')).size);const response = await fetch(ticket.uploadUrl, { method: 'PUT', headers, body: createReadStream('input.png'), duplex: 'half', signal: AbortSignal.timeout(1_800_000),});if (!response.ok) throw new Error(await response.text());console.log('Uploaded; now confirm asset', ticket.assetId);# Python 3.10+; standard libraryimport jsonimport osimport urllib.requestwith open('ticket.json', encoding='utf-8') as source: ticket = json.load(source)if ticket['method'] != 'PUT': raise ValueError('Request a default PUT ticket')headers = dict(ticket['headers'])headers['Content-Length'] = str(os.path.getsize('input.png'))with open('input.png', 'rb') as source: request = urllib.request.Request(ticket['uploadUrl'], data=source, headers=headers, method='PUT') with urllib.request.urlopen(request, timeout=1800) as response: print(response.status, 'Confirm asset', ticket['assetId'])// go run upload.gopackage mainimport ( "encoding/json" "fmt" "net/http" "os" "time")func main() { var ticket struct { AssetID string UploadURL string Method string Headers [][2]string } raw, err := os.ReadFile("ticket.json") if err != nil { panic(err) } if err = json.Unmarshal(raw, &ticket); err != nil { panic(err) } if ticket.Method != "PUT" { panic("Request a default PUT ticket") } file, err := os.Open("input.png") if err != nil { panic(err) } defer file.Close() info, err := file.Stat() if err != nil { panic(err) } req, err := http.NewRequest("PUT", ticket.UploadURL, file) if err != nil { panic(err) } req.ContentLength = info.Size() for _, h := range ticket.Headers { req.Header.Set(h[0], h[1]) } res, err := (&http.Client{Timeout: 30 * time.Minute}).Do(req) if err != nil { panic(err) } defer res.Body.Close() if res.StatusCode >= 300 { panic(res.Status) } fmt.Println("Uploaded; confirm asset", ticket.AssetID)}// cargo add reqwest@0.13 --features blocking// cargo add serde_jsonuse std::{error::Error, fs::File, time::Duration};fn main() -> Result<(), Box<dyn Error>> { let ticket: serde_json::Value = serde_json::from_reader(File::open("ticket.json")?)?; if ticket["method"] != "PUT" { return Err("Request a default PUT ticket".into()); } let file = File::open("input.png")?; let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(1800)).build()?; let mut request = client.put(ticket["uploadUrl"].as_str().ok_or("Missing uploadUrl")?) .header("Content-Length", file.metadata()?.len()); for header in ticket["headers"].as_array().ok_or("Missing headers")? { request = request.header(header[0].as_str().ok_or("Invalid header")?, header[1].as_str().ok_or("Invalid header")?); } request.body(reqwest::blocking::Body::new(file)).send()?.error_for_status()?; println!("Uploaded; confirm asset {}", ticket["assetId"]); Ok(())}// Java 17+; add com.fasterxml.jackson.core:jackson-databind to your project.import com.fasterxml.jackson.databind.ObjectMapper;import java.nio.file.Path;import java.net.URI;import java.net.http.*;import java.time.Duration;class Upload { public static void main(String[] args) throws Exception { var ticket = new ObjectMapper().readTree(Path.of("ticket.json").toFile()); if (!ticket.get("method").asText().equals("PUT")) throw new IllegalArgumentException("Request a default PUT ticket"); var request = HttpRequest.newBuilder(URI.create(ticket.get("uploadUrl").asText())) .timeout(Duration.ofMinutes(30)); for (var header : ticket.get("headers")) request.header(header.get(0).asText(), header.get(1).asText()); var response = HttpClient.newHttpClient().send(request .PUT(HttpRequest.BodyPublishers.ofFile(Path.of("input.png"))).build(), HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException(response.body()); System.out.println("Uploaded; confirm asset " + ticket.get("assetId").asText()); }}// .NET 8+; Program.csusing System;using System.IO;using System.Net.Http;using System.Text.Json;using var ticket = JsonDocument.Parse(await File.ReadAllTextAsync("ticket.json"));var root = ticket.RootElement;if (root.GetProperty("method").GetString() != "PUT") throw new InvalidOperationException("Request a default PUT ticket");using var client = new HttpClient { Timeout = TimeSpan.FromMinutes(30) };using var file = File.OpenRead("input.png");using var request = new HttpRequestMessage(HttpMethod.Put, root.GetProperty("uploadUrl").GetString());request.Content = new StreamContent(file);foreach (var header in root.GetProperty("headers").EnumerateArray()) { var name = header[0].GetString()!; var value = header[1].GetString(); if (!request.Headers.TryAddWithoutValidation(name, value)) request.Content.Headers.TryAddWithoutValidation(name, value);}using var response = await client.SendAsync(request);response.EnsureSuccessStatusCode();Console.WriteLine("Uploaded; confirm asset " + root.GetProperty("assetId").GetString());If you request multipart: true, send a POST form with all formFields first and the fileField file last. Keep the returned headers and let your HTTP library set the boundary. This selects a form upload; use resumable: true for chunked uploads.
Refresh an expired ticket while its upload session is still valid without creating another asset. When the returned status is preparing or ready, uploadUrl is empty: poll status instead of uploading again. An expired session returns 410 UPLOAD_SESSION_EXPIRED.
/api/v1/assets/{assetId}/upload-ticketPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request body fields · application/json
multipartbooleanoptional
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request POST 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-ticket' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-ticket', { method: 'POST', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-ticket", method="POST", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("POST", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-ticket", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::POST, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-ticket") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-ticket")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("POST", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-ticket");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
assetIdstringrequiredchunkSizeinteger · int64requiredcosobjectoptionalExpand fields / variants
bucketstringrequiredexpiredTimeinteger · int64requiredkeystringrequiredregionstringrequiredsessionTokenstringrequiredstartTimeinteger · int64requiredtmpSecretIdstringrequiredtmpSecretKeystringrequired
estimatedQueueSecondsinteger · int64optionalexpiresAtstring · date-timerequiredfileFieldstring | nullrequiredformFieldsstring[][]optionalExpand fields / variants
stringheadersstring[][]requiredExpand fields / variants
stringmethod"PUT" | "POST"requirednodeIdstringoptionalroutestringoptionalrouteGenerationinteger · int64optionalstatus"pending" | "preparing" | "ready" | "failed"optionaluploadUrlstringrequired
If transfer fails and the ticket’s route is node_direct, request a fallback to object storage and send the file again. The fallback keeps the assetId and issues a new ticket with a new routeGeneration. Parts already sent on the original route must be uploaded again. A session that started on COS returns 409 when there is no alternate route.
/api/v1/assets/{assetId}/upload-fallbackPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request body fields · application/json
multipartbooleanoptionalreasonstringoptionalmaxLength: 120
resumablebooleanoptional
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request POST 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-fallback' \ --header "Authorization: Bearer $GLACIER_API_KEY" \ --header 'Content-Type: application/json' \ --data-raw '{ "reason": "network_timeout"}'// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-fallback', { method: 'POST', headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "reason": "network_timeout"}), signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}headers["Content-Type"] = "application/json"request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-fallback", method="POST", headers=headers, data="""{ "reason": "network_timeout"}""".encode("utf-8"),)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "strings" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("POST", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-fallback", strings.NewReader(`{ "reason": "network_timeout"}`)) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) req.Header.Set("Content-Type", "application/json") client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::POST, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-fallback") .bearer_auth(env::var("GLACIER_API_KEY")?) .header("Content-Type", "application/json") .body(r#"{ "reason": "network_timeout"}"#) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-fallback")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("""{ "reason": "network_timeout"}""")) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-fallback");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);request.Content = new StringContent("""{ "reason": "network_timeout"}""", Encoding.UTF8, "application/json");using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
assetIdstringrequiredchunkSizeinteger · int64requiredcosobjectoptionalExpand fields / variants
bucketstringrequiredexpiredTimeinteger · int64requiredkeystringrequiredregionstringrequiredsessionTokenstringrequiredstartTimeinteger · int64requiredtmpSecretIdstringrequiredtmpSecretKeystringrequired
estimatedQueueSecondsinteger · int64optionalexpiresAtstring · date-timerequiredfileFieldstring | nullrequiredformFieldsstring[][]optionalExpand fields / variants
stringheadersstring[][]requiredExpand fields / variants
stringmethod"PUT" | "POST"requirednodeIdstringoptionalroutestringoptionalrouteGenerationinteger · int64optionalstatus"pending" | "preparing" | "ready" | "failed"optionaluploadUrlstringrequired
Confirm completion
Section titled “Confirm completion”After storage accepts the upload, call complete with the ticket’s assetId. The server checks existence and actual size, then durably queues media and integrity verification. A client assertion alone never makes an asset ready. This operation is idempotent; retry it if the response is lost.
Completion can return preparing. Poll the upload status endpoint until ready before quoting or processing. failed is terminal; inspect errorCode/error and upload a corrected file. Status queries also support pending and do not sign download URLs. A 15-second polling interval is recommended.
/api/v1/assets/{assetId}/completePath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request body fields · application/json
partsobject[]optionalmaxItems: 1024
Expand fields / variants
etagstringoptionalmaxLength: 256
numberinteger · int64requiredminimum: 1 · maximum: 1024
sha256stringoptionalmaxLength: 64
routeGenerationinteger · int64optionalminimum: 1
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request POST 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/complete' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/complete', { method: 'POST', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/complete", method="POST", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("POST", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/complete", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::POST, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/complete") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/complete")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("POST", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/complete");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
coverUrlstring | nullrequiredcreatedAtstring · date-timerequireddurationMsinteger | null · int64requiredexpiresAtstring | null · date-timerequiredheightinteger · int64requiredidstringrequiredisPublicbooleanrequiredkind"image" | "video"requiredmimeTypestringrequirednamestringrequiredprepareErrorstringoptionalsizeBytesinteger · int64requiredstatus"pending" | "preparing" | "ready" | "failed"requiredthumbnailUrlstring | nullrequiredupdatedAtstring · date-timerequiredurlstringrequiredversionCountinteger · int64requiredwidthinteger · int64required
Response headers: Retry-After
/api/v1/assets/{assetId}/upload-statusPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request GET 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-status' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-status', { method: 'GET', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-status", method="GET", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("GET", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-status", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::GET, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-status") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-status")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("GET", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-status");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
assetIdstringrequirederrorstring | nullrequirederrorCodestring | nullrequiredstatus"pending" | "preparing" | "ready" | "failed"required
Resume large uploads
Section titled “Resume large uploads”Resume the upload session to read chunkSize, parts, maxConcurrency, and resumeUntil. Part numbers start at 1. Skip saved parts whose hashes match, compute the SHA-256 of each remaining part’s raw bytes, and request its upload ticket. Replace the example hash with the actual part hash. Upload using the returned method, headers, and fileField; once every part is saved, call completeApiUpload to validate and finalize the asset.
Use the returned chunkSize (the final part may be smaller) and stay within maxConcurrency. Include the current routeGeneration when requesting part tickets and confirming completion. For example, send {"routeGeneration":1,"parts":[{"number":1,"etag":"ACTUAL_ETAG","sha256":"ACTUAL_HASH"}]} with the actual generation and all completed parts. The server verifies the stored part count and total size.
/api/v1/assets/{assetId}/upload-sessionPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request POST 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-session' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-session', { method: 'POST', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-session", method="POST", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("POST", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-session", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::POST, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-session") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-session")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("POST", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-session");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
assetIdstringrequiredchunkSizeinteger · int64requiredcompletebooleanrequiredcosobjectoptionalExpand fields / variants
bucketstringrequiredexpiredTimeinteger · int64requiredkeystringrequiredregionstringrequiredsessionTokenstringrequiredstartTimeinteger · int64requiredtmpSecretIdstringrequiredtmpSecretKeystringrequired
maxConcurrencyinteger · int64requiredpartsobject[]requiredExpand fields / variants
etagstringoptionalnumberinteger · int64requiredsha256stringrequiredsizeBytesinteger · int64required
resumeUntilstring · date-timerequiredroutestringoptionalrouteGenerationinteger · int64optionalsizeBytesinteger · int64required
/api/v1/assets/{assetId}/upload-partsPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request body fields · application/json
multipartbooleanoptionalnumberinteger · int64requiredminimum: 1 · maximum: 1024
routeGenerationinteger · int64optionalminimum: 1
sha256stringrequiredpattern: "^[a-f0-9]{64}$"
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request POST 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-parts' \ --header "Authorization: Bearer $GLACIER_API_KEY" \ --header 'Content-Type: application/json' \ --data-raw '{ "number": 1, "routeGeneration": 1, "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}'// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-parts', { method: 'POST', headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "number": 1, "routeGeneration": 1, "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}), signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}headers["Content-Type"] = "application/json"request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-parts", method="POST", headers=headers, data="""{ "number": 1, "routeGeneration": 1, "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}""".encode("utf-8"),)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "strings" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("POST", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-parts", strings.NewReader(`{ "number": 1, "routeGeneration": 1, "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}`)) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) req.Header.Set("Content-Type", "application/json") client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::POST, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-parts") .bearer_auth(env::var("GLACIER_API_KEY")?) .header("Content-Type", "application/json") .body(r#"{ "number": 1, "routeGeneration": 1, "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}"#) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-parts")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("""{ "number": 1, "routeGeneration": 1, "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}""")) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/upload-parts");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);request.Content = new StringContent("""{ "number": 1, "routeGeneration": 1, "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}""", Encoding.UTF8, "application/json");using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
assetIdstringrequiredchunkSizeinteger · int64requiredcosobjectoptionalExpand fields / variants
bucketstringrequiredexpiredTimeinteger · int64requiredkeystringrequiredregionstringrequiredsessionTokenstringrequiredstartTimeinteger · int64requiredtmpSecretIdstringrequiredtmpSecretKeystringrequired
estimatedQueueSecondsinteger · int64optionalexpiresAtstring · date-timerequiredfileFieldstring | nullrequiredformFieldsstring[][]optionalExpand fields / variants
stringheadersstring[][]requiredExpand fields / variants
stringmethod"PUT" | "POST"requirednodeIdstringoptionalroutestringoptionalrouteGenerationinteger · int64optionalstatus"pending" | "preparing" | "ready" | "failed"optionaluploadUrlstringrequired
List and paginate assets
Section titled “List and paginate assets”Use scope=mine for your assets or scope=public for samples. scope=all is the default. Optional filters include kind and search. Pass nextCursor back as the cursor query parameter until it is null. The example requests 24 assets.
Lists include preparing/ready, but exclude pending/failed. Save the asset ID or upload idempotency key to recover an unfinished upload.
/api/v1/assetsPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
scopeoptional | query | "all" | "mine" | "public" |
kindoptional | query | "image" | "video" |
searchoptional | query | stringmaxLength: 100 |
limitoptional | query | integer · int64minimum: 1 · maximum: 100 · default: 24 |
cursoroptional | query | string |
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request GET 'https://www.chaozapi.com/api/v1/assets?scope=mine&limit=24' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets?scope=mine&limit=24', { method: 'GET', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets?scope=mine&limit=24", method="GET", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("GET", "https://www.chaozapi.com/api/v1/assets?scope=mine&limit=24", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::GET, "https://www.chaozapi.com/api/v1/assets?scope=mine&limit=24") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets?scope=mine&limit=24")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("GET", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://www.chaozapi.com/api/v1/assets?scope=mine&limit=24");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
itemsobject[]requiredExpand fields / variants
coverUrlstring | nullrequiredcreatedAtstring · date-timerequireddurationMsinteger | null · int64requiredexpiresAtstring | null · date-timerequiredheightinteger · int64requiredidstringrequiredisPublicbooleanrequiredkind"image" | "video"requiredmimeTypestringrequirednamestringrequiredprepareErrorstringoptionalsizeBytesinteger · int64requiredstatus"pending" | "preparing" | "ready" | "failed"requiredthumbnailUrlstring | nullrequiredupdatedAtstring · date-timerequiredurlstringrequiredversionCountinteger · int64requiredwidthinteger · int64required
nextCursorstring | nullrequiredtotalinteger · int64required
Inspect an asset and its versions
Section titled “Inspect an asset and its versions”The response contains asset and versions. Keep the version ID if you want a later task to use it as sourceVersionId. File URLs are temporary; request fresh details when needed. Processing a public sample can create an owned copy; follow the assetId returned by the task.
/api/v1/assets/{assetId}Path, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request GET 'https://www.chaozapi.com/api/v1/assets/ASSET_ID' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID', { method: 'GET', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID", method="GET", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("GET", "https://www.chaozapi.com/api/v1/assets/ASSET_ID", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::GET, "https://www.chaozapi.com/api/v1/assets/ASSET_ID") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("GET", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
assetobjectrequiredExpand fields / variants
coverUrlstring | nullrequiredcreatedAtstring · date-timerequireddurationMsinteger | null · int64requiredexpiresAtstring | null · date-timerequiredheightinteger · int64requiredidstringrequiredisPublicbooleanrequiredkind"image" | "video"requiredmimeTypestringrequirednamestringrequiredprepareErrorstringoptionalsizeBytesinteger · int64requiredstatus"pending" | "preparing" | "ready" | "failed"requiredthumbnailUrlstring | nullrequiredupdatedAtstring · date-timerequiredurlstringrequiredversionCountinteger · int64requiredwidthinteger · int64required
versionsobject[]requiredExpand fields / variants
assetIdstringrequiredcreatedAtstring · date-timerequireddownloadUrlstringrequireddurationMsinteger | null · int64requiredframeCountinteger | null · int64requiredframeRatenumber | null · doublerequiredheightinteger · int64requiredidstringrequiredindexinteger · int64requiredlabelstringrequiredmaskUrlstring | nullrequiredmimeTypestringrequiredpreviewPendingbooleanrequiredpreviewUrlstring | nullrequiredsizeBytesinteger · int64requiredsourceVersionIdstring | nullrequiredthumbnailUrlstring | nullrequiredtoolIdstring | nullrequiredurlstringrequiredwatermarkMarksobject[]requiredExpand fields / variants
colorstringoptionalpattern: "^#[0-9a-fA-F]{6}$"
endMsinteger · int64optionalminimum: 0
heightnumber · doublerequiredminimum: 0 · maximum: 1
kind"positive" | "negative" | "absent" | "suggested"optionalobjectIdinteger · int64optionalminimum: 0 · maximum: 7
strokesobject[]optionalmaxItems: 64
Expand fields / variants
pointsnumber · double[][]requiredminItems: 1 · maxItems: 4000
Expand fields / variants
number · doubleradiusnumber · doublerequiredminimum: 0 · maximum: 0.25
timeMsinteger · int64optionalminimum: 0
widthnumber · doublerequiredminimum: 0 · maximum: 1
xnumber · doublerequiredminimum: 0 · maximum: 1
ynumber · doublerequiredminimum: 0 · maximum: 1
watermarkObjectsobject[]requiredExpand fields / variants
namestringrequiredminLength: 1 · maxLength: 24
objectIdinteger · int64requiredminimum: 0 · maximum: 7
widthinteger · int64required
Request a version download URL
Section titled “Request a version download URL”Request a short-lived signed download ticket (url, filename, sizeBytes, sha256, locationVersion, and expiresAt) right before downloading a source or processed version. The service automatically selects the optimal healthy replica (direct GPU node within the hot window or cloud object storage).
Only read scope is required. URL expiry is separate from asset retention (expiresAt): a URL can be refreshed while the underlying file is retained. Download without an API key and do not parse or hardcode storage hosts.
/api/v1/assets/{assetId}/versions/{versionId}/download-urlPath, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
versionIdrequired | path | string |
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request POST 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID/download-url' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID/download-url', { method: 'POST', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID/download-url", method="POST", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("POST", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID/download-url", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::POST, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID/download-url") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID/download-url")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("POST", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID/download-url");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
expiresAtstring · date-timerequiredfilenamestringrequiredlocationVersioninteger · int64requiredmimeTypestringrequiredsha256stringrequiredsizeBytesinteger · int64requiredurlstringrequired
Response headers: Cache-Control
Rename an asset
Section titled “Rename an asset”Only supplied fields are changed. Names are trimmed and need not be unique.
/api/v1/assets/{assetId}Path, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request body fields · application/json
namestringoptionalminLength: 1 · maxLength: 255
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request PATCH 'https://www.chaozapi.com/api/v1/assets/ASSET_ID' \ --header "Authorization: Bearer $GLACIER_API_KEY" \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "Enhanced photo"}'// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID', { method: 'PATCH', headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "name": "Enhanced photo"}), signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}headers["Content-Type"] = "application/json"request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID", method="PATCH", headers=headers, data="""{ "name": "Enhanced photo"}""".encode("utf-8"),)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "strings" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("PATCH", "https://www.chaozapi.com/api/v1/assets/ASSET_ID", strings.NewReader(`{ "name": "Enhanced photo"}`)) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) req.Header.Set("Content-Type", "application/json") client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::PATCH, "https://www.chaozapi.com/api/v1/assets/ASSET_ID") .bearer_auth(env::var("GLACIER_API_KEY")?) .header("Content-Type", "application/json") .body(r#"{ "name": "Enhanced photo"}"#) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .header("Content-Type", "application/json") .method("PATCH", HttpRequest.BodyPublishers.ofString("""{ "name": "Enhanced photo"}""")) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("PATCH"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);request.Content = new StringContent("""{ "name": "Enhanced photo"}""", Encoding.UTF8, "application/json");using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 200
coverUrlstring | nullrequiredcreatedAtstring · date-timerequireddurationMsinteger | null · int64requiredexpiresAtstring | null · date-timerequiredheightinteger · int64requiredidstringrequiredisPublicbooleanrequiredkind"image" | "video"requiredmimeTypestringrequirednamestringrequiredprepareErrorstringoptionalsizeBytesinteger · int64requiredstatus"pending" | "preparing" | "ready" | "failed"requiredthumbnailUrlstring | nullrequiredupdatedAtstring · date-timerequiredurlstringrequiredversionCountinteger · int64requiredwidthinteger · int64required
Delete a processed version
Section titled “Delete a processed version”This removes a processed output version. The original cannot be deleted through this endpoint; remove the whole asset instead. A successful deletion returns 204 with no body.
/api/v1/assets/{assetId}/versions/{versionId}Path, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
versionIdrequired | path | string |
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request DELETE 'https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID', { method: 'DELETE', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID", method="DELETE", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("DELETE", "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::DELETE, "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("DELETE", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("DELETE"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID/versions/VERSION_ID");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 204
No response body. Do not attempt to parse empty JSON.
Delete an asset
Section titled “Delete an asset”Deletes the owned asset and cancels its related tasks. Use this only when the original and its versions are no longer needed. Public samples cannot be deleted. Success returns 204 with no body.
/api/v1/assets/{assetId}Path, query and headers
| Parameter | Location | Type & constraints |
|---|---|---|
assetIdrequired | path | string |
Request example
curl --include --fail-with-body --silent --show-error --max-time 60 \ --request DELETE 'https://www.chaozapi.com/api/v1/assets/ASSET_ID' \ --header "Authorization: Bearer $GLACIER_API_KEY"// Node.js 22+; save as example.mjs, then: node example.mjsconst key = process.env.GLACIER_API_KEY;if (!key) throw new Error('Set GLACIER_API_KEY');const response = await fetch('https://www.chaozapi.com/api/v1/assets/ASSET_ID', { method: 'DELETE', headers: { Authorization: `Bearer ${key}`, }, signal: AbortSignal.timeout(60_000),});const text = await response.text();if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);console.log(response.status, text);# Python 3.10+; standard library; python example.pyimport osimport urllib.requestimport urllib.error
headers = {"Authorization": "Bearer " + os.environ["GLACIER_API_KEY"]}request = urllib.request.Request( "https://www.chaozapi.com/api/v1/assets/ASSET_ID", method="DELETE", headers=headers,)try: with urllib.request.urlopen(request, timeout=60) as response: print(response.status, response.read().decode("utf-8"))except urllib.error.HTTPError as error: raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8')}") from error// Go 1.22+; go run example.gopackage main
import ( "fmt" "io" "net/http" "os" "time")
func main() { key := os.Getenv("GLACIER_API_KEY") if key == "" { panic("Set GLACIER_API_KEY") } req, err := http.NewRequest("DELETE", "https://www.chaozapi.com/api/v1/assets/ASSET_ID", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer " + key) client := &http.Client{Timeout: 60 * time.Second} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode >= 300 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, data)) } fmt.Println(res.StatusCode, string(data))}// cargo add reqwest@0.13 --features blocking// Save in src/main.rs, then: cargo runuse std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> { let client = reqwest::blocking::Client::builder() .timeout(Duration::from_secs(60)).build()?; let response = client.request(reqwest::Method::DELETE, "https://www.chaozapi.com/api/v1/assets/ASSET_ID") .bearer_auth(env::var("GLACIER_API_KEY")?) .send()?; let status = response.status(); let text = response.text()?; if !status.is_success() { return Err(format!("HTTP {status}: {text}").into()); } println!("{status} {text}"); Ok(())}// Java 17+; save as Example.java, then: java Example.javaimport java.net.URI;import java.net.http.*;import java.time.Duration;import java.util.Objects;
class Example { public static void main(String[] args) throws Exception { var key = Objects.requireNonNull(System.getenv("GLACIER_API_KEY")); var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build(); var request = HttpRequest.newBuilder(URI.create("https://www.chaozapi.com/api/v1/assets/ASSET_ID")) .timeout(Duration.ofSeconds(60)) .header("Authorization", "Bearer " + key) .method("DELETE", HttpRequest.BodyPublishers.noBody()) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() >= 300) throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body()); System.out.println(response.statusCode() + " " + response.body()); }}// .NET 8+; dotnet new console; replace Program.cs; dotnet runusing System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;
var key = Environment.GetEnvironmentVariable("GLACIER_API_KEY") ?? throw new InvalidOperationException("Set GLACIER_API_KEY");using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };using var request = new HttpRequestMessage(new HttpMethod("DELETE"), "https://www.chaozapi.com/api/v1/assets/ASSET_ID");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);using var response = await client.SendAsync(request);var text = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new HttpRequestException($"HTTP {(int)response.StatusCode}: {text}");Console.WriteLine($"{(int)response.StatusCode} {text}");Response fields · 204
No response body. Do not attempt to parse empty JSON.