POST
/
v1
/
file-upload
File Upload
curl --request POST \
  --url https://api.eka.care/v1/file-upload \
  --header 'Authorization: Bearer <token>'
{
  "uploadData": {
    "url": "https://m-prod-ekascribe-batch.s3.amazonaws.com/",
    "fields": {
      "x-amz-meta-mode": "dictation",
      "key": "EC_173210496011417/txn_301/20250617_105524/${filename}",
      "x-amz-algorithm": "AWS4-HMAC-SHA256",
      "x-amz-credential": "ASIAYES5P2B2ZIB4II4R/20250617/ap-south-1/s3/aws4_request",
      "x-amz-date": "20250617T105524Z",
      "x-amz-security-token": "<string>",
      "policy": "<string>",
      "x-amz-signature": "<string>"
    }
  },
  "folderPath": "EC_173210496011417/txn_301/20250617_105524/",
  "txn_id": "txn_301"
}

Parameters

ParameterTypeRequiredDescription
txn_idstringYesSession ID for file upload
actionstringNoUpload action: ekascribe-v2

Response

{
    "uploadData": {
        "url": "https://m-prod-ekascribe-batch.s3.amazonaws.com/",
        "fields": {
            "x-amz-meta-mode": "dictation",
            "x-amz-meta-uhid": "unique_patient_id",
            "x-amz-meta-hfid": "unique_health_facility_id",
            "key": "EC_173210496011417/txn_301/20250617_105524/${filename}",
            "x-amz-algorithm": "AWS4-HMAC-SHA256",
            "x-amz-credential": "...",
            "x-amz-date": "...",
            "policy": "...",
            "x-amz-signature": "..."
        }
    },
    "folderPath": "EC_173210496011417/txn_301/20250617_105524/",
    "txn_id": "txn_301"
}

2. Upload Audio Files

import requests
import os
from io import BytesIO
import json

def upload_file(upload_data, folder_path, file_path):
    """Upload a single audio file"""
    file_name = os.path.basename(file_path)
    upload_data['fields']['key'] = folder_path + file_name
    
    with open(file_path, 'rb') as file:
        files = {'file': (file_name, file)}
        response = requests.post(upload_data['url'], data=upload_data['fields'], files=files)
    
    if response.status_code == 204:
        return {'key': folder_path + file_name, 'size': os.path.getsize(file_path)}
    else:
        raise Exception(f"Upload failed: {response.status_code}")

Complete Upload Workflow

# Collect all audio files in a list
audio_files = [
    "/path/to/consultation_audio.wav",
    "/path/to/follow_up_audio.wav"
]

# Same as the one used in presigned url
transaction_id = "unique_transaction_id_123"


action = "ekascribe-v2"

# Step 1: Get presigned URL
upload_response = get_presigned_url(txn_id=transaction_id, action=action)

# Step 2: Upload audio files
upload_results = []
for audio_file in audio_files:
    result = upload_file(
        upload_response['uploadData'].copy(),  # Use copy to avoid modifying original
        upload_response['folderPath'],
        audio_file
    )
    upload_results.append(result)
    print(f"Uploaded: {result['key']}")


# Process responses
for response in upload_results:
    # Handle response data as needed
    print(f"File: {response['key']}, Size: {response['size']} bytes")

HTTP Status Codes

CodeDescription
200Presigned URL generated successfully
204File uploaded successfully
403Upload failed (expired policy)

Key Notes

  • Same Presigned URL: Both audio files and JSON use the same presigned URL from the API
  • JSON Filename: Auto-generated as {txn_id}.json in the same folder as audio files
  • Upload Location: All files (audio + JSON) go to the same S3 folder path
  • File Paths: Only filenames are stored in JSON, not full paths
  • Metadata: Request body data becomes S3 metadata with x-amz-meta- prefix

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

txn_id
string
required

Session ID for file upload

Example:

"txn_301"

action
enum<string>
default:ekascribe-v2

Upload action type

Available options:
ekascribe-v2
Example:

"ekascribe-v2"

Response

200
application/json

Presigned URL generated successfully

The response is of type object.