File Converters

File converters accept an uploaded file via multipart/form-data and return the converted output. This page covers all data format converters and document-to-PDF converters that use file upload.


Available Endpoints

Data Format Converters:

  • POST /v1/convert/json-to-xml
  • POST /v1/convert/xml-to-json
  • POST /v1/convert/json-to-yaml
  • POST /v1/convert/yaml-to-json
  • POST /v1/convert/csv-to-json
  • POST /v1/convert/json-to-csv
  • POST /v1/convert/markdown-to-html

Document to PDF Converters:

  • POST /v1/convert/html-to-pdf
  • POST /v1/convert/markdown-to-pdf
  • POST /v1/convert/docx-to-pdf -- Coming Soon
  • POST /v1/convert/xlsx-to-pdf -- Coming Soon
Coming Soon: docx-to-pdf and xlsx-to-pdf currently return 503 Service Unavailable. These endpoints are under active development.

Request Format

All file converter endpoints use multipart/form-data for the request body.

Parameters

Parameter Type Required Description
file file Yes The file to convert. Must match the expected input format for the endpoint.
output_filename string No Custom filename for the converted output. If omitted, the API generates a filename based on the input file.

Example Request

The following example converts a CSV file to JSON:

curl -X POST https://api.enconvert.com/v1/convert/csv-to-json \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@data.csv" \
  -F "output_filename=data.json"

Response Formats

The response format depends on the type of API key used to authenticate the request.

Response with Private API Key

When authenticated with a private API key, the API returns a JSON response containing a presigned URL for downloading the converted file and the storage object key.

HTTP 200 OK

{
  "success": true,
  "message": "Conversion successful",
  "presigned_url": "https://storage.enconvert.com/live/files/abc123/csv-to-json/data.json?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...",
  "object_key": "live/files/abc123/csv-to-json/data.json",
  "filename": "data.json",
  "file_size": 2048,
  "conversion_time": 0.342
}
Field Type Description
success boolean Whether the conversion succeeded.
message string Human-readable status message.
presigned_url string A temporary, downloadable URL for the converted file.
object_key string The storage path of the converted file (e.g., live/files/{key_id}/{conversion_type}/...).
filename string The name of the converted file.
file_size integer Size of the converted file in bytes.
conversion_time float Time taken for the conversion in seconds.

Response with Public API Key or JWT

When authenticated with a public API key or a JWT token, the API returns the converted file directly as a binary download.

HTTP 200 OK

The response body contains the raw file content with the appropriate Content-Type header.

Response Headers

Header Description Example
Content-Disposition Indicates the filename for the downloaded file. attachment; filename="data.json"
Content-Type MIME type of the converted file. application/json
X-Object-Key The storage path of the converted file. live/files/abc123/csv-to-json/data.json
X-File-Size Size of the converted file in bytes. 2048
X-Conversion-Time Time taken for the conversion in seconds. 0.342
X-Filename The name of the converted file. data.json

Error Responses

Validation Error (400)

Returned when the uploaded file is missing or invalid.

{
  "success": false,
  "error": "No file provided",
  "code": "MISSING_FILE"
}

Unsupported Format (400)

Returned when the file type does not match the expected input format.

{
  "success": false,
  "error": "Invalid file format. Expected CSV file.",
  "code": "INVALID_FORMAT"
}

Not Implemented (503)

Returned by endpoints that are marked as Coming Soon.

{
  "success": false,
  "error": "This conversion type is not yet available",
  "code": "NOT_IMPLEMENTED"
}