| title | Agent API Reference |
|---|---|
| description | HTTP API endpoints for MoeNet Agent and Control Plane communication |
The agent exposes a minimal HTTP API for health checks and manual operations. Default port: 24368.
These endpoints are exposed by the agent for local monitoring and operations.
Returns agent status, version, and session counts.
Request:
curl http://localhost:24368/statusResponse:
{
"status": "ok",
"version": "1.2.0",
"commit": "abc1234",
"uptime": 3600,
"node": {
"id": 1,
"name": "jp1",
"region": "ap-northeast"
},
"sessions": {
"total": 15,
"active": 12,
"error": 1,
"pending": 2
}
}Triggers an immediate session sync from Control Plane.
Request:
curl http://localhost:24368/syncResponse:
{
"status": "sync_triggered"
}Prometheus-format metrics for monitoring.
Request:
curl http://localhost:24368/metricsResponse:
# HELP moenet_agent_sessions_total Total BGP sessions
# TYPE moenet_agent_sessions_total gauge
moenet_agent_sessions_total{status="active"} 12
moenet_agent_sessions_total{status="error"} 1
Check maintenance mode status.
Request:
curl http://localhost:24368/maintenanceResponse:
{
"enabled": false,
"since": null
}Enable maintenance mode (drains BGP sessions).
Request:
curl -X POST http://localhost:24368/maintenance/startResponse:
{
"status": "ok",
"message": "Maintenance mode enabled"
}Disable maintenance mode and restore sessions.
Request:
curl -X POST http://localhost:24368/maintenance/stopRestart a specific WireGuard interface.
Request:
curl -X POST http://localhost:24368/restart \
-H "Content-Type: application/json" \
-d '{"interface": "wg_4242421080"}'Response:
{
"status": "ok",
"interface": "wg_4242421080"
}The agent communicates with the Control Plane using these endpoints.
All requests require a Bearer token:
curl -H "Authorization: Bearer $AGENT_TOKEN" \
https://api.moenet.work/agent/jp1/sessionsFetch all BGP sessions for this router.
Response:
{
"sessions": [
{
"uuid": "abc-123",
"asn": 4242421080,
"status": 1,
"ipv6": "fe80::1",
"ipv6LinkLocal": "fe80::2",
"mtu": 1420,
"interface": "wg_4242421080",
"endpoint": "example.com:51820",
"credential": {
"publicKey": "abc123..."
}
}
]
}Status Codes:
| Status | Name | Description |
|---|---|---|
| 0 | DISABLED | Manually disabled |
| 1 | ACTIVE | Running normally |
| 2 | ERROR | Configuration issue |
| 3 | PENDING_REVIEW | Awaiting approval |
| 4 | QUEUED_FOR_SETUP | Ready for agent |
| 5 | QUEUED_FOR_DELETE | Marked for removal |
Report agent health and system metrics.
Request:
{
"version": "1.2.0",
"uptime": 3600,
"meshPublicKey": "publickey..."
}Response:
{
"status": "ok"
}Report session metrics and statistics.
Request:
{
"sessions": [
{
"uuid": "abc-123",
"rtt_ms": 25,
"routes_imported": 150,
"routes_exported": 10,
"state": "established"
}
]
}Update session status after configuration.
Request:
{
"uuid": "abc-123",
"status": 1,
"error": null
}Error Example:
{
"uuid": "abc-123",
"status": 2,
"error": "BIRD configuration failed: syntax error"
}Fetch mesh IGP peer list.
Response:
{
"peers": [
{
"nodeId": 2,
"name": "hk1",
"endpoint": "hk.moenet.work:23456",
"publicKey": "publickey...",
"loopbackIpv4": "172.23.105.178",
"loopbackIpv6": "fd48:4242:420::2"
}
]
}Fetch full bootstrap configuration.
Response:
{
"node": {
"id": 1,
"name": "jp1",
"region": "ap-northeast",
"asn": 4242420998,
"loopbackIpv4": "172.23.105.177",
"loopbackIpv6": "fd48:4242:420::1"
}
}Fetch BIRD routing policy and community configurations.
Response:
{
"configHash": "abc123",
"node": {
"id": 1,
"name": "jp1",
"type": "edge",
"bandwidth": "1G",
"regionCode": 101,
"continentLc": "LC_ORIGIN_AS",
"subregionLc": "LC_REGION_AS_E",
"regionCommunity": "DN42_REGION_AS_E",
"bandwidthCommunity": "DN42_BW_1G_PLUS"
},
"policy": {
"dn42As": "4242420998",
"dn42Ipv4Prefix": "172.23.105.176/28",
"dn42Ipv6Prefix": "fd48:4da8:420::/48",
"rpkiServers": [
{
"host": "rpki.burble.dn42",
"port": 8283
}
],
"ebgpImportLimit": 10000,
"ebgpExportLimit": 100,
"asPathMaxLen": 10
},
"ibgpPeers": [...]
}| Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad request (invalid JSON, missing fields) |
| 401 | Unauthorized (invalid or missing token) |
| 404 | Not found (unknown router) |
| 429 | Rate limited |
| 500 | Internal server error |
| 503 | Service unavailable (maintenance mode) |
{
"error": "Detailed error message",
"code": "ERROR_CODE"
}| Code | Description |
|---|---|
INVALID_TOKEN |
Agent token is invalid or expired |
ROUTER_NOT_FOUND |
Router name not registered |
SESSION_NOT_FOUND |
Session UUID doesn't exist |
RATE_LIMITED |
Too many requests |
MAINTENANCE_MODE |
Agent in maintenance mode |
#!/bin/bash
# Get all sessions and their status
curl -s http://localhost:24368/status | jq '.sessions'# Trigger sync and wait for completion
curl -s http://localhost:24368/sync
# Check logs
journalctl -u moenet-agent | grep -i sync# Test connectivity to Control Plane
curl -v -H "Authorization: Bearer $TOKEN" \
"https://api.moenet.work/agent/jp1/sessions"
# Check for circuit breaker state
curl -s http://localhost:24368/status | jq '.circuitBreaker'