Check

Find out what a file really is

POST/v1/check/file/type

View as Markdown

Reads the file content (base64, as a flow already has it) and reports the type found in the bytes: PDF, Word, Excel and PowerPoint (told apart inside the zip), ZIP, PNG, JPEG, GIF and more, or JSON, XML, CSV and plain text. Also reports the size, whether the file is empty, and whether the file name agrees. A mismatch is reported, never corrected. An unrecognised file is not an error: the type is null.

Request body

Name Type Required Description
content_base64 string yes The file content as base64. File content in a flow is already base64: send it as it is
file_name string no The name the file has, to compare with the content

Example request

A request body that works, as JSON.

{
  "content_base64": "YSxiCjEsMg==",
  "file_name": "invoices.csv"
}

Code samples

Replace YOUR_TOKEN with your access token.

curl

curl -X POST 'https://api.skillfulsardine.com/v1/check/file/type' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "content_base64": "YSxiCjEsMg==",
  "file_name": "invoices.csv"
}'

PowerShell

$body = @'
{
  "content_base64": "YSxiCjEsMg==",
  "file_name": "invoices.csv"
}
'@
$response = Invoke-RestMethod -Method Post -Uri 'https://api.skillfulsardine.com/v1/check/file/type' `
  -Headers @{ Authorization = 'Bearer YOUR_TOKEN' } `
  -ContentType 'application/json; charset=utf-8' `
  -Body ([System.Text.Encoding]::UTF8.GetBytes($body))
$response | ConvertTo-Json -Depth 10

Python

import requests

payload = {
    "content_base64": "YSxiCjEsMg==",
    "file_name": "invoices.csv",
}

response = requests.post(
    "https://api.skillfulsardine.com/v1/check/file/type",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    json=payload,
    timeout=30,
)
print(response.json())

JavaScript

const response = await fetch("https://api.skillfulsardine.com/v1/check/file/type", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "content_base64": "YSxiCjEsMg==",
  "file_name": "invoices.csv"
}),
});
const result = await response.json();
console.log(result);

Node

// Node 18 or later. Save as call.mjs and run: API_TOKEN=... node call.mjs
const token = process.env.API_TOKEN;

const response = await fetch("https://api.skillfulsardine.com/v1/check/file/type", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${token}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "content_base64": "YSxiCjEsMg==",
  "file_name": "invoices.csv"
}),
});
const result = await response.json();
console.log(result);

Rust

// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }, serde_json = "1"
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let body: serde_json::Value = serde_json::from_str(r#"{
  "content_base64": "YSxiCjEsMg==",
  "file_name": "invoices.csv"
}"#)?;
    let response = reqwest::blocking::Client::new()
        .post("https://api.skillfulsardine.com/v1/check/file/type")
        .bearer_auth("YOUR_TOKEN")
        .json(&body)
        .send()?;
    println!("{}", response.text()?);
    Ok(())
}

Swift

import Foundation

var request = URLRequest(url: URL(string: "https://api.skillfulsardine.com/v1/check/file/type")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = Data(#"""
{
  "content_base64": "YSxiCjEsMg==",
  "file_name": "invoices.csv"
}
"""#.utf8)

let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))

Response

The fields inside data of a successful response.

Name Type Required Description
content_type string yes Detected from the content, null when not recognised
extension string yes The usual extension of that type
size_bytes integer yes Size of the content
is_empty boolean yes True for zero bytes, or text that is only blank space
name_extension string yes The extension of file_name
name_content_type string yes The content type file_name suggests
name_matches boolean yes Whether the name agrees with the content. Null without a file name, or when the name's extension is unknown
mismatch_reason string yes What disagrees, when name_matches is false

Example response

A real answer from the operation, as JSON. The fields in the table above are inside data.

{
  "data": {
    "content_type": "text/csv",
    "extension": "csv",
    "size_bytes": 7,
    "is_empty": false,
    "name_extension": "csv",
    "name_content_type": "text/csv",
    "name_matches": true,
    "mismatch_reason": null
  },
  "errors": null,
  "meta": {
    "request_id": "b77887d7-483e-4327-b4a8-d17cdf1bc321",
    "timestamp": "2026-10-27T07:19:42.136864Z",
    "version": "2026-03-26"
  },
  "pagination": null
}

Responses

Status When it happens
200 Successful Response
400 The body respects the operation schema, but the use case rejected it. Each problem is one ApiError entry
413 The request is larger than the request size limit of the API allows
422 The body does not respect the operation schema. Each problem is one ApiError entry with the code validation_error
500 Something failed inside the server and was not an input problem. The same envelope, errors may be empty