# Upload a file to the server using module configuration. Supported file types include images, audios, videos, certificates and many more Upload a file to the server using module configuration. The Module header specifies where the uploaded file will be used. Supported file types include images, audios, videos, certificates, application packages, and configuration profiles. ## Endpoints **POST** `/emsapi/files` ## Request URL `https://{serverurl}/emsapi/files` ## Request Parameters ### Request Headers - **Content-Type** (string) — Mandatory `multipart/form-data` - **Module** (string) — Mandatory `MDM_PROFILES_IMAGES` Specifies the target module where the uploaded file will be used. Allowed values: - **MDM_CERTIFICATES** — certificates (.cer, .crt, .pem, .pfx, .p12) - **MDM_APP_MGMT** — app packages (.apk, .ipa, .xap, .msix, .msixbundle, .appx, .appxbundle, .pkg) - **MDM_CUSTOM_PROFILE** — custom profiles (.xml, .mobileconfig, .plist, .json) - **MDM_CONTENT_MGMT** — content files for distribution - **MDM_PROFILES_IMAGES** — images for profile creation and modification - **MDM_APP_REPOSITORY_CUSTOM_CONFIG** — custom app config (.xml, .plist) - **Accept** (string) — Mandatory `application/json` ### Request Body **multipart/form-data** - **file** (string) — Optional Multipart form field carrying the binary file content. The form field key MUST be `file` and the value MUST be the file's binary stream (e.g., `--form 'file=@/path/to/your/file.ext'`). The actual file extension and content type must be compatible with the value supplied in the `Module` request header. Supported types per module: - **MDM_CERTIFICATES** (.cer, .crt, .pem, .pfx, .p12) - **MDM_APP_MGMT** (.apk, .ipa, .xap, .msix, .msixbundle, .appx, .appxbundle, .pkg) - **MDM_CUSTOM_PROFILE** (.xml, .mobileconfig, .plist, .json) - **MDM_PROFILES_IMAGES** (.png, .jpg, .jpeg, .gif) - **MDM_CONTENT_MGMT** (documents/media for distribution) - **MDM_APP_REPOSITORY_CUSTOM_CONFIG** (.xml, .plist) ## Sample Request ### Curl ```bash curl --request POST \ --url https://appdomain/emsapi/files \ --header 'Accept: application/json' \ --header 'Content-Type: multipart/form-data' \ --header 'Module: MDM_PROFILES_IMAGES' ``` ### Java ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; import java.net.http.HttpTimeoutException; public class Main { public static void main(String[] args) { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://appdomain/emsapi/files")) .header("Content-Type", "multipart/form-data") .header("Module", "MDM_PROFILES_IMAGES") .header("Accept", "application/json") .method("POST", HttpRequest.BodyPublishers.noBody()) .build(); HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` ### Python ```python import http.client conn = http.client.HTTPSConnection("appdomain") headers = { 'Content-Type': "multipart/form-data", 'Module': "MDM_PROFILES_IMAGES", 'Accept': "application/json" } conn.request("POST", "/emsapi/files", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ### Deluge ```javascript headersMap = Map(); headersMap.put("Content-Type", "multipart/form-data"); headersMap.put("Module", "MDM_PROFILES_IMAGES"); headersMap.put("Accept", "application/json"); list_of_text=List(); response = invokeUrl [ url: "https://appDomain/emsapi/files" type: POST headers: headersMap files: list_of_text connection: connection_name ] info response; ``` ### PowerShell ```powershell $headers=@{} $headers.Add("Content-Type", "multipart/form-data") $headers.Add("Module", "MDM_PROFILES_IMAGES") $headers.Add("Accept", "application/json") $response = Invoke-WebRequest -Uri 'https://appdomain/emsapi/files' -Method POST -Headers $headers ``` ## Response Parameters ### HTTP code 200 **Response Body — application/json** - **fileID** (string) Unique identifier assigned to the uploaded file. Use this ID in subsequent API calls (e.g., profile creation, app distribution, content management) that reference the uploaded file. Use [Get File Upload Status](https://www.manageengine.com/mobile-device-management/files-get-file-upload-status.html) to verify the file is ready for use. - **fileName** (string) Name of the uploaded file including its extension, as supplied in the multipart form field. - **customerID** (string) Identifier of the customer account that owns the uploaded file. - **expiryDate** (string) Human-readable date and time until when the uploaded file is valid. The file will be automatically deleted after this time (e.g., Jun 28, 2025 04:18 PM). - **fileStatus** (integer) Numeric status code of the file upload. Possible values: - `1` — PENDING (file is queued for processing) - `2` — COMPLETED (file successfully uploaded and ready for use) - `3` — FAILED (upload or processing failed) ## Possible HTTP Status Codes - **200** — HTTP code ## Sample Response: HTTP 200 ### Profile image (MDM_PROFILES_IMAGES) successfully uploaded via module configuration ```json { "expiryDate": "Jun 28, 2025 04:18 PM", "fileName": "wallpaper.png", "fileStatus": 2, "customerID": "9007199254741062", "fileID": "9007199254741054" } ``` ### Certificate file (MDM_CERTIFICATES) successfully uploaded ```json { "expiryDate": "Jun 28, 2025 04:18 PM", "fileName": "corp-root-ca.cer", "fileStatus": 2, "customerID": "9007199254741062", "fileID": "9007199254741055" } ``` ### Application package (MDM_APP_MGMT) successfully uploaded ```json { "expiryDate": "Jun 28, 2025 04:18 PM", "fileName": "zylker-app.apk", "fileStatus": 2, "customerID": "9007199254741062", "fileID": "9007199254741056" } ``` ### Custom configuration profile (MDM_CUSTOM_PROFILE) successfully uploaded ```json { "expiryDate": "Jun 28, 2025 04:18 PM", "fileName": "custom-config.mobileconfig", "fileStatus": 2, "customerID": "9007199254741062", "fileID": "9007199254741057" } ```