Error Handling 
This guide explains how to handle errors and common issues with the ParseMyFile API.
HTTP Error Codes 
200 - Success 
The request was processed successfully.
{
  "execution_time": "2.4"
  "status": "success",
  "data": {
    /* ... */
  }
}For each error code, there is an associated message in the response
{
  "detail": "Message that details the error",
}400 - Bad Request 
The request contains invalid data.
401 - Unauthorized 
The API key is missing or invalid.
402 - Payment Required 
Insufficient credits or expired subscription
422 - Validation Error 
The request parameters do not meet the expected schema.
500 - Internal Server Error 
An error occurred on the server side.
Error Handling in Code 
JavaScript/TypeScript 
async function processDocument(file, yamlFile, apiKey) {
  try {
    const formData = new FormData();
    formData.append('file', file);
    formData.append('yaml_file', yamlFile);
    const response = await fetch('/api/v1/generate', {
      method: 'POST',
      headers: {
        'X-API-KEY': apiKey
      },
      body: formData
    });
    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`Error ${response.status}: ${errorData.message || response.statusText}`);
    }
    const result = await response.json();
    return result;
  } catch (error) {
    console.error('Error during processing:', error.message);
    throw error;
  }
}Python 
import requests
from requests.exceptions import RequestException
def process_document(file_path, yaml_path, api_key):
    try:
        url = "https://api.parsemyfile.com/api/v1/generate"
        headers = {"X-API-KEY": api_key}
        
        files = {
            'file': ('document.pdf', open(file_path, 'rb'), 'application/pdf'),
            'yaml_file': ('config.yaml', open(yaml_path, 'rb'), 'text/yaml')
        }
        
        response = requests.post(url, headers=headers, files=files)
        
        if response.status_code == 200:
            return response.json()
        else:
            error_data = response.json()
            raise Exception(f"Error {response.status_code}: {error_data.get('message', 'Unknown error')}")
            
    except RequestException as e:
        print(f"Request error: {e}")
        raise
    except Exception as e:
        print(f"Processing error: {e}")
        raise
    finally:
        # Close files
        if 'files' in locals():
            for file_obj in files.values():
                if hasattr(file_obj[1], 'close'):
                    file_obj[1].close()Common Problems and Solutions 
Problem: 401 Unauthorized Error 
Cause: Missing or invalid API key.
Solutions:
- Check that the 
X-API-KEYheader is present - Verify that the API key is correct
 - Log in to the website to get a new key
 
# Check your API key
echo "Your API key: $API_KEY"Problem: 402 Validation Error 
Cause: Missing or invalid parameters.
Solutions:
- Check that both files are provided
 - Verify file formats
 - Check file sizes (max 10 MB)
 
# Check files
ls -la document.pdf configuration.yamlProblem: Low Quality Extraction 
Cause: Poor document quality or inadequate configuration.
Solutions:
- Improve source document quality
 - Adjust confidence threshold in YAML
 - Enable appropriate preprocessing
 
Problem: 402 File Too Large 
Cause: The file exceeds the limit allowed by your subscription.
Solutions:
- Compress the file
 - Split the document into multiple pages
 - Reduce image resolution
 
Problem: 402 Unsupported File Format 
Cause: The file format is not supported or your subscription doesn't allow this file type.
Supported formats:
- JPG, JPEG
 - PNG
 - DOCX
 - XLSX
 
Solutions:
- Convert the file to a supported format
 - Use an online conversion tool
 - Check the file extension
 
Support and Troubleshooting 
If you encounter persistent problems:
- Check the logs of your application
 - Verify the YAML configuration
 - Test with simple files first
 - Contact technical support with: 
- Complete error message
 - File type used
 - YAML configuration
 - Application logs