Skip to main content

Simulation Endpoint

Generate realistic emergency scenarios for testing and training purposes with access911.

Endpoint

POST https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate

Request

Headers

HeaderTypeRequiredDescription
Content-TypestringYesapplication/json
AcceptstringNoapplication/json

Body Parameters

ParameterTypeRequiredDefaultDescription
scenariostringNola_wildfireEmergency scenario to simulate
num_callsintegerNo1Number of emergency calls to generate (1-1000)
table_namestringNowildfire-simulation-callsDynamoDB table name

Available Scenarios

Scenario IDNameDescription
la_wildfireLos Angeles WildfireWildfire emergency simulation
nashville_tornadoNashville TornadoTornado outbreak simulation
earthquake_sfSan Francisco EarthquakeEarthquake emergency simulation
hurricane_floridaFlorida HurricaneHurricane emergency simulation

Request Examples

Basic Simulation

curl -X POST https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate \
  -H "Content-Type: application/json" \
  -d '{
    "scenario": "nashville_tornado",
    "num_calls": 25
  }'

High-Volume Simulation

curl -X POST https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate \
  -H "Content-Type: application/json" \
  -d '{
    "scenario": "la_wildfire",
    "num_calls": 100,
    "table_name": "emergency-calls"
  }'

Custom Table Simulation

curl -X POST https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate \
  -H "Content-Type: application/json" \
  -d '{
    "scenario": "earthquake_sf",
    "num_calls": 50,
    "table_name": "test-emergency-calls"
  }'

Response

Success Response

{
  "message": "Generated 25 calls for Nashville Tornado Outbreak",
  "scenario": "nashville_tornado",
  "total_requested": 25,
  "successful": 25,
  "failed": 0,
  "generation_method": "Templates (fast mode)",
  "sample_calls": [
    {
      "call_id": "NASHVILLE_TORNADO-1703123456-1234",
      "location": "Downtown Nashville",
      "emergency_type": "building_damage"
    },
    {
      "call_id": "NASHVILLE_TORNADO-1703123457-1235",
      "location": "East Nashville",
      "emergency_type": "trapped_person"
    }
  ],
  "errors": []
}

Error Response

{
  "error": "Unknown scenario: invalid_scenario",
  "available_scenarios": [
    "la_wildfire",
    "nashville_tornado",
    "earthquake_sf",
    "hurricane_florida"
  ]
}

Response Fields

FieldTypeDescription
messagestringSuccess message describing the operation
scenariostringThe scenario that was simulated
total_requestedintegerNumber of calls requested
successfulintegerNumber of calls successfully generated
failedintegerNumber of calls that failed to generate
generation_methodstringMethod used for generation (“Bedrock AI” or “Templates (fast mode)“)
sample_callsarraySample of generated calls (first 5)
errorsarrayList of any errors encountered

HTTP Status Codes

CodeDescription
200Success - Calls generated successfully
400Bad Request - Invalid parameters or scenario
500Internal Server Error - Server error during processing

Rate Limits

  • Maximum calls per request: 1000
  • Rate limit: 100 requests per minute
  • Burst limit: 500 requests per minute

Generation Methods

AI-Powered Generation (≤20 calls)

For small batches, the API uses AWS Bedrock AI to generate human-like call summaries:
{
  "generation_method": "Bedrock AI",
  "quality": "High",
  "processing_time": "2-5 seconds"
}

Template-Based Generation (>20 calls)

For large batches, the API uses templates for high throughput:
{
  "generation_method": "Templates (fast mode)",
  "quality": "Good",
  "processing_time": "1-3 seconds"
}

Call Data Structure

Each generated call includes:
{
  "call_id": "NASHVILLE_TORNADO-1703123456-1234",
  "timestamp": 1703123456,
  "created_at": "2023-12-21T10:30:56.789Z",
  "location": {
    "latitude": "36.1627",
    "longitude": "-86.7816",
    "address": "1234 Broadway, Downtown Nashville",
    "area": "Downtown Nashville"
  },
  "emergency_type": "building_damage",
  "severity": "critical",
  "description": "severe structural damage from tornado",
  "summary": "Caller reported severe structural damage from tornado at 1234 Broadway, Downtown Nashville. Fire and EMS units dispatched to scene.",
  "duration_secs": 180,
  "caller_phone": "+16155551234",
  "status": "active",
  "simulation": true,
  "scenario": "nashville_tornado",
  "scenario_name": "Nashville Tornado Outbreak"
}

Error Handling

Common Errors

ErrorDescriptionSolution
Unknown scenarioInvalid scenario ID providedUse one of the available scenarios
Invalid num_callsNumber of calls out of rangeUse a number between 1 and 1000
DynamoDB errorDatabase operation failedCheck table permissions and configuration
Bedrock errorAI generation failedFalls back to template generation

Error Response Format

{
  "error": "Error description",
  "details": "Additional error information",
  "timestamp": "2023-12-21T10:30:56.789Z"
}

Best Practices

Performance Optimization

  • Start Small: Begin with 10-20 calls to test system responsiveness
  • Monitor Performance: Watch response times and error rates
  • Use Appropriate Scenarios: Choose scenarios that match your testing needs

Error Handling

  • Implement Retry Logic: Retry failed requests with exponential backoff
  • Handle Rate Limits: Implement proper rate limiting in your client
  • Monitor Errors: Track error rates and types for debugging

Security

  • Validate Input: Always validate parameters before sending requests
  • Handle Sensitive Data: Be careful with sensitive information in logs
  • Use HTTPS: Always use HTTPS for API requests

SDK Examples

Python

import requests
import json

def generate_emergency_calls(scenario, num_calls):
    url = "https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate"
    payload = {
        "scenario": scenario,
        "num_calls": num_calls
    }
    
    response = requests.post(url, json=payload)
    
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"API Error: {response.status_code} - {response.text}")

# Usage
result = generate_emergency_calls("nashville_tornado", 25)
print(f"Generated {result['successful']} calls")

JavaScript

async function generateEmergencyCalls(scenario, numCalls) {
  const url = 'https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate';
  const payload = {
    scenario: scenario,
    num_calls: numCalls
  };
  
  try {
    const response = await fetch(url, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(payload)
    });
    
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    
    const result = await response.json();
    return result;
  } catch (error) {
    console.error('Error generating calls:', error);
    throw error;
  }
}

// Usage
generateEmergencyCalls('nashville_tornado', 25)
  .then(result => console.log(`Generated ${result.successful} calls`))
  .catch(error => console.error('Error:', error));

Testing

Unit Testing

import unittest
from unittest.mock import patch, Mock

class TestSimulationAPI(unittest.TestCase):
    def test_successful_simulation(self):
        with patch('requests.post') as mock_post:
            mock_response = Mock()
            mock_response.status_code = 200
            mock_response.json.return_value = {
                "successful": 25,
                "failed": 0
            }
            mock_post.return_value = mock_response
            
            result = generate_emergency_calls("nashville_tornado", 25)
            self.assertEqual(result["successful"], 25)
            self.assertEqual(result["failed"], 0)

Integration Testing

# Test basic functionality
curl -X POST https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate \
  -H "Content-Type: application/json" \
  -d '{"scenario": "nashville_tornado", "num_calls": 5}'

# Test error handling
curl -X POST https://v2y08vmfga.execute-api.us-east-1.amazonaws.com/simulate \
  -H "Content-Type: application/json" \
  -d '{"scenario": "invalid_scenario", "num_calls": 5}'
Testing Environment: Use the simulation API for testing and training purposes only. For production emergency response, ensure proper integration with your existing 911 systems.