Update Lambda@Edge
curl --request POST \
--url https://searchcompany-main.up.railway.app/api/domain/update-lambda-edgeimport requests
url = "https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge")
.asString();require 'uri'
require 'net/http'
url = URI("https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body🔵 POST - Update Lambda@Edge
Update Lambda@Edge
Update the Lambda@Edge function with new bot patterns and propagate to all CloudFront distributions
POST
/
api
/
domain
/
update-lambda-edge
Update Lambda@Edge
curl --request POST \
--url https://searchcompany-main.up.railway.app/api/domain/update-lambda-edgeimport requests
url = "https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge")
.asString();require 'uri'
require 'net/http'
url = URI("https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyUpdate the Lambda@Edge function with new bot patterns and propagate to all CloudFront distributions.
When to Use
Call this endpoint when you’ve updated the bot detection patterns inlambda_code.js and want to deploy the changes to all customer domains.
Common reasons to update:
- New AI bot released (e.g., new Anthropic crawler)
- Bot User-Agent pattern changed
- Bug fix in routing logic
What This Does
- Uploads new Lambda code from
lambda_code.js - Publishes a new Lambda version (e.g.,
:1→:2) - Updates all CloudFront distributions to use the new version (parallel batches)
Timing
| Step | Duration |
|---|---|
| Lambda upload | ~5 seconds |
| Version publish | ~5 seconds |
| Distribution updates | ~1 minute per 100 distributions |
| Total for 1,000 distributions | ~15 minutes |
Customer Impact
Zero downtime. CloudFront updates are rolling:- Old Lambda version continues handling requests
- Traffic gradually shifts to new version
- No interruption to customer websites
Authentication
This endpoint requires an internal API key. Include theX-API-Key header:
X-API-Key: your-internal-api-key
Example Request
curl -X POST https://searchcompany-main.up.railway.app/api/domain/update-lambda-edge \
-H "X-API-Key: your-internal-api-key"
Example Response
{
"status": "success",
"lambda_arn": "arn:aws:lambda:us-east-1:577004485557:function:HostHeaderProxy:5",
"distributions": {
"total": 150,
"successful": 150,
"failed": 0,
"failed_details": null
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
| status | string | success or error |
| lambda_arn | string | New Lambda version ARN |
| distributions.total | number | Total distributions to update |
| distributions.successful | number | Successfully updated |
| distributions.failed | number | Failed to update |
| distributions.failed_details | array | Details of any failures |
Workflow
Step 1: Update Bot Patterns
EditBackend/src/app/domain/setup_proxy/step_0_lambda_setup/lambda_code.js:
const BOT_PATTERNS = [
// Existing bots...
"gptbot",
"claudebot",
"perplexitybot",
// Add new bot here
"newaibot",
"another-crawler",
];
Step 2: Deploy Changes
curl -X POST https://api.searchcompany.ai/api/domain/update-lambda-edge \
-H "X-API-Key: your-internal-api-key"
Step 3: Verify
The response shows how many distributions were updated. All customer domains will now detect the new bot patterns.Rate Limiting
The endpoint processes distributions in batches of 10 with a 1-second delay between batches to respect AWS CloudFront API limits.Error Handling
If some distributions fail to update:- Successfully updated distributions use the new Lambda
- Failed distributions continue using the old Lambda (still works)
- Retry the endpoint to attempt failed distributions again
Example Response with Failures
{
"status": "success",
"lambda_arn": "arn:aws:lambda:us-east-1:577004485557:function:HostHeaderProxy:5",
"distributions": {
"total": 150,
"successful": 148,
"failed": 2,
"failed_details": [
{
"distribution_id": "E1ABC123",
"status": "error",
"error": "Distribution is currently being updated"
},
{
"distribution_id": "E2DEF456",
"status": "error",
"error": "Access denied"
}
]
}
}