Delete a media folder
Delete a media folder. By default its files are not deleted: they return to the unfiled library and the folder is gone in one call. Pass ?withContents=true to delete the files too.
DELETE https://sitepaste.com/api/v1/public/media/folders/{folderId}
Requires the media scope.
Usage
# Delete the folder, keeping its files (they return to the unfiled library)
curl -X DELETE "https://sitepaste.com/api/v1/public/media/folders/f8qjx2v7mz4r" \
-H "Authorization: Bearer $TOKEN"
# Delete the folder and its files
curl -X DELETE "https://sitepaste.com/api/v1/public/media/folders/f8qjx2v7mz4r?withContents=true" \
-H "Authorization: Bearer $TOKEN"
Authorizations
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token (Authorization: Bearer sp_...). Created in the dashboard under Account > Tokens. See authentication. |
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| withContents | boolean | No | true deletes the folder’s files as well, up to 100 per call. Anything else, or omitting it, unfiles them instead. |
Response
{ "deleted": 12, "remaining": 0 }
| Field | Type | Description |
|---|---|---|
| deleted | number | Files deleted in this call. Always 0 without withContents=true. |
| remaining | number | Files still in the folder. Non-zero when a large folder needs another call. |
Without withContents=true the response is always { "deleted": 0, "remaining": 0 }.
With withContents=true each request deletes at most 100 files, so loop until remaining is 0. The folder itself is removed on the call that empties it.
400 when {folderId} is malformed. 404 when it is well formed but no folder in your workspace has that id.