Appearance
Storage Upload
A step-by-step guide to uploading files to Repliz Storage using the API.
Overview
Repliz Storage uses a three-step upload flow to securely upload files. Instead of sending the file directly through the API, you receive a presigned upload URL and upload the file directly to the storage service.
Init File → Upload to Presigned URL → Complete FileUpload Flow
Step 1: Initialize the Upload
Call the Init File endpoint with the file metadata (filename, size, and MIME type). This creates an upload session and returns a presigned URL.
bash
curl -X POST "https://api.repliz.com/public/storage/file/init" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)" \
-H "Content-Type: application/json" \
-d '{
"filename": "promo-video.mp4",
"size": 10485760,
"mimetype": "video/mp4"
}'The response contains:
| Field | Description |
|---|---|
id | The file ID — you will need this for Step 3. |
upload | The presigned URL where you should upload the file binary. |
key | The storage key (internal path) of the file. |
url | The public URL of the file (accessible after upload completes). |
json
{
"id": "6a4c3a3bc4586b1f1ce483e4",
"upload": "https://repliz.xxxxx.r2.cloudflarestorage.com/uploads/...",
"key": "uploads/.../promo-video.mp4",
"url": "https://storage.repliz.com/uploads/.../promo-video.mp4"
}Step 2: Upload the File
Upload your file directly to the upload URL from Step 1 using a PUT request. The request body must be the raw binary of the file, and the Content-Type header must match the MIME type used during initialization.
bash
curl -X PUT "UPLOAD_URL_FROM_STEP_1" \
-H "Content-Type: video/mp4" \
--data-binary @promo-video.mp4javascript
import axios from "axios";
import fs from "fs";
const fileBuffer = fs.readFileSync("./promo-video.mp4");
await axios.put(uploadUrl, fileBuffer, {
headers: {
"Content-Type": "video/mp4",
},
maxBodyLength: Infinity,
});javascript
const fileBuffer = await fs.promises.readFile("./promo-video.mp4");
await fetch(uploadUrl, {
method: "PUT",
headers: {
"Content-Type": "video/mp4",
},
body: fileBuffer,
});Important
- The
Content-Typeheader must match themimetypeyou provided in Step 1. - The presigned URL expires after a short time (typically 10 minutes). Upload the file promptly after initialization.
- Do not include the
Authorizationheader in this request — the presigned URL already contains the necessary credentials.
Step 3: Complete the Upload
After the file has been successfully uploaded, call the Complete File endpoint to finalize the process. This marks the file as success and makes it available for use.
bash
curl -X POST "https://api.repliz.com/public/storage/file/FILE_ID/complete" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)"Once completed, the file is accessible via the url returned in Step 1 and can be used in scheduled posts, chat messages, and other features.
Full Example
Here is the complete upload flow in JavaScript:
javascript
import axios from "axios";
import fs from "fs";
const API_BASE = "https://api.repliz.com";
const auth = {
username: "YOUR_ACCESS_KEY",
password: "YOUR_SECRET_KEY",
};
async function uploadFile(filePath, filename, mimetype) {
// Step 1: Init
const { data: initData } = await axios.post(
`${API_BASE}/public/storage/file/init`,
{ filename, size: fs.statSync(filePath).size, mimetype },
{ auth },
);
console.log("File ID:", initData.id);
console.log("Upload URL:", initData.upload);
// Step 2: Upload binary to presigned URL
const fileBuffer = fs.readFileSync(filePath);
await axios.put(initData.upload, fileBuffer, {
headers: { "Content-Type": mimetype },
maxBodyLength: Infinity,
});
console.log("File uploaded successfully");
// Step 3: Complete
await axios.post(
`${API_BASE}/public/storage/file/${initData.id}/complete`,
{},
{ auth },
);
console.log("Upload completed! File URL:", initData.url);
return initData;
}
// Usage
uploadFile("./promo-video.mp4", "promo-video.mp4", "video/mp4");javascript
import fs from "fs";
const API_BASE = "https://api.repliz.com";
const credentials = btoa("YOUR_ACCESS_KEY:YOUR_SECRET_KEY");
const headers = {
Authorization: `Basic ${credentials}`,
"Content-Type": "application/json",
};
async function uploadFile(filePath, filename, mimetype) {
// Step 1: Init
const initRes = await fetch(`${API_BASE}/public/storage/file/init`, {
method: "POST",
headers,
body: JSON.stringify({
filename,
size: fs.statSync(filePath).size,
mimetype,
}),
});
const initData = await initRes.json();
console.log("File ID:", initData.id);
console.log("Upload URL:", initData.upload);
// Step 2: Upload binary to presigned URL
const fileBuffer = await fs.promises.readFile(filePath);
await fetch(initData.upload, {
method: "PUT",
headers: { "Content-Type": mimetype },
body: fileBuffer,
});
console.log("File uploaded successfully");
// Step 3: Complete
await fetch(`${API_BASE}/public/storage/file/${initData.id}/complete`, {
method: "POST",
headers: { Authorization: `Basic ${credentials}` },
});
console.log("Upload completed! File URL:", initData.url);
return initData;
}
// Usage
uploadFile("./promo-video.mp4", "promo-video.mp4", "video/mp4");Using Uploaded Files
Once a file is uploaded and completed, you can use the file url in:
- Scheduled Posts: use the URL in the
mediasarray when creating schedules - Chat Messages: send images, videos, or documents using the file URL
- Content Comments: attach media to comment replies
bash
# Example: Create a scheduled post using the uploaded file
curl -X POST "https://api.repliz.com/public/schedule" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)" \
-H "Content-Type: application/json" \
-d '{
"title": "",
"description": "Check out this video!",
"type": "video",
"medias": [{
"alt": "",
"type": "video",
"thumbnail": "",
"url": "https://storage.repliz.com/uploads/.../promo-video.mp4"
}],
"meta": { "title": "", "description": "", "url": "" },
"additionalInfo": {
"isAiGenerated": false,
"isDraft": false,
"isAutoAddMusic": false,
"collaborators": [],
"music": { "id": "", "artist": "", "name": "", "thumbnail": "" },
"products": [],
"tags": [],
"mentions": [],
"link": "",
"targetCountries": []
},
"replies": [],
"topic": "",
"accountId": "YOUR_ACCOUNT_ID",
"scheduleAt": "2026-07-08T10:00:00.000Z"
}'Checking Storage Usage
Monitor your storage consumption using the Statistic endpoint:
bash
curl -X GET "https://api.repliz.com/public/storage/statistic" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)"json
{
"file": { "total": 5, "success": 4, "pending": 1 },
"usage": { "total": 5368709120, "free": 5200000000, "used": 168709120 }
}total: your storage limit in bytesused: how much storage you've consumedfree: remaining available storage
TIP
Keep an eye on your storage usage. If you exceed your storage limit, the Init File endpoint will return a 402 error. Upgrade your plan or delete unused files to free up space.
Related APIs
- Init File: initialize a file upload session
- Complete File: finalize a file upload
- Get File: list all uploaded files
- Get One File: get details of a specific file
- Remove File: delete a file from storage
- Get Statistic: check storage usage
