Authentication
MSpread supports two methods of authentication. Use Bearer tokens for client-side applications and API Keys for server-side scripts.
Method A: Bearer Token
Standard for frontend applications using JWT.
Authorization: Bearer <JWT_TOKEN>Method B: API Key
Recommended for scripts and external tools. Generate this in your settings.
X-API-Key: <YOUR_API_KEY>Auth Endpoints
POST
/auth/registerRegister a new user account.
Request Body
{
"email": "user@example.com",
"password": "string"
}POST
/auth/loginLogin and retrieve a JWT access token.
Request Body
{
"email": "user@example.com",
"password": "string"
}Example Usage (Python)
import requests
import json
API_KEY = "msp_example_key_12345"
BASE_URL = "https://api.mspread.com/api"
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
# 1. Define Simulation
payload = {
"network_config": {
"network_type": "scale_free",
"num_nodes": 50
},
"malware_config": {
"malware_type": "worm",
"infection_rate": 0.3
},
"initial_infected": ["device_0"],
"max_steps": 50
}
# 2. Run Simulation
response = requests.post(f"{BASE_URL}/simulate", json=payload, headers=headers)
if response.status_code == 200:
results = response.json()
print(f"Simulation Complete! ID: {results['id']}")
else:
print(f"Error: {response.text}")