The Optimize and Deploy API is currently in early access. Contact your Customer Success representative to get access enabled for your organization.
Prerequisites
- A Scrunch workspace with Optimize and Deploy access enabled
- An API key with Configure access
- A brand ID for the brand you want to optimize
- (Optional) A site ID if you want to deploy to AXP
Run your first pipeline
cURL
Python
JavaScript / TypeScript
Set your credentials
export SCRUNCH_API_KEY="your-api-key-here"
export SCRUNCH_BRAND_ID="your-brand-id"
Submit URLs for audit and optimization
This example submits two URLs for audit and content optimization:curl -X POST "https://api.scrunchai.com/v2/orchestration/optimize-and-deploy/$SCRUNCH_BRAND_ID" \
-H "Authorization: Bearer $SCRUNCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://example.com/page-a",
"https://example.com/page-b"
],
"optimize": true
}'
Example response:{
"pipeline_id": null,
"tokens": [
{
"token": "01JABC00000000000000001",
"url": "https://example.com/page-a",
"status": "pending",
"orchestration_status": "audit"
},
{
"token": "01JABC00000000000000002",
"url": "https://example.com/page-b",
"status": "pending",
"orchestration_status": "audit"
}
],
"status": "pending"
}
Poll for status
Use a token from the response to check progress:curl "https://api.scrunchai.com/v2/orchestration/optimize-and-deploy/$SCRUNCH_BRAND_ID/01JABC00000000000000001" \
-H "Authorization: Bearer $SCRUNCH_API_KEY"
Example response (completed):{
"token": "01JABC00000000000000001",
"url": "https://example.com/page-a",
"status": "completed",
"orchestration_status": "completed",
"optimization_run_id": "01JOPTRUN0000000000000",
"axp_version_id": null,
"result": {
"checks": [],
"access_controls_score": 100,
"content_delivery_score": 90,
"content_quality_score": 85
},
"created_at": "2025-02-06T10:00:00Z",
"updated_at": "2025-02-06T10:02:30Z"
}
Submit and poll
import requests
import time
API_KEY = "your-api-key"
BRAND_ID = "your-brand-id"
BASE = f"https://api.scrunchai.com/v2/orchestration/optimize-and-deploy/{BRAND_ID}"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# Submit URLs
resp = requests.post(BASE, headers=HEADERS, json={
"urls": [
"https://example.com/page-a",
"https://example.com/page-b",
],
"optimize": True,
}, timeout=30)
resp.raise_for_status()
pipeline = resp.json()
# Poll each token until done
for record in pipeline["tokens"]:
token = record["token"]
while True:
status = requests.get(
f"{BASE}/{token}", headers=HEADERS, timeout=30
).json()
stage = status["orchestration_status"]
print(f"{token}: {stage}")
if stage in ("completed", "failed"):
break
time.sleep(5)
Submit and poll
import axios from "axios";
const API_KEY = "your-api-key";
const BRAND_ID = "your-brand-id";
const BASE = `https://api.scrunchai.com/v2/orchestration/optimize-and-deploy/${BRAND_ID}`;
const headers = { Authorization: `Bearer ${API_KEY}` };
async function main() {
// Submit URLs
const { data: pipeline } = await axios.post(BASE, {
urls: [
"https://example.com/page-a",
"https://example.com/page-b",
],
optimize: true,
}, { headers });
// Poll each token
for (const record of pipeline.tokens) {
let stage = record.orchestration_status;
while (stage !== "completed" && stage !== "failed") {
await new Promise((r) => setTimeout(r, 5000));
const { data: status } = await axios.get(
`${BASE}/${record.token}`, { headers }
);
stage = status.orchestration_status;
console.log(`${record.token}: ${stage}`);
}
}
}
main().catch(console.error);
Next steps
Orchestration overview
Learn about pipeline stages, error codes, and request patterns.
Pipeline lifecycle guide
Walk through the full lifecycle from submission to completion.
Set up webhooks
Get notified in real time instead of polling.