Media Library API Documentation ​
Media library management endpoints for uploading, browsing, and managing media files and folders.
Behavior change (v6.0.0): folder ids must be plain integers
media.folderdelete now requires FolderID to be a digits-only value, refused with ErrorCode 2, which is the code the command already returned for an id resolving to no folder. 7 with a trailing space, 7abc, 7.0, -1, 0x07 and an array value are now refused.
This one mattered more than the others: the folder id reached a SQL condition that was emitted without quoting, so a crafted value could widen the delete beyond the caller's own folders. A bare integer for a folder the caller owns behaves exactly as before, deleting the folder, its sub-folders, its files and their stored blobs, and a bare integer for a folder the caller does not own still answers ErrorCode 3. See Behavior changes in v6.0.0 for the full list.
Browse Media Library ​
POST/api.phpDEPRECATION WARNING
This endpoint is deprecated and will be removed in a future Octeth release. There are no alternative or replacement API endpoints available.
API Usage Notes
- Authentication required: User API Key
- Required permissions:
Media.Browse - Legacy endpoint access via
/api.phponly (no v1 REST alias configured)
Browse media library files and folders in a specified folder.
Since v6.0.8 (#4112) each file also has MediaURL, the absolute public address to use in emails, with Type (MIME type) and Size (bytes). Path lists the folders from the top level down to the browsed one (empty at the top level), and Rules holds the install's media library rules: Enabled, AllowedFileTypes and MaxFileSize in bytes. URL is unchanged.
Request Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Command | String | Yes | API command: media.browse |
| SessionID | String | No | Session ID obtained from login |
| APIKey | String | No | API key for authentication |
| FolderID | Integer | No | Parent folder ID to browse (default: 0 = root) |
curl -X POST https://example.com/api.php \
-H "Content-Type: application/json" \
-d '{
"Command": "media.browse",
"SessionID": "your-session-id",
"FolderID": 0
}'{
"Success": true,
"ErrorCode": 0,
"ErrorText": "",
"Folders": [
{
"ID": 123,
"Name": "My Folder",
"ParentFolderID": 0
}
],
"Files": [
{
"ID": 456,
"Name": "image.jpg",
"URL": "/public/file/view/rt/th",
"MediaURL": "https://example.com/m/rt/th",
"Type": "image/jpeg",
"Size": 102400
}
],
"Path": [],
"Rules": {
"Enabled": true,
"AllowedFileTypes": ["image/gif", "image/jpeg", "image/png", "application/pdf"],
"MaxFileSize": 5242880
}
}{
"Success": false,
"ErrorCode": [1]
}0: SuccessDelete Media File ​
POST/api/v1/media.deleteDEPRECATION WARNING
This endpoint is deprecated and will be removed in a future Octeth release. There are no alternative or replacement API endpoints available.
API Usage Notes
- Authentication required: User API Key or Admin API Key
- Required permissions:
Media.Delete - v1 REST alias:
POST /api/v1/media.delete. Legacy access via/api.phpis also supported
Delete a media file from the media library. The stored bytes are deleted from the storage that holds them, whatever the install's current storage method is (v6.0.8, #4112).
Request Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Command | String | Yes | API command: media.delete |
| SessionID | String | No | Session ID obtained from login |
| APIKey | String | No | API key for authentication |
| MediaID | Integer | Yes | ID of the media file to delete |
curl -X POST https://example.com/api.php \
-H "Content-Type: application/json" \
-d '{
"Command": "media.delete",
"SessionID": "your-session-id",
"MediaID": 456
}'{
"Success": true,
"ErrorCode": 0
}{
"Success": false,
"ErrorCode": [1]
}0: Success
1: Missing required parameter: MediaID
2: Media file not found or permission deniedCreate Media Library Folder ​
POST/api.phpDEPRECATION WARNING
This endpoint is deprecated and will be removed in a future Octeth release. There are no alternative or replacement API endpoints available.
API Usage Notes
- Authentication required: User API Key
- Required permissions:
Media.Upload - Legacy endpoint access via
/api.phponly (no v1 REST alias configured)
Create a new folder in the media library.
Request Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Command | String | Yes | API command: media.foldercreate |
| SessionID | String | No | Session ID obtained from login |
| APIKey | String | No | API key for authentication |
| FolderName | String | Yes | Name of the folder to create |
| ParentFolderID | Integer | Yes | Parent folder ID (use 0 for root level) |
curl -X POST https://example.com/api.php \
-H "Content-Type: application/json" \
-d '{
"Command": "media.foldercreate",
"SessionID": "your-session-id",
"FolderName": "My Images",
"ParentFolderID": 0
}'{
"Success": true,
"ErrorCode": 0,
"FolderID": 789
}{
"Success": false,
"ErrorCode": [1, 2]
}0: Success
1: Missing required parameter: FolderName
2: Missing required parameter: ParentFolderID
3: Parent folder not foundDelete Media Library Folder ​
POST/api.phpDEPRECATION WARNING
This endpoint is deprecated and will be removed in a future Octeth release. There are no alternative or replacement API endpoints available.
API Usage Notes
- Authentication required: User API Key
- Required permissions:
Media.Delete - Legacy endpoint access via
/api.phponly (no v1 REST alias configured)
Delete a folder and all its contents (files and subfolders) from the media library.
Request Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Command | String | Yes | API command: media.folderdelete |
| SessionID | String | No | Session ID obtained from login |
| APIKey | String | No | API key for authentication |
| FolderID | Integer | Yes | ID of the folder to delete |
curl -X POST https://example.com/api.php \
-H "Content-Type: application/json" \
-d '{
"Command": "media.folderdelete",
"SessionID": "your-session-id",
"FolderID": 789
}'{
"Success": true,
"ErrorCode": 0
}{
"Success": false,
"ErrorCode": [1]
}0: Success
1: Missing required parameter: FolderID
2: Folder not found
3: Permission denied (folder does not belong to user)Retrieve Media File Details ​
POST/api.phpDEPRECATION WARNING
This endpoint is deprecated and will be removed in a future Octeth release. There are no alternative or replacement API endpoints available.
API Usage Notes
- Authentication required: User API Key
- Required permissions:
Media.Retrieve - Legacy endpoint access via
/api.phponly (no v1 REST alias configured)
Retrieve details of a specific media file from the media library. MediaURL (v6.0.8, #4112) is the absolute public address to use in emails.
Request Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Command | String | Yes | API command: media.retrieve |
| SessionID | String | No | Session ID obtained from login |
| APIKey | String | No | API key for authentication |
| MediaID | Integer | Yes | ID of the media file to retrieve |
curl -X POST https://example.com/api.php \
-H "Content-Type: application/json" \
-d '{
"Command": "media.retrieve",
"SessionID": "your-session-id",
"MediaID": 456
}'{
"Success": true,
"ErrorCode": 0,
"Name": "image.jpg",
"Type": "image/jpeg",
"Size": 102400,
"URL": "/public/file/view/rt/th",
"MediaURL": "https://example.com/m/rt/th"
}{
"Success": false,
"ErrorCode": [1]
}0: Success
1: Missing required parameter: MediaID
2: Media file not foundUpload Media File ​
POST/api/v1/media.uploadDEPRECATION WARNING
This endpoint is deprecated and will be removed in a future Octeth release. There are no alternative or replacement API endpoints available.
API Usage Notes
- Authentication required: User API Key. Admin authentication is also accepted with
Access=adminandUserID(see Admin usage below) - Required permissions:
Media.Upload - v1 REST alias:
POST /api/v1/media.upload. Legacy access via/api.phpis also supported
Upload a new media file to the media library. MediaURL in the response is the absolute public address to use in emails (v6.0.8, #4112).
Admin usage (v5.9.6, #2775)
This command also accepts admin authentication. Pass AdminAPIKey (or an admin SessionID), Access=admin, and UserID naming the account to act on; the response is exactly what that account's own API key would receive. The uploaded file is stored under that account (RelOwnerUserID). Without Access=admin the call is treated as a user call, so existing integrations are unaffected. UserID is ignored under user authentication. Admin-only error codes: 5001 UserID missing or invalid, 5002 user not found, 5003 user outside the user groups a restricted sub-admin may access. Requires the User.Edit privilege when ADMIN_API_ENFORCE_PRIVILEGES is on.
Request Body Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Command | String | Yes | API command: media.upload |
| UserID | Integer | Admin only | Account to act on when calling with admin authentication and Access=admin. Ignored under user authentication (v5.9.6, #2775) |
| SessionID | String | No | Session ID obtained from login |
| APIKey | String | No | API key for authentication |
| MediaData | String | Yes | Base64-encoded file data |
| MediaType | String | Yes | MIME type of the file (e.g., "image/jpeg") |
| MediaSize | Integer | Yes | File size in bytes |
| MediaName | String | Yes | File name |
| FolderID | Integer | No | Folder to store the file in, one of the account's own. Omit or send 0 for the top level (v6.0.8, #4112) |
| EnforceMediaRules | Boolean | No | true applies the install's media library rules: the on/off switch and the allowed file types, judged on the file's bytes instead of MediaType. The detected type is stored. Default false, which keeps the size limit as the only check (v6.0.8, #4112) |
curl -X POST https://example.com/api.php \
-H "Content-Type: application/json" \
-d '{
"Command": "media.upload",
"SessionID": "your-session-id",
"MediaData": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"MediaType": "image/png",
"MediaSize": 68,
"MediaName": "sample.png"
}'{
"Success": true,
"ErrorCode": 0,
"MediaID": 456,
"MediaURL": "https://example.com/m/rt/th"
}{
"Success": false,
"ErrorCode": [1, 2, 3, 5]
}0: Success
1: Missing required parameter: MediaData
2: Missing required parameter: MediaType
3: Missing required parameter: MediaSize
4: File size exceeds maximum allowed limit
5: Missing required parameter: MediaName
6: The media library is turned off (only with EnforceMediaRules, v6.0.8)
7: This file type is not allowed (only with EnforceMediaRules, v6.0.8)
8: Folder not found (v6.0.8)
9: The file could not be stored. Nothing is kept (v6.0.8)
10: MediaData is not a base64 encoded file (only with EnforceMediaRules, v6.0.8)
