Skip to content
RobinReturn (opens in a new tab)
Partner API

Uploads

Upload an invoice document to RobinReturn via a presigned URL before creating a case over the Partner API.

Last updated

Every case carries its original invoice document, so creating a case starts with uploading the invoice. This is a two-part step: ask for a presigned URL, then PUT the file bytes to it.

Request a presigned URL

Requires the cases:write scope.

curl -X POST https://app.robinreturn.co.uk/api/v1/uploads \
  -H "Authorization: Bearer $RR_API_KEY" \
  -H "Content-Type: application/json" \
  --data "{\"filename\": \"invoice-001.pdf\", \"contentType\": \"application/pdf\", \"contentLength\": $(wc -c < invoice-001.pdf)}"

All three fields are required. Allowed contentType values: application/pdf, image/png, image/jpeg — no other type is accepted.

contentLength is the exact byte count of the file you are about to PUT. It must be a positive integer of at most 15,728,640 bytes (15 MiB). Omitting it, exceeding that cap, or sending an unsupported contentType returns 422 Validation failed with an issues array identifying the offending field — no presigned URL is issued.

Response

{
  "fileKey": "<companyId>/api-uploads/<uuid>/invoice-001.pdf",
  "uploadUrl": "https://…presigned-PUT…",
  "expiresInSeconds": 300
}

Upload the file

PUT the raw file bytes to uploadUrl with the same Content-Type you declared and exactly the number of bytes you declared as contentLength:

curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: application/pdf" \
  --data-binary @invoice-001.pdf

--data-binary sends the file unchanged and sets Content-Length to its exact size. Put the uploadUrl from the response in UPLOAD_URL first.

The declared size is signed into the URL, so R2 refuses a PUT of any other length. That refusal comes from R2 itself rather than from RobinReturn, so it does not use the { "error": … } JSON envelope and is hard to interpret — measure the file's byte length and send that exact number rather than an estimate or a rounded value.

The presigned URL expires after expiresInSeconds (300s). If it lapses, request a new one.

Next

Keep the returned fileKey — you pass it as invoiceFileKey when you create the case. A fileKey is scoped to your company; a case referencing a key outside your company's prefix is rejected (INVALID_FILE_KEY).