Skip to main content
POST
Image Search: Upload Image

Authorization

string
required
Token-based authentication header in the form of <YOUR_LAYERS_TOKEN>.

Headers

string
default:"multipart/form-data"
required
string
default:"application/json"
required

Body

file
required
Image file to upload. Supported formats: JPEG, JPG, PNG, WebP, HEIC, and HEIF. Maximum file size: 15MB (15,360 KB).
integer
X-coordinate (in pixels) of the top-left corner of the crop region. Must be 0 or greater. When provided, all four crop parameters (crop_x, crop_y, crop_width, crop_height) are required.
integer
Y-coordinate (in pixels) of the top-left corner of the crop region. Must be 0 or greater.
integer
Width (in pixels) of the crop region. Must be 1 or greater.
integer
Height (in pixels) of the crop region. Must be 1 or greater.

Response

string
Status of the upload operation. Returns “success” on successful upload.
string
Unique UUID identifier for the uploaded image. Use this ID in the Image Search API to perform visual searches.

Usage

The Image Upload endpoint enables a two-step process for visual search:
  1. Upload the image using this endpoint to receive an imageId
  2. Search with the image using the imageId in the Image Search API
This approach offers several advantages:
  • Better performance: Avoids repeated base64 encoding/decoding
  • Caching: Processed image embeddings are cached for faster subsequent searches
  • Reduced payload size: Use lightweight UUID instead of large base64 strings

Error responses

object
Validation errors returned when the request fails validation.
Common validation errors:
  • File required: No image file provided
  • Invalid file type: File format not supported (must be JPEG, JPG, PNG, WebP, HEIC, or HEIF)
  • File too large: Image exceeds 15MB size limit
  • Missing crop parameters: All four crop parameters must be provided together