apyhub
DATA VALIDATION · FILE SECURITY

Validate File Type API

What it does

File Validator checks whether an uploaded file matches its filename extension and declared MIME type. Send a binary file and get back the original file_name, extracted extension, client mime_type, detected detected_type, a boolean is_valid, and a human-readable message.

Use it when you need to confirm that a file is what it claims to be before you store, process, or forward it. The upload endpoint accepts a single file up to 100 MB. If you already have a direct download link, the URL endpoint takes a file_url and validates the downloaded file instead. In both cases, the service reports the detected file type from the binary content so you can compare it against the expected type.

File Validator is useful for intake forms, document pipelines, attachment checks, and any workflow where extension spoofing or bad MIME declarations can cause downstream failures. A mismatched PDF, image, or Office document is surfaced clearly in the response so you can reject it or route it for review.

▣ ENDPOINT 01 / 02
POST
Validate an uploaded file
https://api.eu.apyverse.com/apyhub/validate-file

QUICKSTART

GUIDE

Quickstart

Upload a file to validate its extension and detected MIME type.

curl -X POST "https://api.eu.apyverse.com/apyhub/validate-file" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/report.pdf"

What you'll get back

Returns a JSON object with file_name, extension, mime_type, detected_type, is_valid, and message. is_valid is a boolean indicating whether the detected type matches the extension and declared MIME; mime_type and detected_type may be null.

{
  "file_name": "report.pdf",
  "extension": "pdf",
  "mime_type": "application/pdf",
  "detected_type": "application/pdf",
  "is_valid": true,
  "message": "File is valid"
}
TRY ITLIVE · 25 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
The file to validate. Maximum 100 MB.

About this endpoint

What it does

Validates an uploaded file by comparing the file’s detected type against the client-provided filename extension and declared MIME type. It returns a JSON object describing the file name, extracted extension, MIME information, detected type, a validity flag, and a human-readable message.

Request Body

ParameterTypeMandatoryDescription
fileStringYesThe file to validate. Binary upload. Maximum 100 MB.

Response

Returns a JSON object with six required top-level string/boolean fields: file_name, extension, mime_type, detected_type, is_valid, and message. is_valid is true when the detected type matches both the extension and the declared MIME; mime_type and detected_type may be null if not provided or not detected.

ParameterTypeMandatoryDescription
file_nameStringYesOriginal filename as provided by the client.
extensionStringYesLowercased file extension extracted from file_name.
mime_typeStringYesMIME type declared by the client (multipart Content-Type field). Null if not provided.
detected_typeStringYesMIME type detected from the file's binary content. Null if detection failed.
is_validBooleanYesTrue when detected type matches both the extension and the declared MIME.
messageStringYesHuman-readable validation result or mismatch explanation.

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 02 / 02
POST
Validate a file from a URL
https://api.eu.apyverse.com/apyhub/validate-file/url

QUICKSTART

GUIDE

Quickstart

Validate a file by sending its direct URL in a JSON body.

curl -X POST "https://api.eu.apyverse.com/apyhub/validate-file/url" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"file_url":"https://assets.apyhub.com/samples/sample.pdf"}'

What you'll get back

Returns a JSON object with file_url (string), detected_type (string or null), is_valid (boolean), and message (string).

{
  "file_url": "https://assets.apyhub.com/samples/sample.pdf",
  "detected_type": "application/pdf",
  "is_valid": true,
  "message": "File is valid"
}
TRY ITLIVE · 25 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Direct URL to the file to validate. Must include a recognisable file extension (e.g. .pdf, .jpg, .docx).

About this endpoint

What it does

Validates a file referenced by a URL and returns the URL that was checked, the detected file type, whether the file is valid, and a message describing the result.

Request Body

ParameterTypeMandatoryDescription
file_urlStringYesDirect URL to the file to validate. Must be a URI and must include a recognisable file extension (e.g. .pdf, .jpg, .docx).

Response

Returns a JSON object with four top-level fields: message as a string, file_url as a string URI, is_valid as a boolean, and detected_type as a string that may be nullable. The schema requires all four fields in the success response.

ParameterTypeMandatoryDescription
messageStringYesResult message returned by the endpoint.
file_urlStringYesThe URL that was validated.
is_validBooleanYesIndicates whether the file is valid.
detected_typeStringYesMIME type detected from the downloaded file's binary content. May be null.

Body

Name
Type
Description
bodyREQUIRED
object
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.