Delete File / Folder
Delete files or folders from your shard node by sending a DELETE request to the specified endpoint with the destination path as a query parameter.
DELETE
/fso
FSO stands for "file system object" - in this case, a file or folder
Important Notes
- • All paths must start with
/(absolute paths only) - • Use your shard node URL and your API key
Headers
| Header | Type | Required | Description |
|---|---|---|---|
| x-user-api-key | string | Yes | Your authentication API key |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| path | string | Yes | Absolute path of the file or folder to delete (must start with /) |
Example Request
func DeleteFile(pathOnShard string) {
url := fmt.Sprintf("%s/fso?path=%s", SHARD_NODE_URL, url.QueryEscape(pathOnShard))
req, err := http.NewRequest(http.MethodDelete, url, nil)
if err != nil {
panic(fmt.Errorf("could not create delete request: %w", err))
}
req.Header.Set("x-user-api-key", API_KEY)
client := http.DefaultClient
resp, err := client.Do(req)
if err != nil {
panic(fmt.Errorf("error deleting file: %w", err))
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
panic(fmt.Sprintf("Delete failed with status %d: %s", resp.StatusCode, string(body)))
}
}
async function deleteFile(pathOnShard: string): Promise<void> {
const url = `${SHARD_NODE_URL}/fso?path=${encodeURIComponent(pathOnShard)}`;
const res = await fetch(url, {
method: 'DELETE',
headers: {
'x-user-api-key': API_KEY
}
});
if (res.status !== 200) {
const body = await res.text();
throw new Error(`Delete failed with status ${res.status}: ${body}`);
}
}
Response Status Codes
| Code | Status | Description |
|---|---|---|
| 200 | Success | File or folder deleted successfully |
| 400 | Bad Request | Invalid request parameters |
| 401 | Unauthorized | Invalid or missing API key |
| 404 | Not Found | File or folder doesn't exist |
| 5xx | Server Error | Internal server error - check response body for details |