Upload file

POST

Upload a file to decentralized storage on Walrus Protocol.

Endpoint

POST https://api.tuskr.dev/v1/files

Request Headers

HeaderTypeDescription
AuthorizationstringBearer token with your API key
Content-Typestringmultipart/form-data

Request Body

FieldTypeDescription
fileFileThe file to upload (required)
tagstringOptional tag for organization
categorystringOptional category for grouping
epochsnumberStorage duration in epochs (default: 1)

Example Request

const formData = new FormData()
formData.append('file', file)
formData.append('tag', 'avatar')
formData.append('category', 'images')
 
const response = await fetch('https://api.tuskr.dev/v1/files', {
method: 'POST',
headers: {
'Authorization': 'Bearer tsk_live_xxxx'
},
body: formData
})

Response

{
"id": "file_abc123",
"blob_id": "0x1a2b3c4d5e6f...",
"url": "https://cdn.tuskr.dev/abc123",
"size": 1048576,
"mime_type": "image/png",
"tag": "avatar",
"category": "images",
"created_at": "2024-01-15T10:30:00Z",
"expires_at": "2024-02-15T10:30:00Z"
}