Announce a file

POST /api/v1/deliveries/{id}/files

Announces a file of the delivery: its name, its exact size, its type. A credit is reserved then, and the response gives the address to send the bytes to.

Scope · deliveries:write Takes an Idempotency-Key

Path parameters

id uuid required
The delivery, as POST /deliveries returned it.

Request body

name string required
The file’s name, 500 characters at most. ValidFile reads it to choose the placement: Meta_FR_story-noel.mp4 helps, 001.mp4 does not. Join folders with _.
size integer required
The exact size in bytes, 5 GB at most. The upload address accepts this size only.
type string required
The MIME type, 200 characters at most. The real type is read from the bytes: a PNG named .jpg is judged as a PNG.

What the response holds · 201

file announced
The file announced.

The fields of announced

id uuid
The file, for /complete, reading and DELETE.
uploadUrl uri
A resumable Cloud Storage upload session, in Montréal, for this file only. PUT the bytes there: Sending a file says how.

Errors

400invalidFix the request: a field is missing, too long or of another type, or the JSON is malformed.
400emptyA 0-byte file: do not send it.
402no_creditsNo files left on the plan, and no credits; left says what is left. Buy some in ValidFile, or wait for the next period.
402key_ceilingThe key’s ceiling is reached for the period; cap says what it is.
403scopeThe key does not have the scope the route asks for: a read-only key tried to write, or a key without drop-links:write tried to make or cut a drop link.
404not_foundA delivery or file unknown, deleted, or erased at the end of its retention; or an address the API does not have.
413too_largeA file of more than 5 GB, a file of more than 25 MB sent to POST /validate (announce it with POST …/files instead), or a JSON body of more than 64 KiB.
415zip_not_supportedA zip: unzip a zip of files and announce each file; an HTML5 banner is dropped in ValidFile, which judges it.
429too_many_pendingToo many files not judged yet: wait Retry-After seconds, or for verdicts.
429test_limitThe agency’s 10 test files in 24 h are taken: wait Retry-After seconds, until the oldest is erased.
409idempotency_mismatchThe same Idempotency-Key with another body: take a new one.
409idempotency_in_progressThe first call is still running: try again in a moment, with the same key.

And those of any call, in Limits and errors.

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.

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"
  }'
{
  "file": { "id": "9e2d4c1a-3b7f-4e0d-8a6c-2f1b5d9e7c43" },
  "uploadUrl": "https://storage.northamerica-northeast1.rep.googleapis.com/upload/storage/v1/b/…&upload_id=…"
}