apyhub
DATA VALIDATION · DEVELOPER TOOLS

Validate File Type API

Hosted on ApyHub

What it does

File Type Validator checks whether an uploaded file matches its filename extension and declared MIME type. Send a file or a file URL, and get back the original filename or URL, the extracted extension, the declared MIME type when provided, the detected MIME type from the file content, a boolean validity flag, and a human-readable message.

Use the direct upload endpoint when you receive multipart files from users or partners. The file input accepts a binary file up to 100 MB. The response tells you the file name, lowercased extension, declared MIME type, detected type, and whether the file is valid according to both checks. When you need to validate remote assets, the URL endpoint accepts a direct file URL with a recognisable extension and returns the validated URL, detected type, validity flag, and message.

This is useful for upload filters, document intake, attachment checks, and backend file safety rules. You can reject mismatched uploads, flag suspicious content types, or log validation results before passing files into conversion, storage, or processing workflows.

▣ ENDPOINT 01 / 02
POST
Validate an uploaded file
http://localhost:8080/apyhub/validate-file-type
QUICKSTARTGUIDE

Quickstart

Upload a file to validate its type against its filename extension and declared MIME type.

curl -X POST "http://localhost:8080/apyhub/validate-file-type" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/report.pdf"

What you'll get back

Returns a JSON object with these required fields: file_name (string), extension (string), mime_type (string or null), detected_type (string or null), is_valid (boolean), and message (string).

{
  "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 detected file type against the file extension and the MIME type declared by the client. It returns the original file name, extracted extension, declared MIME type, detected type, a boolean validity flag, and a human-readable message.

Request Body

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

Response

Returns a JSON object with file_name, extension, mime_type, detected_type, is_valid, and message fields. The response confirms whether the detected type matches both the extension and the declared MIME, and includes the relevant file details.

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). Nullable; null if not provided.
detected_typeStringYesMIME type detected from the file's binary content. Nullable; null if detection failed.
is_validBooleanYestrue when detected type matches both the extension and the declared MIME.
messageStringYesHuman-readable validation result or mismatch explanation.

Notes

The uploaded file has a maximum size of 100 MB.

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
http://localhost:8080/apyhub/validate-file-type/url
QUICKSTARTGUIDE

Quickstart

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

curl -X POST "http://localhost:8080/apyhub/validate-file-type/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 accessible from a URL by inspecting the downloaded file and comparing its detected MIME type against the file URL. It returns the validated file_url, the detected file type, whether the file is valid, and a message.

Request Body

ParameterTypeMandatoryDescription
file_urlStringYesDirect URL to the file to validate. Must be a URI and should include a recognisable file extension such as .pdf, .jpg, or .docx.

Response

Returns a JSON object with file_url, detected_type, is_valid, and message fields. file_url and message are strings, detected_type is a string and may be null, and is_valid is a boolean. The success response schema does not declare a specific status code.

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

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.