Skip to content
AdCrunch
Esc
↑↓navigate↵open⌘Jpreview

Reserve an Asset and mint an upload URL

Reserves an Asset and returns a presigned PUT URL to upload the bytes to. The URL is valid for one hour, and expiresAt says when it stops being accepted.

The client uploads directly to storage — the bytes never pass through this worker, because Cloudflare rejects over-limit request bodies at the proxy before any code runs. Call POST /assets/{id}/finalize once the upload completes.

The URL is the credential: anyone holding it can write that one key until it expires. Nothing is known about the file until finalize inspects what actually landed, so size and type cannot be enforced here.

The reserved Asset stays pending until finalize. No read, rename or list answers a pending Asset, and a reservation nobody finalizes is swept a day later, together with whatever landed under it.

POST/assets/uploads
Authorization
AuthorizationBearer token · headerrequired

Send Authorization: Bearer <credential>.

Use an API key (acr_…), from the AdCrunch console under Settings → API keys.

The credential names the organization, and no operation takes an organization parameter.

See https://docs.adcrunch.dev/api/authentication.

Request body
requiredapplication/json
filenamestringrequired

The name of the file you are about to send. Shown until somebody renames the Asset, and never used to look one up.

min length 1 · max length 255
Responses
200

The reservation. Send the bytes to uploadUrl, then finalize assetId.

assetIdstringrequired

The Asset this reservation made. Finalize it with this id.

expiresAtnumberrequired

When the upload URL stops being accepted.

uploadUrlstringrequired

PUT the bytes here, directly. The URL is the credential: anybody holding it can write that one object until it expires.

400

The request does not match the schema of this operation: a field is missing or has the wrong type, or the body is not valid JSON. error is invalid_request, and issues names each field. Nothing was changed.

issuesobject[]required

One entry for each field that does not match.

Show properties
Array of object
instringrequired

The part of the request that holds the field.

Allowed:bodycookieheadersparamsquery
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

pathstringrequired

A JSON Pointer into that part of the request, such as /filename. An empty string is the whole part.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

Allowed:invalid_request
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

401

No API key, or one that does not resolve. See the security scheme. error is unauthorized.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

Allowed:unauthorized
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

403

The caller does not hold asset:write. error is forbidden.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

Allowed:forbidden
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

500

AdCrunch could not write the reservation. error is reservation_failed. Nothing was reserved, so send the request again.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

Request
curl -X POST "https://api.pr-701.adcrunch.dev/assets/uploads" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "filename": "spring-sale.mp4"
}'
Response
{
  "assetId": "ast_7c1e9a",
  "expiresAt": 1790003600000,
  "uploadUrl": "https://b7f3c81a29d64e0fa5c3d1e8b0947265.r2.cloudflarestorage.com/assets/org_3a7f10/ast_7c1e9a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20260922T101500Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=7d1c4a9f2e8b0536c1a7e94d2b6f038a5c1e9b7d3f6a2c805d4e1b93a7f0c625"
}