Request a pre-signed upload URL
curl --request POST \
--url https://api.fourthwall.com/open-api/v1.0/media/upload-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fileName": "artwork.png",
"contentType": "image/png",
"size": 1048576
}
'import requests
url = "https://api.fourthwall.com/open-api/v1.0/media/upload-url"
payload = {
"fileName": "artwork.png",
"contentType": "image/png",
"size": 1048576
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({fileName: 'artwork.png', contentType: 'image/png', size: 1048576})
};
fetch('https://api.fourthwall.com/open-api/v1.0/media/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.fourthwall.com/open-api/v1.0/media/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([
'fileName' => 'artwork.png',
'contentType' => 'image/png',
'size' => 1048576
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.fourthwall.com/open-api/v1.0/media/upload-url"
payload := strings.NewReader("{\n \"fileName\": \"artwork.png\",\n \"contentType\": \"image/png\",\n \"size\": 1048576\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.fourthwall.com/open-api/v1.0/media/upload-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileName\": \"artwork.png\",\n \"contentType\": \"image/png\",\n \"size\": 1048576\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fourthwall.com/open-api/v1.0/media/upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fileName\": \"artwork.png\",\n \"contentType\": \"image/png\",\n \"size\": 1048576\n}"
response = http.request(request)
puts response.read_body{
"uploadUrl": "<string>",
"fileUrl": "<string>",
"expiresAt": "2023-11-07T05:31:56Z"
}
Media library
Request a pre-signed upload URL
Rate limit: 20 requests / minute per shop. See Rate limiting.
Returns a pre-signed upload URL for uploading a new image. After receiving the response, PUT the image bytes directly to the uploadUrl.
POST
/
open-api
/
v1.0
/
media
/
upload-url
Request a pre-signed upload URL
curl --request POST \
--url https://api.fourthwall.com/open-api/v1.0/media/upload-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fileName": "artwork.png",
"contentType": "image/png",
"size": 1048576
}
'import requests
url = "https://api.fourthwall.com/open-api/v1.0/media/upload-url"
payload = {
"fileName": "artwork.png",
"contentType": "image/png",
"size": 1048576
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({fileName: 'artwork.png', contentType: 'image/png', size: 1048576})
};
fetch('https://api.fourthwall.com/open-api/v1.0/media/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.fourthwall.com/open-api/v1.0/media/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([
'fileName' => 'artwork.png',
'contentType' => 'image/png',
'size' => 1048576
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.fourthwall.com/open-api/v1.0/media/upload-url"
payload := strings.NewReader("{\n \"fileName\": \"artwork.png\",\n \"contentType\": \"image/png\",\n \"size\": 1048576\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.fourthwall.com/open-api/v1.0/media/upload-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileName\": \"artwork.png\",\n \"contentType\": \"image/png\",\n \"size\": 1048576\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fourthwall.com/open-api/v1.0/media/upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fileName\": \"artwork.png\",\n \"contentType\": \"image/png\",\n \"size\": 1048576\n}"
response = http.request(request)
puts response.read_body{
"uploadUrl": "<string>",
"fileUrl": "<string>",
"expiresAt": "2023-11-07T05:31:56Z"
}
OAuth scope:
media_writeAPI keys have full access to this endpoint.When you
PUT the bytes to uploadUrl, you must send two headers that are baked into the URL’s signature — omit or mismatch either and Google Cloud Storage rejects the upload with 403 SignatureDoesNotMatch:Content-Type— must equal thecontentTypeyou sent in this request.x-goog-content-length-range: 0,<size>— must use the samesize(in bytes) you sent in this request.
PUT goes directly to Google Cloud Storage, not Fourthwall — don’t send your Fourthwall credentials with it, and note the URL is short-lived (~6 hours). See Create design products for an end-to-end walkthrough.Authorizations
oauthbasicAuth
The access token received from the authorization server in the OAuth 2.0 flow.
Body
application/json
⌘I