{"uid":"cap_fKr_DC9qP07-U3nnKWr2r","slug":"file-type-detector-e683e189","name":"File Type Detector","description":"Detect a file's real format from its first bytes (magic numbers), given as base64 or hex: MIME type, extension and a warning when it does not match the file name. Use to validate uploads.","url":"https://bess-x402.onrender.com/v1/util/file-type?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET","HEAD","DELETE"],"type":"string"},"queryParams":{"type":"object","required":["data"],"properties":{"data":{"type":"string","description":"First bytes of the file (base64 or hex)"},"encoding":{"type":"string","description":"base64 or hex"},"filename":{"type":"string","description":"Original file name (optional)"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.003","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.003/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_9ZxSWuqDk5VS0t260NVzl","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.003","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Detects a file's real format from its magic bytes (base64 or hex), returning MIME type, extension, and a mismatch warning if the filename doesn't match.","exampleAgentPrompt":"Can you check whether these base64 bytes actually correspond to a PDF file — here's the encoded header data: 'JVBERi0xLjQK...' and the uploaded filename is 'report.pdf'?","exampleUseCases":[{"title":"Detecting disguised malware uploads","prompt":"A user just uploaded a file called 'invoice.pdf' to our system — here are its first bytes in base64: 'TVqQAAMAAAAE...'. Can you check whether this file is actually a PDF or something else, like an executable?"},{"title":"Validating image uploads before storage","prompt":"Before I save this to our image CDN, can you verify that these hex bytes 'FFD8FFE000104A464946' are really a JPEG? The filename provided was 'photo.jpg'."},{"title":"Identifying unknown file format","prompt":"I have a mystery file with no extension and these base64-encoded first bytes: 'UEsDBBQAAAAI...'. What file format is this actually, and what MIME type and extension should I give it?"}],"resultDescription":"Returns the detected MIME type (e.g. 'application/pdf'), the standard file extension (e.g. 'pdf'), and an optional warning if the detected type does not match the provided filename — enabling reliable validation of file uploads regardless of their stated extension.","failureModes":["Too few bytes provided to identify the format — magic number detection requires at least a handful of bytes from the file header","Unknown or unsupported file format — returns a null or unknown type if the magic bytes don't match any known signature","Invalid base64 or hex encoding — malformed input will cause a parsing error","Missing required 'data' query parameter returns an error","Very short or truncated byte sequences may lead to ambiguous or incorrect detection"],"whenToPreferThis":"Choose this endpoint when you need to validate file uploads server-side by inspecting actual file content rather than trusting user-supplied filenames or MIME headers. It is especially useful for security-sensitive upload flows where disguised executables or mismatched file types pose a risk, and when you need a lightweight, per-call check without standing up your own magic-number detection library.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T00:33:41.867Z","isFirstParty":false,"canonicalSlug":"file-type-detector-e683e189"}