Create an asset

Adds an uploaded file to the project's library once its bytes are checked.

Only whoever started the upload can finish it, and finishing it again answers the same asset. Needs project:files:write.

Guide: Fonts and images

POST
/api/v1/projects/{projectId}/assets

Authorization

AuthorizationBearer <token>

A project secret key: vh_sk_... for production, vh_sk_test_... for test. Keep it on your servers.

In: header

Path parameters

projectId*string

The project's id, proj_.... A secret key works only in the project it belongs to.

Request body

application/json

TypeScript definitions

Use the request body type in TypeScript.

uploadId*string

The upload whose file has been sent to storage, upload_....

Examples

curl -X POST "https://api.voidhash.com/api/v1/projects/proj_tz4a98xxat96iws9zmbrgj3a/assets" \  -H "Authorization: Bearer vh_sk_..." \  -H "Content-Type: application/json" \  -d '{    "uploadId": "upload_h7d2k9m4x1c6v8b3n5q0w2e7"  }'
{  "id": "asset_n5q0w2e7h7d2k9m4x1c6v8b3",  "projectId": "proj_tz4a98xxat96iws9zmbrgj3a",  "kind": "image",  "name": "hero.png",  "url": "https://api.voidhash.com/files/file_t2y5u8i1o4p7a0s3d6f9g2h5j8",  "contentType": "image/png",  "sizeBytes": 48213,  "width": 1170,  "height": 780,  "createdBy": "user:user_k3m8q1z6v9c2x5b7n4w0e8r1",  "createdAt": "2026-02-20T16:30:00.000Z"}
{  "error": {    "type": "invalid_request",    "code": "invalid_file",    "message": "File type or size is not allowed."  }}
{  "error": {    "type": "unauthenticated",    "code": "invalid_api_key",    "message": "This secret key is not valid."  }}
{  "error": {    "type": "permission_denied",    "code": "permission_denied",    "message": "Insufficient permissions."  }}

{  "error": {    "type": "not_found",    "code": "upload_not_found",    "message": "This project has no upload upload_h7d2k9m4x1c6v8b3n5q0w2e7 that you started.",    "param": "uploadId"  }}

{  "error": {    "type": "conflict",    "code": "upload_incomplete",    "message": "Upload has not reached storage.",    "param": "uploadId"  }}

{  "error": {    "type": "internal",    "code": "internal_error",    "message": "Something went wrong on our side. Try again, and contact support with the Request-Id header if it keeps failing."  }}
{  "error": {    "type": "unavailable",    "code": "file_storage_unavailable",    "message": "File storage is temporarily unavailable. Try again shortly."  }}

Response body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

Errors

StatustypecodeWhen
400invalid_requestinvalid_fileFor a file that is not what it was said to be.
404not_foundupload_not_foundFor an upload the project does not have or someone else started.
409conflictupload_incompleteWhile the file has not reached storage, is still being checked, or was refused or expired before (message says which).
409conflictasset_limit_reachedWhen the library is full.
503unavailablefile_storage_unavailable—

It can also fail with the errors every operation shares, such as unauthenticated; see Errors.

More in Assets

Something wrong or missing on this page? Tell us by email or on Discord.