Get presigned upload URL
Generate a presigned URL for direct file upload. This allows clients to upload files directly to storage without passing through the API server. After uploading, call POST /files to create the database record.
curl -X POST https://app.mavera.io/api/v1/files/upload-url \
-H "Authorization: Bearer mvra_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"file_name": "image.png",
"file_type": "image/png",
"file_size": 524288,
"workspace_id": "ws_abc123"
}'import requests
import hashlib
def upload_file(file_path, workspace_id, api_key):
# Read file and compute checksum
with open(file_path, "rb") as f:
content = f.read()
checksum = hashlib.sha256(content).hexdigest()
file_name = file_path.split("/")[-1]
file_type = "application/octet-stream" # Or detect from extension
headers = {"Authorization": f"Bearer {api_key}"}
# Get presigned URL
response = requests.post(
"https://app.mavera.io/api/v1/files/upload-url",
headers=headers,
json={
"file_name": file_name,
"file_type": file_type,
"file_size": len(content),
"checksum": checksum,
"workspace_id": workspace_id
}
).json()
# Upload to presigned URL
requests.put(
response["upload_url"],
data=content,
headers={"Content-Type": file_type}
)
# Create file record
file = requests.post(
"https://app.mavera.io/api/v1/files",
headers=headers,
json={
"name": file_name,
"type": file_type,
"url": response["public_url"],
"workspace_id": workspace_id,
"file_size": len(content)
}
).json()
return fileconst options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
file_name: '<string>',
file_type: '<string>',
file_size: 2,
workspace_id: '<string>',
checksum: '<string>',
folder_id: '<string>'
})
};
fetch('https://app.mavera.io/api/v1/files/upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.mavera.io/api/v1/files/upload-url"
payload := strings.NewReader("{\n \"file_name\": \"<string>\",\n \"file_type\": \"<string>\",\n \"file_size\": 2,\n \"workspace_id\": \"<string>\",\n \"checksum\": \"<string>\",\n \"folder_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"object": "upload_url",
"upload_url": "<string>",
"public_url": "<string>",
"key": "<string>",
"expires_in": 123,
"method": "PUT",
"headers": {
"Content-Type": "<string>",
"x-amz-checksum-sha256": "<string>"
},
"next_step": {
"description": "<string>",
"endpoint": "<string>",
"body": {}
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}Authorizations
API key prefixed with mvra_live_. Create keys at Settings > Developer > API Keys.
Body
Name of the file to upload
MIME type of the file (e.g., 'image/png', 'application/pdf')
File size in bytes. Maximum 10MB for regular files, 2GB for video files.
x >= 1Workspace to upload the file to
SHA256 checksum of the file for integrity verification (optional)
Optional folder ID to organize the file
Response
Presigned upload URL generated
Response containing the presigned upload URL and instructions
upload_url Presigned URL for uploading the file (PUT request)
Public URL where the file will be accessible after upload
Storage key for the file
Seconds until the upload URL expires (3600 = 1 hour)
HTTP method to use for uploading
PUT Headers to include when uploading to the presigned URL
Show child attributes
Show child attributes
Instructions for completing the upload
Show child attributes
Show child attributes
curl -X POST https://app.mavera.io/api/v1/files/upload-url \
-H "Authorization: Bearer mvra_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"file_name": "image.png",
"file_type": "image/png",
"file_size": 524288,
"workspace_id": "ws_abc123"
}'import requests
import hashlib
def upload_file(file_path, workspace_id, api_key):
# Read file and compute checksum
with open(file_path, "rb") as f:
content = f.read()
checksum = hashlib.sha256(content).hexdigest()
file_name = file_path.split("/")[-1]
file_type = "application/octet-stream" # Or detect from extension
headers = {"Authorization": f"Bearer {api_key}"}
# Get presigned URL
response = requests.post(
"https://app.mavera.io/api/v1/files/upload-url",
headers=headers,
json={
"file_name": file_name,
"file_type": file_type,
"file_size": len(content),
"checksum": checksum,
"workspace_id": workspace_id
}
).json()
# Upload to presigned URL
requests.put(
response["upload_url"],
data=content,
headers={"Content-Type": file_type}
)
# Create file record
file = requests.post(
"https://app.mavera.io/api/v1/files",
headers=headers,
json={
"name": file_name,
"type": file_type,
"url": response["public_url"],
"workspace_id": workspace_id,
"file_size": len(content)
}
).json()
return fileconst options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
file_name: '<string>',
file_type: '<string>',
file_size: 2,
workspace_id: '<string>',
checksum: '<string>',
folder_id: '<string>'
})
};
fetch('https://app.mavera.io/api/v1/files/upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.mavera.io/api/v1/files/upload-url"
payload := strings.NewReader("{\n \"file_name\": \"<string>\",\n \"file_type\": \"<string>\",\n \"file_size\": 2,\n \"workspace_id\": \"<string>\",\n \"checksum\": \"<string>\",\n \"folder_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"object": "upload_url",
"upload_url": "<string>",
"public_url": "<string>",
"key": "<string>",
"expires_in": 123,
"method": "PUT",
"headers": {
"Content-Type": "<string>",
"x-amz-checksum-sha256": "<string>"
},
"next_step": {
"description": "<string>",
"endpoint": "<string>",
"body": {}
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}