Sending a file
A file takes three calls and an upload: ValidFile opens an upload address for it alone, your bytes go straight there, to Cloud Storage in Montréal, then ValidFile measures them.
A small file, in one call
Up to 25 MB, an image, a GIF or a display banner, a file is validated in one call: its bytes in the body, its verdict in the response, which waits up to 30 seconds. Without delivery, a delivery is made for it; pass the one a first response returned for the next files of the same campaign. The credit, the limits and the verdict are those of the steps below. Validate a file gives each parameter.
curl "https://validfile.ca/api/v1/validate?name=Display_FR_300x250-noel.jpg&platforms=Display" \
-H "Authorization: Bearer $VALIDFILE_KEY" \
-H "Content-Type: image/jpeg" \
--data-binary @Display_FR_300x250-noel.jpg
Beyond that, or for an upload that must be able to resume where it stopped, the five steps that follow.
1. Make the delivery
One per campaign. platforms says where the campaign will run: each file is judged on these platforms’ placements. campaignRef is your own id, to find the delivery again later. Make a delivery gives each field.
curl https://validfile.ca/api/v1/deliveries \
-H "Authorization: Bearer $VALIDFILE_KEY" \
-H "Content-Type: application/json" \
-d '{
"client": "Fromagerie Boivin",
"campaign": "Noël 2026",
"platforms": ["Meta", "Display"],
"campaignRef": "bynder:4471"
}'
2. Announce the file
Its name, its exact size in bytes, its type. A credit is reserved then, and the response gives uploadUrl, the upload address.
curl https://validfile.ca/api/v1/deliveries/$DELIVERY/files \
-H "Authorization: Bearer $VALIDFILE_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Meta_FR_story-noel.mp4",
"size": 18734201,
"type": "video/mp4"
}'
3. Send the bytes
A PUT of the whole file to uploadUrl, with the same Content-Type, without the key: the address is the only right to send, for this file only, at this size exactly.
curl -T Meta_FR_story-noel.mp4 "$UPLOAD_URL" \
-H "Content-Type: video/mp4"
uploadUrl is a Cloud Storage resumable upload session, good for a week: a large file cut off on the way resumes where it stopped, rather than starting again from zero. Google’s page says how to ask how far the upload got.
4. Say it has arrived
ValidFile checks that Cloud Storage holds a file of the size announced, then measures it. The verdict is read afterwards, or comes by webhook.
curl -X POST https://validfile.ca/api/v1/deliveries/$DELIVERY/files/$FILE/complete \
-H "Authorization: Bearer $VALIDFILE_KEY"
5. Close the delivery
Once everything is sent. ValidFile then knows nothing more is coming, and delivery.judged goes out once every file is judged. A file added later is taken, and the event goes out again once it is judged. A delivery your client fills through its drop link also closes when it says there that it is complete.
curl -X POST https://validfile.ca/api/v1/deliveries/$DELIVERY/close \
-H "Authorization: Bearer $VALIDFILE_KEY"
Before you write your script
- No zip. Unzip a zip of files, and announce each file. A
.zip, or a file announced asapplication/zip, is refused at the announcement (415 zip_not_supported), with no credit reserved. An HTML5 banner, a zip with itsindex.html, is therefore dropped in ValidFile, by you or through your client’s drop link: it is judged there like any file, onDisplay’s HTML5 placements, and the API then reads it with its verdict and its checks. - The name counts. ValidFile reads the name to choose the placement: a platform or a format in the name helps. For a file kept in folders, join the folders with
_, as ValidFile does with a folder dropped on it:Meta/FR/story.mp4becomesMeta_FR_story.mp4. - The type is read from the bytes, not from the name nor from
type: a PNG named.jpgis judged as a PNG. - 5 GB at most per file. An empty file is refused.
- A credit waits 24 h. A file announced and never completed gives its credit back after 24 h. A failed upload gives it back at once with Give up a file; do so too when
/completeanswersnot_uploadedand you will not send the file. - The same bytes cost once in the same delivery:
/completerecognises them and gives the credit back (duplicate: true). A script started again does not pay twice for what it already sent, as long as it goes as far as/complete. - An
Idempotency-Keyon aPOSTreturns the same response to a call sent again, rather than doing it again: Limits and errors.