Get a fingerprint code of a file to prove it was not changed
POST /v1/documents/checksum
About this tool · Open it in the Studio
What it does
A checksum is a short code worked out from the contents of a file. If even one byte changes, the code changes, so it works like a fingerprint. This tool gives you the codes for one or more files, using the kind of code you choose, such as SHA-256 or MD5. You can also paste a code you were given, to see if it matches.
How to call it
Send a POST request to /v1/documents/checksum with your API key in the X-Api-Key header. The parameters below go in the request body (or in the address of a GET request). Files, when the tool takes them, are sent as multipart form data. Every answer carries a Request-Id header: quote it if you contact support.
Parameters
| Parameter | Type | Default | What it does |
|---|---|---|---|
filesRequired | files | — | The files to hash. |
algorithmsOptional | array | — | Which hashes, as a list or comma-separated (default sha256): md5, sha1, sha224, sha256, sha384, sha512, sha512-256, sha3-256, sha3-384, sha3-512, blake2b512, blake2s256, ripemd160, crc32, adler32. |
encodingOptional | string | hex | hex (default), base64 or base64url. hexbase64base64url |
uppercaseOptional | boolean | false | true: write hex digits in capitals. Default false. |
expectedOptional | string | — | A hash you already have, to compare with the first file (the algorithm is found from its length), or a map of file name to hash for several files (sent as an object). |
expected_algorithmOptional | string | — | Which algorithm `expected` is made with, when its length fits several (a 64-digit hash can be SHA-256, SHA3-256 or BLAKE2s). |
include_sizeOptional | boolean | true | true (default): give the size in bytes of every file. |
manifestOptional | string | none | Also make a file listing every hash: gnu (sha256sum style, "hash name"), bsd ("SHA256 (name) = hash"), a data file with the list (format json) or none (default). nonegnubsdjson |
manifest_algorithmOptional | string | — | The algorithm used in the manifest (default: the first of algorithms). |
validate_onlyOptional | boolean | false | true = check the request without running it. The answer is `{ validated: true, valid, errors[], files, estimate, limits }` instead of the endpoint's usual answer: `errors` lists every parameter or file the real call would reject, `estimate` is what it would count against your plan, and `limits` are the limits that apply to this endpoint for your key. Nothing is processed, no files are produced and no files are counted against the plan; the call itself counts as one request. The tool’s own checks run on it too, up to the point where processing would start; a problem that only shows while processing (a crop outside the image) is not found. Files given as a web address are not downloaded. |
presetIdOptional | string | — | Apply a saved preset (create one with POST /v1/presets). Every value stored in the preset is used unless this request sets that field itself. The preset must have been saved for this same endpoint; requires an individual customer API key. |
appOptional | string | — | The name of the app that makes this call, for example "My shop importer". It is shown in your History next to the result, so you can tell which app did what. The official apps fill it in themselves (Davix H2I plugin, Davix H2I n8n node, Davix H2I Studio, Davix H2I Dashboard); when you leave it out, the official SDKs and plugins are recognised from their User-Agent. Up to 60 characters; control characters and angle brackets are removed. The header `X-Davix-App` does the same. It is only a label: it never changes what the call does. |
source_urlsOptional | array | — | A list of public http(s) addresses to fetch as inputs, as a JSON array, for example ["https://example.com/a.pdf","https://example.com/b.pdf"]. They are added to any files you upload: uploaded files come first, then the URLs, in the order sent. Together they cannot exceed the files-per-request limit of your plan. Only public addresses on port 80/443 are fetched (never loopback, private, link-local or cloud-metadata addresses), redirects are re-checked, and the download is size- and time-limited; every fetched file is then judged exactly like an upload (content sniffing, format and size limits). |
Idempotency-KeyOptional | string | — | Optional idempotency key (8-128 characters). Reuse it for a retry of the SAME request; a different request with the same key -> 409 idempotency_key_conflict. |
asyncOptional | boolean | — | Opt-in asynchronous execution. With async=true and an individual customer API key the endpoint answers 202 {job_id, status_url} and the result becomes available from GET /v1/jobs/{id}. Omitted/false = the normal synchronous response. A request that carries several files in one field is not run as a job: it is processed immediately, answered with one result per file, and a `warnings` entry says that async was not applied. |
Use it from your code
cURL
curl -X POST "https://app.h2i.davixlabs.io/v1/documents/checksum" \
-H "X-Api-Key: $DAVIX_H2I_API_KEY" \
-F 'files=@document.pdf' \
-F 'algorithms=["sha256","md5"]' \
-F 'encoding=hex' \
-F 'expected=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'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.checksum({
"files": 'document.pdf',
"algorithms": "[\"sha256\",\"md5\"]",
"encoding": "hex",
"expected": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
});
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()->checksum([
'files' => 'document.pdf',
'algorithms' => '["sha256","md5"]',
'encoding' => 'hex',
'expected' => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
]);
echo $result->requestId;