Create Assets API Access Denied


I am trying to upload an image via API Create Assets but all the time I get this page

My code looks like this (copied from API docs; key and site-id is hidden):

const url = ‘{site-id}/assets’;
const options = {
method: ‘POST’,
headers: {
accept: ‘application/json’,
‘content-type’: ‘application/json’,
authorization: ‘Bearer {key}’
body: JSON.stringify({fileName: ‘2013-Hyundai-H-1-25-CRDi-VGT-Wagon-Auto (1).webp’, fileHash: ‘38fa8ae5f3bea9d2d5f16e43ede26c17a4c77639f135a0ef5f2691ae5a641b88’})

let uploadDetails = await fetch(url, options)
.then(res => res.json())
.catch(err => console.error(‘error:’ + err));

// You’ll recieve a body of Upload Details which has th following key information needed to upload the asset
async function uploadImageToS3(uploadDetails, imagePath) {
const s3Endpoint = uploadDetails.uploadUrl;

// Create a new FormData object to send as a multipart/form-data request
const form = new FormData();

// Add form fields
for (const key in uploadDetails.uploadDetails) {
form.append(key, uploadDetails.uploadDetails[key]);

// Append the actual asset file to the FormData object
form.append(‘file’, fs.createReadStream(imagePath));

try {
const response = await, form, {
headers: {

if (response.status === 201) {
  console.log('Upload successful.');
} else {
  console.error('Upload failed with status:', response.status);

} catch (error) {
console.error(‘Error:’, error);

const imagePath = ‘’; // Replace with the actual path to your image file

uploadImageToS3(uploadDetails, imagePath);

What am I doing wrong?