RedirectFlow API

Programmatically manage redirects, import/export data, and integrate with your applications

REST API
Standard HTTP methods
JSON
Request/response format
Rate Limited
Based on your plan

API Access Required

API access is available on Pro, Business, and Enterprise plans. Webhook functionality requires Business plan or higher.

View pricing

Authentication

The RedirectFlow API uses API keys for authentication. Include your API key in the Authorization header of every request.

Creating an API Key

  1. 1. Navigate to your Dashboard → API tab
  2. 2. Click "Create API Key"
  3. 3. Choose permissions: Import, Export, Analytics
  4. 4. Copy and securely store your API key

Request Headers

HTTP
Authorization: Bearer rf_your_api_key_here
Content-Type: application/json
User-Agent: YourApp/1.0

Security Best Practices

  • • Never expose API keys in client-side code
  • • Store keys securely in environment variables
  • • Rotate keys regularly and revoke unused keys
  • • Use least-privilege permissions

Rate Limits

Rate limits are enforced per user account and vary by subscription plan. Limits reset every minute.

Pro Plan

100
requests per minute

Business Plan

1,000
requests per minute

Enterprise Plan

5,000
requests per minute

Rate Limit Headers

HTTP
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640995200

HTTP/1.1 429 Too Many Requests
{
  "error": "Rate limit exceeded",
  "limit": 1000,
  "reset": 1640995200
}

Bulk Import/Export

Bulk Import Redirects

Import up to 1,000,000 redirects in a single API call (Enterprise plan). Data is processed in batches for optimal performance.

Request

HTTP
POST https://redirectflow.com/api/v1/redirects/bulk
Authorization: Bearer rf_your_api_key_here
Content-Type: application/json

{
  "website_id": "123",
  "redirects": [
    {
      "old_path": "/old-page",
      "new_path": "/new-page",
      "status_code": 301
    },
    {
      "old_path": "/another-old-page",
      "new_path": "/another-new-page",
      "status_code": 302
    }
  ],
  "group_id": "migration-2024",
  "target_environments": ["production", "staging"]
}

Response

JSON
{
  "success": true,
  "import_id": "imp_1234567890",
  "summary": {
    "total_submitted": 2,
    "created": 2,
    "updated": 0,
    "errors": 0
  },
  "processing_time": "1.2s",
  "batch_info": {
    "batch_size": 1000,
    "total_batches": 1
  }
}

Import Limits by Plan

  • Pro: 10,000 redirects per import
  • Business: 100,000 redirects per import
  • Enterprise: 1,000,000 redirects per import

Bulk Export Redirects

Export all redirects for a website or specific groups. Supports various formats and filtering options.

Request

HTTP
GET https://redirectflow.com/api/v1/redirects/bulk/export?website_id=123&format=json&group_id=migration-2024
Authorization: Bearer rf_your_api_key_here

Response

JSON
{
  "export_id": "exp_1234567890",
  "website": {
    "id": "123",
    "name": "My Website"
  },
  "filters": {
    "group_id": "migration-2024"
  },
  "redirects": [
    {
      "id": "456",
      "old_path": "/old-page",
      "new_path": "/new-page",
      "status_code": 301,
      "group_id": "migration-2024",
      "created_at": "2024-01-15T10:30:00Z",
      "deployed_to_prod": "2024-01-15T11:00:00Z"
    }
  ],
  "total_count": 1,
  "exported_at": "2024-01-16T14:30:00Z"
}

Analytics API

Access read-only analytics data for your redirects. Get insights into deployment stats, redirect performance, and usage patterns.

Website Analytics

HTTP
GET https://redirectflow.com/api/v1/analytics?website_id=123&start_date=2024-01-01&end_date=2024-01-31&group_by=day
Authorization: Bearer rf_your_api_key_here

Response

JSON
{
  "website": {
    "id": "123",
    "name": "My Website"
  },
  "date_range": {
    "start_date": "2024-01-01",
    "end_date": "2024-01-31"
  },
  "analytics": {
    "overview": {
      "total_redirects": 1500,
      "deployed_redirects": 1450,
      "total_groups": 12
    },
    "time_series": [
      {
        "period": "2024-01-01",
        "redirect_count": 50,
        "deployed_count": 48
      }
    ],
    "top_groups": [
      {
        "group_id": "migration-2024",
        "redirect_count": 500,
        "deployed_count": 495
      }
    ],
    "environments": {
      "production_deployed": 1450,
      "staging_deployed": 1500,
      "development_deployed": 1200
    }
  }
}

Analytics Query Limits

  • Pro: 30 day maximum date range
  • Business: 90 day maximum date range
  • Enterprise: 365 day maximum date range

Webhooks

Webhooks allow you to receive real-time notifications when events occur in your RedirectFlow account. Available on Business and Enterprise plans.

Creating a Webhook

HTTP
POST https://redirectflow.com/api/webhooks
Authorization: Bearer rf_your_api_key_here
Content-Type: application/json

{
  "name": "Deployment Notifications",
  "url": "https://your-app.com/webhooks/redirectflow",
  "events": [
    "deployment.completed",
    "deployment.failed",
    "bulk_import.completed"
  ]
}

Response

JSON
{
  "webhook": {
    "id": "wh_1234567890",
    "name": "Deployment Notifications",
    "url": "https://your-app.com/webhooks/redirectflow",
    "events": ["deployment.completed", "deployment.failed", "bulk_import.completed"],
    "secret": "whsec_abc123def456...",
    "is_active": true,
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Webhook Events

redirect.created

New redirect added

redirect.updated

Redirect modified

redirect.deleted

Redirect removed

deployment.started

Deployment initiated

deployment.completed

Deployment finished successfully

deployment.failed

Deployment encountered errors

bulk_import.completed

Bulk import process finished

bulk_export.completed

Bulk export process finished

Webhook Payload

JSON
{
  "event": "deployment.completed",
  "timestamp": "2024-01-15T11:00:00Z",
  "data": {
    "deployment": {
      "website_id": "123",
      "environment": "production",
      "redirect_count": 150,
      "deployed_at": "2024-01-15T11:00:00Z"
    }
  }
}

Signature Verification

Verify webhook authenticity using the signature in the X-RedirectFlow-Signature header.

JavaScript
const crypto = require('crypto');

function verifyWebhookSignature(payload, signature, secret) {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  
  const receivedSignature = signature.replace('sha256=', '');
  
  return crypto.timingSafeEqual(
    Buffer.from(expectedSignature, 'hex'),
    Buffer.from(receivedSignature, 'hex')
  );
}

// Express.js example
app.post('/webhooks/redirectflow', (req, res) => {
  const signature = req.headers['x-redirectflow-signature'];
  const payload = JSON.stringify(req.body);
  
  if (!verifyWebhookSignature(payload, signature, process.env.WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature');
  }
  
  // Process webhook event
  const { event, data } = req.body;
  console.log('Received webhook:', event, data);
  
  res.status(200).send('OK');
});

Error Handling

The RedirectFlow API uses conventional HTTP response codes to indicate success or failure of requests.

HTTP Status Codes

200Success
Request completed successfully
201Created
Resource created successfully
400Bad Request
Invalid request parameters
401Unauthorized
Invalid or missing API key
403Forbidden
Insufficient permissions
404Not Found
Resource not found
429Rate Limited
Too many requests
500Server Error
Internal server error

Error Response Format

JSON
{
  "error": "Invalid request parameters",
  "details": "website_id is required",
  "code": "MISSING_PARAMETER",
  "timestamp": "2024-01-15T10:30:00Z"
}

Code Examples

JavaScript/Node.js

JavaScript
const fetch = require('node-fetch');

class RedirectFlowClient {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.baseUrl = 'https://redirectflow.com/api/v1';
  }

  async bulkImport(websiteId, redirects, groupId = null) {
    const response = await fetch(`${this.baseUrl}/redirects/bulk`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.apiKey}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        website_id: websiteId,
        redirects,
        group_id: groupId
      })
    });

    if (!response.ok) {
      const error = await response.json();
      throw new Error(`API Error: ${error.error}`);
    }

    return await response.json();
  }

  async getAnalytics(websiteId, startDate, endDate) {
    const params = new URLSearchParams({
      website_id: websiteId,
      start_date: startDate,
      end_date: endDate
    });

    const response = await fetch(`${this.baseUrl}/analytics?${params}`, {
      headers: {
        'Authorization': `Bearer ${this.apiKey}`
      }
    });

    return await response.json();
  }
}

// Usage
const client = new RedirectFlowClient('rf_your_api_key_here');

async function example() {
  try {
    // Import redirects
    const result = await client.bulkImport('123', [
      { old_path: '/old', new_path: '/new', status_code: 301 }
    ], 'migration-2024');
    
    console.log('Import successful:', result);

    // Get analytics
    const analytics = await client.getAnalytics('123', '2024-01-01', '2024-01-31');
    console.log('Analytics:', analytics);

  } catch (error) {
    console.error('Error:', error.message);
  }
}

example();

Python

Python
import requests
import json
from datetime import datetime

class RedirectFlowClient:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = 'https://redirectflow.com/api/v1'
        self.session = requests.Session()
        self.session.headers.update({
            'Authorization': f'Bearer {api_key}',
            'Content-Type': 'application/json'
        })

    def bulk_import(self, website_id, redirects, group_id=None):
        payload = {
            'website_id': website_id,
            'redirects': redirects,
            'group_id': group_id
        }
        
        response = self.session.post(
            f'{self.base_url}/redirects/bulk',
            json=payload
        )
        
        response.raise_for_status()
        return response.json()

    def get_analytics(self, website_id, start_date, end_date):
        params = {
            'website_id': website_id,
            'start_date': start_date,
            'end_date': end_date
        }
        
        response = self.session.get(
            f'{self.base_url}/analytics',
            params=params
        )
        
        response.raise_for_status()
        return response.json()

# Usage
client = RedirectFlowClient('rf_your_api_key_here')

try:
    # Import redirects
    redirects = [
        {'old_path': '/old-page', 'new_path': '/new-page', 'status_code': 301}
    ]
    result = client.bulk_import('123', redirects, 'migration-2024')
    print(f'Import successful: {result}')

    # Get analytics
    analytics = client.get_analytics('123', '2024-01-01', '2024-01-31')
    print(f'Analytics: {analytics}')

except requests.exceptions.HTTPError as e:
    print(f'HTTP Error: {e.response.status_code} - {e.response.text}')
except Exception as e:
    print(f'Error: {str(e)}')

cURL

bash
# Bulk import redirects
curl -X POST https://redirectflow.com/api/v1/redirects/bulk \
  -H "Authorization: Bearer rf_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "website_id": "123",
    "redirects": [
      {
        "old_path": "/old-page",
        "new_path": "/new-page", 
        "status_code": 301
      }
    ],
    "group_id": "migration-2024"
  }'

# Get analytics
curl -X GET "https://redirectflow.com/api/v1/analytics?website_id=123&start_date=2024-01-01&end_date=2024-01-31" \
  -H "Authorization: Bearer rf_your_api_key_here"

# Export redirects
curl -X GET "https://redirectflow.com/api/v1/redirects/bulk/export?website_id=123&format=json" \
  -H "Authorization: Bearer rf_your_api_key_here"

# Create webhook
curl -X POST https://redirectflow.com/api/webhooks \
  -H "Authorization: Bearer rf_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Deployment Notifications",
    "url": "https://your-app.com/webhooks/redirectflow",
    "events": ["deployment.completed", "bulk_import.completed"]
  }'

SDKs & Libraries

Official and community-maintained SDKs and libraries to integrate RedirectFlow into your applications.

JavaScript/TypeScript

Official Node.js SDK with TypeScript support

bash
npm install @redirectflow/sdk

Python

Official Python package for RedirectFlow API

bash
pip install redirectflow-python

PHP

Community-maintained PHP library

bash
composer require redirectflow/php-sdk

Ruby

Community-maintained Ruby gem

bash
gem install redirectflow-ruby

Coming Soon

We're working on additional SDKs for Go, Rust, and .NET. Want to contribute?Get in touch.

Need Help?

Our support team is here to help you integrate the RedirectFlow API successfully.