Free plan

Detect file type

Find out what a file really is, whatever its name says
POST
/v1/documents/file-type

About this tool

A file name can be wrong or misleading. This tool looks inside a file to find its real type, such as picture, document, archive or program. It tells you if the name does not match, if a program is hidden under a harmless name, and if an Office file contains macros (small programs). It can also show a fingerprint of the file.
For example, a file called photo.jpg arrives by e-mail and you want to be sure it is not really a program.

How to use it

  1. Choose this tool.
  2. Add one or more files with Upload or drag and drop.
  3. Optionally list the types you expect, and choose whether to look inside archives.
  4. Press Generate.
  5. Read the report for each file.

What you get back

You get a report for each file showing its real type and any warnings, such as a wrong name or hidden program.
GOOD TO KNOW
The content decides, not the name. Nothing is run. Counts as one document per file.
TEST IT LIVE

Try Detect file type in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Documents
Plan
Free
Method
POST
Endpoint
/v1/documents/file-type
Tool ID
documents.file-type
Authentication
API key
Accepts
Text and settings
Background jobs
Yes
Usage group
Documents
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/documents/file-type" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'files=@document.pdf' \
  -F 'expect=["png","jpg","pdf"]' \
  -F 'deep=true' \
  -F 'max_entries=25'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.documents.fileType({
    "files": 'document.pdf',
    "expect": "[\"png\",\"jpg\",\"pdf\"]",
    "deep": true,
    "max_entries": 25
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->documents()->fileType([
    'files' => 'document.pdf',
    'expect' => '["png","jpg","pdf"]',
    'deep' => true,
    'max_entries' => 25,
]);
echo $result->requestId;
FAQ

Frequently asked questions

Find out what a file really is from its content (pictures, documents, archives, audio, video, fonts, databases, programs, text): its type, mime type and kind, whether its name lies, programs hidden under a harmless name, macros in Office files and programs inside archives.

Detect file type works from text and settings, so no file is needed. Every input is optional.

Detect file type is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/documents/file-type with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.