Skip to content

Integrating Other Data Sources

This guide explains how to integrate external data sources with our platform using the File Upload API. You can create API keys and build simple integration applications to regularly send data via our secure endpoint.

Overview

Our File Upload API allows you to programmatically upload CSV files that can be analyzed by our AI-powered platform. This is perfect for:

  • Scheduled data imports from external systems
  • Automated reporting from business intelligence tools
  • Data synchronization from various data sources
  • Custom integrations with your existing workflows

Quick Start

We've created a Postman collection to help you get up and running quickly. The collection itself has the authentication settings defined. The sample request demonstrates uploading a file. Use the button below to fork the collection and try it yourself.

Run In Postman

Creating an API Key

Step 1: Access the Settings

  1. Log into your account
  2. Navigate to SettingsAPI Keys
  3. Click "Create New API Key"

Step 2: Configure the API Key

  • User: Select the user account that will own this API key
  • Name: Give your API key a descriptive name (e.g., "Production Integration", "Scheduled Reports")
  • Click "Create API Key"

Step 3: Save Your API Key

⚠️ Important: The API key will only be displayed once. Copy and store it securely.

API keys follow the format: rk_ followed by a 64-character hexadecimal string.

API Endpoint

File Upload Endpoint

URL: POST /api/files/upload
Authentication: Bearer Token (API Key)
Content-Type: multipart/form-data

Headers

Header Value Required
Authorization Bearer rk_your_api_key_here
Content-Type multipart/form-data ✅ (some frameworks set this automatically)

Request Body (Form Data)

Field Type Required Description
file File CSV file to upload (max 20MB)
name Text Display name for the file
audience Text "user" or "company" (defaults to "user")

Response

Success Response (201 Created)

{
  "success": true,
  "file": {
    "id": "file_id_here",
    "displayName": "My Data Export",
    "originalFileName": "export.csv",
    "fileSize": 12345,
    "mimeType": "text/csv",
    "audience": "user",
    "expiresAt": "2024-01-15T10:30:00.000Z",
    "created": "2024-01-08T10:30:00.000Z"
  }
}

Error Responses

Status Error Description
400 No file provided Missing file in request
400 File name is required Missing name parameter
400 Invalid file type. Only CSV files are allowed. Non-CSV file uploaded
401 API key required in Authorization header Missing or invalid API key
401 Invalid API key API key not found or inactive
413 File size exceeds 20MB limit File too large
500 Internal server error Server error

File Requirements

Supported Formats

  • CSV files only (.csv)
  • MIME types: text/csv, application/csv, application/vnd.ms-excel

File Limits

  • Maximum size: 20MB
  • Expiration: Files expire after 7 days
  • Character encoding: UTF-8 recommended

CSV Format Recommendations

  • Headers: Include descriptive column headers
  • Data types: Use consistent data types within columns
  • Missing values: Use empty cells or consistent placeholder values
  • Special characters: Avoid special characters in headers

Integration Examples

cURL Example

curl -X POST "https://rightinsight.ai/api/files/upload" \
  -H "Authorization: Bearer rk_your_api_key_here" \
  -F "file=@/path/to/your/data.csv" \
  -F "name=Monthly Sales Report" \
  -F "audience=company"

Python Example

import requests

def upload_file(api_key, file_path, display_name, audience="user"):
    url = "https://rightinsight.ai/api/files/upload"
    headers = {"Authorization": f"Bearer {api_key}"}

    with open(file_path, 'rb') as file:
        files = {'file': file}
        data = {
            'name': display_name,
            'audience': audience
        }

        response = requests.post(url, headers=headers, files=files, data=data)
        return response.json()

# Usage
result = upload_file(
    api_key="rk_your_api_key_here",
    file_path="data.csv",
    display_name="Weekly Report",
    audience="company"
)
print(result)

Node.js Example

const FormData = require('form-data');
const fs = require('fs');
const axios = require('axios');

async function uploadFile(apiKey, filePath, displayName, audience = 'user') {
  const form = new FormData();
  form.append('file', fs.createReadStream(filePath));
  form.append('name', displayName);
  form.append('audience', audience);

  try {
    const response = await axios.post('https://rightinsight.ai/api/files/upload', form, {
      headers: {
        'Authorization': `Bearer ${apiKey}`,
        ...form.getHeaders()
      }
    });
    return response.data;
  } catch (error) {
    console.error('Upload failed:', error.response?.data || error.message);
    throw error;
  }
}

// Usage
uploadFile('rk_your_api_key_here', './data.csv', 'Daily Export', 'company')
  .then(result => console.log('Upload successful:', result))
  .catch(error => console.error('Upload failed:', error));

Best Practices

Security

  • Store API keys securely - Never commit them to version control
  • Use environment variables for API keys in production
  • Rotate API keys regularly for enhanced security
  • Monitor API key usage through the settings dashboard

File Management

  • Use descriptive names for uploaded files
  • Include timestamps in file names for tracking
  • Validate CSV format before uploading

Error Handling

  • Implement retry logic for transient failures
  • Log all upload attempts for debugging
  • Handle rate limiting gracefully
  • Validate file size before upload

Integration Patterns

  • Scheduled uploads: Use cron jobs or task schedulers
  • Event-driven uploads: Trigger uploads based on data changes
  • Batch processing: Upload multiple files in sequence
  • Monitoring: Set up alerts for failed uploads

Troubleshooting

Common Issues

"Invalid API key" - Verify the API key is correct and active - Check that the Authorization header includes Bearer prefix - Ensure the API key hasn't been revoked

"File size exceeds 20MB limit" - Remove unnecessary columns or rows - Remove data that's not essential for your analysis

"Invalid file type" - Ensure the file is a valid CSV format - Check the file extension is .csv - Verify the MIME type is correct

"No file provided" - Ensure the file field is included in the form data - Check that the file is being read correctly - Verify the multipart form data is properly formatted

Getting Help

If you encounter issues not covered in this guide:

  1. Check the API response for detailed error messages
  2. Verify your integration using the Postman collection
  3. Contact support with specific error details and request logs
  4. Review the API logs for server-side issues

Rate Limits

  • File uploads: No specific rate limits currently enforced
  • API key usage: Monitored for security purposes
  • File storage: 7-day expiration for all uploaded files

Support

For technical support or questions about the File Upload API:

  • Documentation: This guide and the Postman collection
  • API Testing: Use the provided Postman collection for testing
  • Error Logs: Check your application logs for detailed error information
  • Contact: Reach out to our support team with specific error details