File search
Search files in your project with POST /files/search/. A single request can
combine full-text search, exact matching, range filters, and tag filters. This
page explains the query syntax, how conditions combine, and shows worked
request/response examples.
File search requires API version 0.7. Send the
Accept: application/vnd.uploadcare-v0.7+json header with every request.
Newly uploaded and recently changed files are indexed asynchronously and may not appear in (or disappear from) search results immediately. Expect a short delay, usually a few seconds.
Quick start
At least one search condition is required. With no conditions, the request
returns 400.
Search conditions
A request body is a JSON object. Each of the following keys is optional, but at least one must be present.
Plus these modifiers:
Pagination and appdata are controlled with query parameters — see
Pagination and Including appdata.
How conditions combine
Understanding the boolean model is the key to building complex queries.
- Different top-level conditions are combined with AND. A request with
phrase,size, andis_imagereturns files that match all three. - There is no top-level OR and no general NOT. You cannot ask for
“filename contains
photoOR is an image”. The only ways to express OR and NOT are the narrow cases listed below.
Full-text search: query and phrase
query and phrase run full-text search. query searches all full-text fields
(original_filename, metadata, detected_mime_type) at once, while phrase
targets specific fields:
Both are substring-aware: a term matches anywhere inside a word, not only at
the start. Searching photo finds photo.jpg, photographer.png, and
holiday-photo.jpg. Filenames are also split on separators such as -, _,
and case boundaries before matching.
A few rules follow from this:
- Minimum 4 characters for every
queryandphrasevalue. Shorter terms cannot match — useexactfor short or precise values. - Very long terms (over ~15 characters) may not match via full-text; prefer
exactfor full filenames or full MIME types. phrase.metadatasearches across all metadata keys and values at once. To match a specific metadata key, useexactwithmetadata[key].
query also matches against the file UUID with a relevance boost: if you paste a
UUID into query, that exact file is returned at the top of the results while
the rest of the term is still matched as full text.
Typo tolerance with fuzziness
Set fuzziness: true to tolerate small spelling differences in query and
phrase (it does not affect exact). The allowed edit distance scales with
term length (roughly 1 edit for 3–5 characters, 2 for longer).
Fuzzy matching significantly increases query latency. Enable it only when you need it.
Exact matching
exact matches stored values exactly. Each field takes a non-empty array;
multiple values in one field are OR-ed:
To match an arbitrary metadata field, use metadata[key] syntax:
A field cannot appear in both phrase and exact in the same request.
Range filters: datetime_uploaded and size
Both accept the operators gt, gte, lt, and lte. At least one operator is
required; combine two to form a range.
datetime_uploaded values are ISO 8601 timestamps; size is in bytes.
Filter by tags
Use tags to filter by file tags. All three keys are
optional, but at least one must be non-empty. Tag values are normalized
(lowercased, whitespace-stripped) before matching.
Sorting
sort is an array of 1–4 keys. Prefix a key with - for descending order. You
cannot pass both directions of the same key, and keys must be unique.
If sort is omitted, results are ordered by relevance. For filter-only
requests (no query or phrase), there is no relevance to rank by, so the
order is undefined — always pass an explicit sort in that case.
Pagination
Pagination uses the limit and offset query parameters (not the body):
The response includes ready-to-use next and previous URLs. Results beyond
the first 1000 cannot be paged through; narrow your query instead of deep
paging.
Including appdata
Pass include=appdata as a query parameter to embed
application data (such as moderation or virus-scan
results) in each result:
appdata is currently the only supported value.
Response
total— number of matching files (may be approximate for very large result sets).results— file objects in the same shape as file info, plus ahighlightfield.highlight— for fields that matched a full-text condition, the matched tokens wrapped in<em>tags.original_filenameanddetected_mime_typeare arrays of strings;metadatais an object keyed by metadata field name. Absent for filter-only matches.
Worked examples
Recent images, largest first
PDFs whose name contains “invoice”, uploaded in 2024
Outdoor photos tagged cat or dog, excluding archived
Files with a specific metadata value
Errors
A 400 response body is a JSON object mapping field names to arrays of error
strings. Errors that span more than one field appear under non_field_errors.
Get $YOUR_PUBLIC_KEY and $YOUR_SECRET_KEY from
API keys.