Developers · Code Examples
Copy-ready integration examples
The same assessment call in cURL, JavaScript and Python, followed by real request payloads for Salesforce, Shopify and GitHub agent actions and the retry and control-application patterns we recommend.
Assess a proposed action
Set ASYRX_API_URL and ASYRX_API_KEY in your server environment, then send the proposed action before it executes.
curl -X POST "$ASYRX_API_URL/api/v1/actions/assess" \
-H "Authorization: Bearer $ASYRX_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: demo-assessment-001" \
-d '{
"agent_id": "agt_customer_operations_01",
"target_system": "salesforce",
"action_type": "crm.records.export",
"environment": "production",
"records_affected": 84000,
"entities_affected": 84000,
"data_classification": "confidential",
"destination": "external_analytics",
"reversibility": "partially_reversible"
}'Asyrx does not publish language SDKs. Every example is a plain HTTPS request, so any HTTP client works. See SDK starter for a thin wrapper you can paste into your own codebase.
Response
The complete response for the Salesforce export above, exactly as the engine returns it.
200 OK
{
"api_version": "v1",
"risk_engine_version": "1.0",
"policy_version": "1.0",
"assessment_id": "1f3c9b7a-6d24-4a8e-9c51-77b0f2a4e1d9",
"action_id": "8b2e5d41-90c7-4f6a-b3ae-0c19d7f45a62",
"request_id": "req_01j9x8k2j3n4m5p6q7r8s9t0u1",
"status": "completed",
"environment_mode": "test",
"normalized_action_type": "crm.records.export",
"action_category": "data",
"action_risk": { "score": 60, "level": "moderate", "confidence": 0.77 },
"blast_radius": {
"score": 97,
"level": "critical",
"dimensions": {
"financial_impact": 0,
"entity_impact": 95,
"data_impact": 97,
"operational_impact": 45,
"privilege_impact": 0,
"reversibility": 48
}
},
"risk_factors": [
{
"code": "NOVEL_DESTINATION",
"category": "destination",
"severity": "high",
"message": "Destination \"external_analytics\" has not been used by this organization before."
},
{
"code": "HIGH_ENTITY_COUNT",
"category": "volume",
"severity": "critical",
"message": "84,000 records in scope for a single action."
},
{
"code": "SENSITIVE_DATA_EXPORT",
"category": "data",
"severity": "critical",
"message": "84,000 confidential records would leave the system of record."
},
{
"code": "PRODUCTION_ENVIRONMENT",
"category": "environment",
"severity": "moderate",
"message": "The action targets a live production environment."
}
],
"recommended_control": {
"type": "SECONDARY_APPROVAL_RECOMMENDED",
"priority": "critical",
"because": ["Novel destination", "High entity count", "Sensitive data export"]
},
"recommendations": ["VERIFY_DESTINATION", "VERIFY_SCOPE", "CONFIRM_PRODUCTION_ENVIRONMENT"],
"behavioral_context": {
"historical_comparison_available": false,
"baseline_scope": "organization",
"sample_size": 0,
"window_days": 30,
"entity_volume_multiplier": null,
"financial_value_multiplier": null,
"velocity_multiplier": null,
"destination_seen_before": false,
"action_type_seen_before": false
},
"policy_context": [],
"summary": "Action Risk 60 with a Blast Radius of 97. Primary drivers: novel destination and high entity count. Secondary Approval Recommended. Asyrx does not authorize, execute or block this action.",
"processing_time_ms": 41,
"created_at": "2026-09-01T16:12:04.118Z",
"disclaimer": "Asyrx provides risk intelligence and decision-support recommendations for proposed AI-agent actions. Customers remain responsible for authorization, execution and final operational decisions."
}Salesforce action payloads
Request bodies for representative Salesforce agent actions, including a routine action so you can see the contrast in scoring.
{
"agent_id": "agt_customer_ops",
"target_system": "salesforce",
"action_type": "contacts.export",
"environment": "production",
"entities_affected": 84000,
"records_affected": 84000,
"destination": "analytics-vendor-staging.example.com",
"data_classification": "confidential",
"reversibility": "partially_reversible",
"privilege_change": false,
"production_impact": true,
"action_description": "Export 84,000 CRM contacts to an external analytics destination.",
"target_resource": "Contact",
"context": {
"requested_by": "customer_operations_agent",
"workflow_id": "wf_82944"
}
}Shopify action payloads
Request bodies for representative Shopify agent actions, including a routine action so you can see the contrast in scoring.
{
"agent_id": "agt_commerce_ops",
"target_system": "shopify",
"action_type": "bulk_cancel_orders",
"environment": "production",
"financial_value": 128450,
"currency": "USD",
"entities_affected": 847,
"records_affected": 847,
"data_classification": "internal",
"reversibility": "difficult_to_reverse",
"production_impact": true,
"action_description": "Cancel 847 customer orders affected by a warehouse fulfilment exception.",
"target_resource": "Order",
"context": {
"workflow_id": "wf_fulfilment_exception"
}
}GitHub action payloads
Request bodies for representative GitHub agent actions, including a routine action so you can see the contrast in scoring.
{
"agent_id": "agt_eng_automation",
"target_system": "github",
"action_type": "delete_repository",
"environment": "production",
"entities_affected": 1,
"data_classification": "restricted",
"reversibility": "irreversible",
"production_impact": true,
"action_description": "Delete the northwind/payments-core repository flagged as stale by cleanup automation.",
"target_resource": "northwind/payments-core",
"context": {
"workflow_id": "wf_repo_cleanup"
}
}Retries and fail-safe handling
Retry rate limits and unavailability with the returned retry_after_seconds, and escalate to a human when Asyrx cannot produce an assessment.
JavaScript
async function assessWithRetry(payload, idempotencyKey, attempt = 0) {
const response = await fetch(`${process.env.ASYRX_API_URL}/api/v1/actions/assess`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ASYRX_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": idempotencyKey,
},
body: JSON.stringify(payload),
});
if (response.status === 429 || response.status === 503) {
const body = await response.json();
const wait = (body.error?.retry_after_seconds ?? 2 ** attempt) * 1000;
if (attempt >= 3) {
// Fail safe: never assume low risk when Asyrx could not answer.
return { unavailable: true, request_id: body.request_id };
}
await new Promise((resolve) => setTimeout(resolve, wait));
return assessWithRetry(payload, idempotencyKey, attempt + 1);
}
return response.json();
}Reuse the same Idempotency-Key across retries of one logical action so a replay returns the original assessment rather than creating a duplicate.
Applying the recommendation
Asyrx never authorizes, executes or blocks an action. This is the shape of the control layer on your side.
JavaScript
// Asyrx returns intelligence. Your policy decides.
const assessment = await assessWithRetry(proposedAction, actionId);
switch (assessment.recommended_control?.type) {
case "SECONDARY_APPROVAL_RECOMMENDED":
await queueForApproval(actionId, assessment);
break;
case "HUMAN_REVIEW_RECOMMENDED":
await queueForReview(actionId, assessment);
break;
case "ELEVATED_MONITORING_RECOMMENDED":
await execute(proposedAction, { monitor: true });
break;
default:
await execute(proposedAction);
}
// Always store the trace alongside your own action record.
await recordAudit({
action_id: actionId,
assessment_id: assessment.assessment_id,
request_id: assessment.request_id,
action_risk: assessment.action_risk?.score,
blast_radius: assessment.blast_radius?.score,
});