Joint session with Vercel: How to build intelligent storefronts (May 15th)

Trouble uploading images to Sanity - getting error in Postman

6 repliesLast updated: Nov 29, 2025

Hey guys, I've been having trouble uploading images to sanity so I attempted to try it on postman with different pictures as well and I'm still getting this error.
AI Update

I understand you're having trouble uploading images to Sanity through the REST API, both in your application and when testing with Postman. While you didn't mention the specific error you're encountering, let me walk you through the proper way to upload images to Sanity and address common issues.

How to Upload Images via the HTTP API

Based on the Sanity Assets API documentation, here's how to properly upload an image:

Endpoint:

POST https://{projectId}.api.sanity.io/{apiVersion}/assets/images/{dataset}

Required components:

Optional query parameters:

Common Issues and Solutions

1. 413 Payload Too Large Error

If you're getting a 413 error, your image file is likely exceeding Sanity's upload size limits. While Sanity's documentation doesn't explicitly state a hard limit in the Assets API page, this typically means:

2. Authentication Issues

Make sure you're using a valid token with write permissions:

3. Postman Configuration

Here's how to set up your Postman request correctly:

Method: POST

URL: https://YOUR_PROJECT_ID.api.sanity.io/v2024-06-24/assets/images/YOUR_DATASET

Headers:

Authorization: Bearer YOUR_TOKEN
Content-Type: image/jpeg

Body:

Query Parameters (optional):

4. Content-Type Header

Make sure your Content-Type header matches your actual image format:

5. Using the JavaScript Client (Alternative)

If the HTTP API continues giving you trouble, consider using the official JavaScript client which handles uploads more reliably:

import {createClient} from '@sanity/client'

const client = createClient({
  projectId: 'your-project-id',
  dataset: 'your-dataset',
  token: 'your-token',
  apiVersion: '2024-06-24',
})

// Upload from a file input or blob
client.assets
  .upload('image', fileData, {
    filename: 'my-image.jpg',
    title: 'My Image'
  })
  .then(document => {
    console.log('Upload successful:', document)
  })
  .catch(error => {
    console.error('Upload failed:', error)
  })

Debugging Steps

If you share the specific error message you're seeing, I can provide more targeted guidance!

Show original thread
6 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions