Media Files API
This document provides details on how to retrieve and work with media files from form submissions.
Base URL
Section titled “Base URL”https://api.compitcom.inGet Media
Section titled “Get Media”Retrieve media/image file details by ID.
Endpoint
Section titled “Endpoint”GET /api/public/media/{workspaceId}/{mediaId}Description
Section titled “Description”Fetches metadata and URL for a specific media file. Call this endpoint when you have media IDs from form submissions.
Path Parameters
Section titled “Path Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string | Yes | The unique identifier of the workspace |
mediaId | string | Yes | The unique identifier of the media file |
Request Example
Section titled “Request Example”curl -X GET https://api.compitcom.in/api/public/media/workspace_123/media_456 \Response Schema
Section titled “Response Schema”Success Response (200 OK)
Section titled “Success Response (200 OK)”{ "id": "media_456", "name": "profile_photo.png", "mimeType": "image/png", "url": "https://cdn.compitcom.in/media/media_456"}Response Field Descriptions
Section titled “Response Field Descriptions”| Field | Type | Description |
|---|---|---|
id | string | Unique media identifier |
name | string | Original filename |
mimeType | string | MIME type (e.g., “image/png”, “application/pdf”) |
url | string | Direct URL to access the media file |
Error Response (404 Not Found)
Section titled “Error Response (404 Not Found)”{ "error": "Media not found"}Understanding Media Fields
Section titled “Understanding Media Fields”Media Fields in Form Submissions
Section titled “Media Fields in Form Submissions”Media/image fields in form submissions are stored as IDs:
{ "data": { "attachments": ["media_456", "media_789"] }}To retrieve the actual files, make separate GET requests to the Media endpoint for each ID:
GET /api/public/media/{workspaceId}/media_456GET /api/public/media/{workspaceId}/media_789Complete Example
Section titled “Complete Example”Here’s a complete workflow for retrieving form submissions and their media files:
# Step 1: Get form submissions with media IDscurl -X POST https://api.compitcom.in/api/public/forms/workspace_123/employees/submissions \ -H "Content-Type: application/json" \ -d '{ "page": 1, "pageSize": 10 }'
# Response includes media IDs# {# "data": [{# "id": "sub_123456",# "data": {# "employee_name": "Alice",# "profile_image": ["media_456"]# }# }]# }
# Step 2: Get media using the ID from step 1curl -X GET https://api.compitcom.in/api/public/media/workspace_123/media_456 \
# Response# {# "id": "media_456",# "name": "profile_photo.png",# "mimeType": "image/png",# "url": "https://cdn.compitcom.in/media/media_456"# }