Skip to main content

Files

CRUD endpoints for every file hosted on your Flexweg site — HTML, CSS, JS, images, fonts, PDF.

All endpoints require a valid X-API-Key header. See Authentication.

GET /api/v1/files/list

List all files and folders on your site with metadata (size, type, URL). Supports pagination for large sites.

Query parameters (all optional)

FieldTypeDefaultDescription
pageinteger1Page number.
per_pageinteger100Items per page (max 100).
cURL
curl -X GET "https://www.flexweg.com/api/v1/files/list?page=1&per_page=100" \
-H "X-API-Key: YOUR_API_KEY"
200 OK
{
"success": true,
"storage_folder": {
"slug": "a78gj8d3",
"name": "Mon Site",
"file_count": 30,
"storage_used": 274668,
"storage_used_formatted": "268.23 KB"
},
"pagination": {
"current_page": 1,
"per_page": 100,
"total_items": 3,
"total_pages": 1,
"has_more": false,
"is_last_page": true
},
"files": [
{
"path": "coree",
"name": "coree",
"type": "folder",
"size": 0,
"size_formatted": "0 B",
"url": null,
"depth": 0,
"parent": null
},
{
"path": "coree/index.html",
"name": "index.html",
"type": "file",
"size": 9971,
"size_formatted": "9.74 KB",
"url": "https://your-site.flexweg.com/coree/index.html",
"depth": 1,
"parent": "coree"
}
]
}
Notes
  • Folders appear with type: "folder" and url: null.
  • .gitkeep files are filtered out automatically.
  • Results are sorted by depth, then folders-first, then alphabetically by name.
  • Check pagination.has_more to know if you need to fetch another page.

GET /api/v1/files/get

Retrieve the raw content of a single file.

Query parameters

FieldTypeDescription
pathstring (required)Path of the file (e.g. index.html, assets/css/main.css).
cURL
curl -X GET "https://www.flexweg.com/api/v1/files/get?path=index.html" \
-H "X-API-Key: YOUR_API_KEY"

POST /api/v1/files/upload

Create or update a file. If a file already exists at the target path, it is overwritten.

Body parameters

FieldTypeDescription
pathstring (required)Target path — determines where the file lives and its public URL.
contentstring (required)File content. Plain text for text files, base64-encoded for binary files.
encodingstringSet to "base64" for binary uploads. Omit for text files.

Example 1 — HTML file

cURL
curl -X POST https://www.flexweg.com/api/v1/files/upload \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path": "index.html", "content": "<!DOCTYPE html>..."}'

Example 2 — CSS file

cURL
curl -X POST https://www.flexweg.com/api/v1/files/upload \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path": "assets/css/main.css", "content": "body { margin: 0; }"}'

Example 3 — Binary file (image)

cURL
curl -X POST https://www.flexweg.com/api/v1/files/upload \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"path": "assets/img/logo.png",
"content": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"encoding": "base64"
}'

Supported file types

  • Web: HTML, CSS, JS, JSON, XML, TXT
  • Images: JPG, JPEG, PNG, GIF, SVG, WebP, ICO
  • Documents: PDF
  • Fonts: WOFF, WOFF2, TTF, OTF
  • Videos: see Videos for dedicated endpoint

Max size: 10 MB per file.

Error responses

403 — File limit exceeded
{
"error": "File limit exceeded",
"message": "You have reached your file limit of 20 files. Upgrade your plan to upload more files.",
"current_file_count": 20,
"file_limit": 20,
"current_plan": "free",
"upgrade_url": "https://www.flexweg.com/pricing"
}
403 — Storage limit exceeded
{
"error": "Storage limit exceeded",
"message": "You have reached your storage limit of 2 MB. Available space: 256 KB. Upgrade your plan to get more storage.",
"current_storage": 1835008,
"storage_limit": 2097152,
"storage_limit_formatted": "2 MB",
"current_storage_formatted": "1.75 MB",
"available_storage": 262144,
"available_storage_formatted": "256 KB",
"current_plan": "free",
"upgrade_url": "https://www.flexweg.com/pricing"
}
400 — File too large
{
"error": "File too large",
"message": "File size exceeds the maximum allowed size of 10 MB",
"max_size_bytes": 10485760
}
400 — Invalid file type
{
"error": "Invalid file type",
"message": "File type 'exe' is not allowed. Allowed types: html, css, js, jpg, jpeg, png, ..."
}

Limits by plan

PlanFilesStorage
Free202 MB
Standard10010 MB
Premium50050 MB
Business2000500 GB
EnterpriseUnlimitedUnlimited

Use the Storage endpoint to check your live usage before uploading.

POST /api/v1/files/rename

Rename a file or move it to a new path.

Body parameters

FieldTypeDescription
old_pathstring (required)Current path.
new_pathstring (required)New path. Folders are created automatically.
cURL
curl -X POST https://www.flexweg.com/api/v1/files/rename \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"old_path": "old.html", "new_path": "new.html"}'
Existing URLs will break

Renaming changes the file's public URL. Anyone who bookmarked or linked to the old path will get a 404.

DELETE /api/v1/files/delete

Permanently delete a file.

Query parameters

FieldTypeDescription
pathstring (required)Path of the file to delete.
cURL
curl -X DELETE "https://www.flexweg.com/api/v1/files/delete?path=index.html" \
-H "X-API-Key: YOUR_API_KEY"
Irreversible

Deletion is immediate and cannot be undone. Files do not go through a trash bin.