KnoxCall AI Integration Guide
For AI Assistants: This guide provides explicit implementation details for helping developers integrate their APIs with KnoxCall. Read this carefully to avoid common mistakes.
What is KnoxCall?
KnoxCall is an API proxy that sits between your application and external APIs. It:- Routes API calls through a central proxy
- Injects credentials/secrets automatically
- Logs all requests for monitoring
- Manages API keys across environments
Critical Architecture Facts
IMPORTANT: Understanding how KnoxCall routing works is critical to correct implementation.Route Identification
- ✅ Routes are identified by the
x-knoxcall-routeheader - ❌ Routes are NOT identified by path matching or URL patterns
- Code proof:
const routeName = req.headers['x-knoxcall-route']
Path Concatenation
- KnoxCall concatenates:
target_base_url.pathname + client_request.path - Implementation:
combinedPath = targetBase.pathname.replace(/\/$/, '') + clientPath - The client path is APPENDED as-is to the target base path
- Paths are NOT stripped, matched, or modified
What This Means
If a route’starget_base_url is https://api.example.com/v1/users, and you send a request to https://proxy.knoxcall.com/123:
- KnoxCall extracts the target base pathname:
/v1/users - KnoxCall takes your request path:
/123 - KnoxCall concatenates them:
/v1/users+/123=/v1/users/123 - Final upstream request:
https://api.example.com/v1/users/123
How KnoxCall Proxy Works (Step-by-Step)
Example: Route hastarget_base_url: https://api.example.com/integration/patients
- User sends:
GET https://proxy.knoxcall.com/123with headerx-knoxcall-route: ROUTE_ID - KnoxCall looks up route: Uses the
x-knoxcall-routeheader to find the route configuration (NOT path matching!) - KnoxCall extracts paths:
- Client path from request:
/123 - Target base path from route config:
/integration/patients
- Client path from request:
- KnoxCall builds final URL: Concatenates paths =
/integration/patients/123 - KnoxCall injects: the secret/API key from the route configuration
- KnoxCall forwards:
GET https://api.example.com/integration/patients/123with injected credentials - Returns: the response to the user
Common Mistakes to AVOID
❌ Mistake #1: Duplicating the Base Path
WRONG:❌ Mistake #2: Assuming Path Matching
KnoxCall does NOT match paths or strip base paths. It simply concatenates:target_base_url.pathname+your_request.path=final_url.pathname
❌ Mistake #3: Including API Keys in Code
After integrating with KnoxCall, the API key should be removed from your code. KnoxCall injects it automatically.The 3 Code Changes Required
When integrating an API with KnoxCall, you need to make exactly 3 changes:1. Replace the Base URL
Critical Path Calculation:- Original API call:
https://api.example.com/v1/users/123 - Route’s target_base_url:
https://api.example.com/v1/users - Step 1: Remove target_base_url from original →
/123 - Step 2: KnoxCall URL = proxy domain + what’s left →
https://proxy.knoxcall.com/123 - Step 3: Verify → KnoxCall receives
/123, forwards totarget_base_url + /123=https://api.example.com/v1/users/123✅
2. Add KnoxCall Headers
3. Remove the Old API Key/Secret
KnoxCall injects the API key automatically based on the route configuration. Remove it from:- Request headers
- Query parameters
- Request body
- Authorization headers
Complete Examples
Example 1: Python with Query Parameter Auth
Scenario: Route target_base_url ishttps://app.scrapingbee.com/api/v1/
Before:
Example 2: cURL with Header Auth
Scenario: Route target_base_url ishttps://api.stripe.com/v1/customers, calling /v1/customers/cus_123
Before:
Example 3: PHP with Complex Path
Scenario: Route target_base_url ishttps://api.endoaxis.com/integration/patients, calling patient ID 789
Before:
Path Calculation Algorithm
When helping a developer convert their API call to KnoxCall, always follow these steps:Integration Patterns
Pattern 1: Base Path Only (No Additional Path)
Pattern 2: Base Path + Resource ID
Pattern 3: Base Path + Nested Resources
Pattern 4: Base Path + Query Parameters
When to Create Routes
Create one route for each unique combination of:- API endpoint (base URL)
- Authentication method (which secret/credentials to use)
- HTTP method (GET, POST, etc.) - if different methods need different config
- ✅ One route for all Stripe customers:
/v1/customers/* - ❌ Don’t create separate routes for each customer ID
Environment Support
KnoxCall supports multiple environments (development, staging, production):Testing Your Integration
After making the 3 code changes:- Check the logs in KnoxCall dashboard to see the actual upstream request
- Verify the URL in logs matches your expected API endpoint
- Check for auth errors - if you see 401/403, the secret might not be injected correctly
- Look for path duplication - if you see
/v1/users/v1/users, you included the base path in your request
Advanced: OAuth2 Token Management
For OAuth2 APIs, KnoxCall handles token refresh automatically:Common Error Messages
”Route not found”
- Check that
x-knoxcall-routeheader contains the correct route ID - Verify the route exists in your KnoxCall dashboard
”Client not authorized”
- Check that
x-knoxcall-keyheader contains your client API key - Verify the client has access to this route
”Secret not found for environment”
- The route’s secret doesn’t have a value for the requested environment
- Add the secret value for that environment or switch environments
”404 Not Found” from upstream API
- Likely path duplication or incorrect path calculation
- Check KnoxCall logs to see the actual URL being forwarded
- Verify you’re not including the base path in your request
Best Practices for AI Assistants
When helping developers integrate with KnoxCall:- Always work through the path calculation step-by-step - don’t guess
- Show before/after code diffs - makes the changes crystal clear
- Explicitly point out the removed API key - security win!
- Use the actual route ID from the route they configured
- Verify the math - trace through what KnoxCall will forward
- Don’t invent features - KnoxCall is a proxy, nothing more
Summary
KnoxCall is ONLY a proxy. It:- Identifies routes by
x-knoxcall-routeheader - Concatenates
target_base_url.pathname + request.path - Injects secrets automatically
- Forwards the request to the upstream API
- Path matching or pattern matching
- Path stripping or modification
- SDK or library to install
- Secret fetching API
- Environment variable injection
This guide is maintained by the KnoxCall team. For questions or issues, visit https://docs.knoxcall.com