Generate Upload URL
curl --request POST \
--url https://api.sunbird.ai/tasks/generate-upload-url \
--header 'Content-Type: application/json' \
--data '
{
"file_name": "recording.wav",
"content_type": "audio/wav"
}
'import requests
url = "https://api.sunbird.ai/tasks/generate-upload-url"
payload = {
"file_name": "recording.wav",
"content_type": "audio/wav"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({file_name: 'recording.wav', content_type: 'audio/wav'})
};
fetch('https://api.sunbird.ai/tasks/generate-upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sunbird.ai/tasks/generate-upload-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file_name' => 'recording.wav',
'content_type' => 'audio/wav'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sunbird.ai/tasks/generate-upload-url"
payload := strings.NewReader("{\n \"file_name\": \"recording.wav\",\n \"content_type\": \"audio/wav\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sunbird.ai/tasks/generate-upload-url")
.header("Content-Type", "application/json")
.body("{\n \"file_name\": \"recording.wav\",\n \"content_type\": \"audio/wav\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sunbird.ai/tasks/generate-upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_name\": \"recording.wav\",\n \"content_type\": \"audio/wav\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "<string>",
"file_id": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Uploads
Generate Upload URL
Generate a signed URL for direct upload to Google Cloud Storage.
POST
/
tasks
/
generate-upload-url
Generate Upload URL
curl --request POST \
--url https://api.sunbird.ai/tasks/generate-upload-url \
--header 'Content-Type: application/json' \
--data '
{
"file_name": "recording.wav",
"content_type": "audio/wav"
}
'import requests
url = "https://api.sunbird.ai/tasks/generate-upload-url"
payload = {
"file_name": "recording.wav",
"content_type": "audio/wav"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({file_name: 'recording.wav', content_type: 'audio/wav'})
};
fetch('https://api.sunbird.ai/tasks/generate-upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sunbird.ai/tasks/generate-upload-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file_name' => 'recording.wav',
'content_type' => 'audio/wav'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sunbird.ai/tasks/generate-upload-url"
payload := strings.NewReader("{\n \"file_name\": \"recording.wav\",\n \"content_type\": \"audio/wav\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sunbird.ai/tasks/generate-upload-url")
.header("Content-Type", "application/json")
.body("{\n \"file_name\": \"recording.wav\",\n \"content_type\": \"audio/wav\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sunbird.ai/tasks/generate-upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_name\": \"recording.wav\",\n \"content_type\": \"audio/wav\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "<string>",
"file_id": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Request model for generating a signed upload URL.
Fields
file_name— Name of the file to upload.content_type— MIME type of the file (e.g., "audio/wav", "image/png").
Example
{
"file_name": "recording.wav",
"content_type": "audio/wav"
}
Response
Successful Response
Response model for upload URL generation.
Fields
upload_url— Pre-signed URL for direct upload to GCS.file_id— Unique identifier for the uploaded file.expires_at— When the upload URL expires.
Example
{
"upload_url": "https://storage.googleapis.com/...",
"file_id": "550e8400-e29b-41d4-a716-446655440000",
"expires_at": "2024-01-15T10:30:00Z"
}

