English
English
Appearance
English
English
Appearance
A step-by-step guide to uploading files to Repliz Storage using the API.
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 FileCall the Init File endpoint with the file metadata (filename, size, and MIME type). This creates an upload session and returns a presigned URL.
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). |
{
"id": "6a4c3a3bc4586b1f1ce483e4",
"upload": "https://repliz.xxxxx.r2.cloudflarestorage.com/uploads/...",
"key": "uploads/.../promo-video.mp4",
"url": "https://storage.repliz.com/uploads/.../promo-video.mp4"
}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.
curl -X PUT "UPLOAD_URL_FROM_STEP_1" \
-H "Content-Type: video/mp4" \
--data-binary @promo-video.mp4import 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,
});const fileBuffer = await fs.promises.readFile('./promo-video.mp4');
await fetch(uploadUrl, {
method: 'PUT',
headers: {
'Content-Type': 'video/mp4',
},
body: fileBuffer,
});Important
Content-Type header must match the mimetype you provided in Step 1.Authorization header in this request — the presigned URL already contains the necessary credentials.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.
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.
Here is the complete upload flow in 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');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');Once a file is uploaded and completed, you can use the file url in:
medias array when creating schedules# 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,
"isShareToFeed": false,
"collaborators": [],
"music": { "id": "", "artist": "", "name": "", "thumbnail": "", "volume": { "video": 50, "music": 100 } },
"products": [],
"tags": [],
"mentions": [],
"targetCountries": []
},
"replies": [],
"topic": "",
"accountId": "YOUR_ACCOUNT_ID",
"scheduleAt": "2026-07-08T10:00:00.000Z"
}'Monitor your storage consumption using the Statistic endpoint:
curl -X GET "https://api.repliz.com/public/storage/statistic" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)"{
"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 storageTIP
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.