Skip to content
UGC API

Instagram API aspect ratio and image format errors

You send a perfectly good image and Instagram's API answers with an error about the aspect ratio or the media type. Instagram feed posts and carousels only take JPEGs between 4:5 and 1.91:1. Here are the rules, what the errors mean, and how to stop handling them per post.

Updated

The rules Instagram enforces

PlacementFormatAspect ratioOther limits
Single image postJPEG only4:5 (0.8) to 1.91:1Up to 8 MB
CarouselJPEG images (and videos)4:5 to 1.91:1 for each imageUp to 10 items
Story imageJPEG9:16 recommendedShown for 24 hours
ReelMP4 or MOV (H.264 or HEVC)9:16 recommended3 seconds to 15 minutes
CaptionText—2,200 characters, 30 hashtags

What the errors mean

  • "The aspect ratio is not supported": the image is taller than 4:5 (a 9:16 phone screenshot) or wider than 1.91:1 (a banner). Instagram won't crop it for you through the API.
  • "Only photo or video can be accepted as media type" or a generic "media could not be fetched"**: usually a PNG or WebP file, or a URL that doesn't return an image content type.
  • Too many hashtags: a caption with more than 30 hashtags fails the whole post.
  • Carousel errors: one bad image fails the whole carousel, so check every item, not just the first.

Fixing it yourself

  1. Decode the image, flatten transparency onto a background (JPEG has no alpha), and re-encode as JPEG.
  2. If the ratio is below 0.8, pad the sides (or crop the top and bottom) to 4:5. If it's above 1.91, pad top and bottom (or crop the sides) to 1.91:1.
  3. Downscale anything huge (Instagram displays at 1080 px wide) so the file stays under 8 MB.
  4. Keep the original for TikTok and Facebook, which take PNG or WebP without changes, and host the JPEG on a public HTTPS URL Instagram can fetch.
  5. Count hashtags and characters before you post.

Or send any file and let UGC API fit it

UGC API checks every file against each destination's rules when you create a post. For Instagram it converts PNG and WebP to JPEG, pads (or crops, with options.fit: "crop") images outside 4:5–1.91:1, uses the first 10 carousel images, and trims captions to 2,200 characters and 30 hashtags. TikTok and Facebook get their own versions. A dry run shows each change before anything posts.

bash
curl https://ugcapi.dev/v1/posts -H "Authorization: Bearer ugc_live_..." -H "Content-Type: application/json" -d '{
  "dry_run": true,
  "accounts": ["acc_ig_01", "acc_tt_01"],
  "format": "slideshow",
  "media": ["https://cdn.example.com/screenshot-9x16.png", "https://cdn.example.com/banner.webp"],
  "caption": "Before and after",
  "options": { "tiktok": { "privacy": "PUBLIC_TO_EVERYONE" } }
}'
# warnings:
#  Image 1: PNG → JPEG, padded to 4:5 for Instagram carousel.
#  Image 2: WEBP → JPEG, padded to 1.91:1 for Instagram carousel.
#  Image 1: PNG → JPEG for TikTok photo post.

Details in fit to platform.

FAQ

What aspect ratio does the Instagram API accept for images?

Between 4:5 (portrait, 0.8) and 1.91:1 (landscape) for feed posts and carousels. A 9:16 image has to be padded or cropped to 4:5 first.

Can I post a PNG through the Instagram Graph API?

Not for feed posts: Instagram takes JPEG images. Convert PNG to JPEG (flattening transparency) before creating the media container, or let UGC API convert it.

Does Instagram crop images sent through the API?

No. Unlike the app, the API rejects images outside the 4:5 to 1.91:1 range instead of cropping them.

Related