Skip to main content

Method-Specific Route Configuration

Configure different headers, body templates, and security settings for each HTTP method on a single route.

What are Method Configs?

Method configs let you customize route behavior per HTTP method. For example:
  • GET requests: Inject read-only API key
  • POST requests: Inject write API key + additional auth
  • DELETE requests: Require admin API key + signature
All on the same route with same URL!

Why Use Method Configs?

Use Case 1: Different API Keys Per Method

Your API uses different keys for read vs write operations:

Use Case 2: Method-Specific Headers

Use Case 3: Different Secrets Per Method

Use Case 4: Security Levels

How It Works

Fallback System

Example:
Result:
  • GET requests → Uses read_key (global)
  • POST requests → Uses write_key (method config)
  • PUT requests → Uses read_key (global, no method config)

Create Method Config

Step 1: Edit Your Route

  1. Navigate to Routes
  2. Click your route
  3. Click Edit

Step 2: Scroll to Method Configs

Find the Method-Specific Configuration section

Step 3: Add Method Config

Click Add Method Config Select HTTP Method:
Inject Headers:
Inject Body:
Override other settings (optional):
  • Rate limit
  • Require signature
  • Allowed origins

Step 4: Save

Click Save Changes Now POST requests use different configuration!

Example: Read vs Write Keys

Scenario

You have a REST API with:
  • Read operations: GET (low risk)
  • Write operations: POST, PUT, DELETE (high risk)
You want different API keys for each.

Setup

Create secrets:
  1. api_read_key → sk_read_abc123
  2. api_write_key → sk_write_xyz789
Route global config:
Default: Use read-only key POST method config:
PUT method config:
DELETE method config:

Result

Example: Idempotency for POST

Scenario

Your API requires idempotency keys for POST requests to prevent duplicate processing.

Setup

POST method config only:

Usage

Client includes idempotency key in query param:
KnoxCall extracts idempotency_key from query and injects as header:
Backend receives idempotency key in header (standard pattern).

Example: Signature Only for Mutations

Scenario

You want to require HMAC signatures for POST/PUT/DELETE but not GET (performance).

Setup

Global route config:
POST method config:
PUT method config:
DELETE method config:

Result

Advanced: Method-Specific Rate Limits

Scenario

Allow many GET requests (reads) but limit POST requests (writes).

Setup

Global route:
1000 requests per minute for GET POST method config:
Only 100 POST requests per minute

Result

  • GET: 1000/min allowed
  • POST: 100/min allowed
  • Other methods: 1000/min (global)

Variables Available in Templates

Query Parameters: {{var:param_name}}

Secrets: {{secret:name}}

Environment Variables

Can reference in templates for dynamic values.

Viewing Method Configs

In Route Details

  1. Navigate to Routes
  2. Click your route
  3. See Method Configs section
  4. Shows all configured methods with icons:
    • 🟢 GET
    • 🔵 POST
    • 🟡 PUT
    • 🔴 DELETE
    • ⚫ PATCH
    • 🟣 OPTIONS
    • ⚪ HEAD

In Logs

Request logs show which config was used:
Or:

Best Practices

1. Use Global as Default

Configure global headers/body for the most common case (usually GET). Method configs only for exceptions.

2. Principle of Least Privilege

Give each method minimum necessary permissions.

3. Document Your Method Configs

Use route description to note:
Helps team understand configuration.

4. Test Each Method

Don’t assume method configs work without testing:
Verify correct headers/body injected for each.

5. Monitor Per-Method Metrics

In Analytics, filter by HTTP method:
  • GET success rate
  • POST latency
  • DELETE error rate
Identify method-specific issues.

Common Patterns

REST API Standard

Webhook Receiver

File Upload API

Troubleshooting

Method Config Not Applied

Symptoms: Request uses global config instead of method config Check:
  1. Method name matches the request method (matching is case-insensitive — both the config method and request method are upper-cased before comparison, so POST, post, and Post all match)
  2. Method config is saved
  3. Route is enabled
  4. Check logs to see which config was used

Wrong Headers Injected

Debug:
  1. Check request logs
  2. See “Config Used” field
  3. Verify method config has correct headers
  4. Check for typos in secret names

Variables Not Replaced

Symptoms: Backend receives literal {{var:param}} Causes:
  • Query parameter name doesn’t match
  • Typo in template: {{var:paramter}} instead of {{var:parameter}}
  • Query parameter not provided in request
Fix:
  1. Check query parameter name in request
  2. Match exactly in template
  3. Verify in logs
  • Global Route Config: Default configuration used when no method override
  • Secrets: Encrypted credentials injected via {{secret:name}}
  • Variables: Query parameters accessible via {{var:name}}
  • Rate Limiting: Can be different per method
  • Request Signing: Can be required only for certain methods

Next Steps

Secret Injection

Use secrets in method configs

Rate Limiting

Different limits per method

Request Signing

Require signatures for mutations

Testing Routes

Test each method configuration

📊 Statistics

  • Level: intermediate
  • Time: 10 minutes

🏷️ Tags

routing, configuration, http-methods, rest-api