Skip to main content

API Overview

GateKey provides a comprehensive REST API for managing all aspects of the VPN infrastructure.

Base URL

All API endpoints are prefixed with /api/v1/.

https://vpn.yourcompany.com/api/v1/

Authentication

Session-Based (Web UI)

For web UI interactions, authentication uses session cookies obtained through OIDC/SAML login.

API Key

For programmatic access, use API keys in the Authorization header:

curl -H "Authorization: Bearer gk_your_api_key_here" \
https://vpn.yourcompany.com/api/v1/gateways

Gateway Token

Gateway agents authenticate with gateway-specific tokens:

curl -H "X-Gateway-Token: your-gateway-token" \
https://vpn.yourcompany.com/api/v1/gateway/heartbeat

Response Format

All responses are JSON:

{
"data": { ... },
"meta": {
"total": 100,
"page": 1,
"per_page": 20
}
}

Error Responses

{
"error": {
"code": "unauthorized",
"message": "Invalid or expired token"
}
}

Common HTTP Status Codes

CodeMeaning
200Success
201Created
400Bad Request
401Unauthorized
403Forbidden
404Not Found
429Rate Limited
500Server Error

Rate Limiting

API endpoints are rate-limited to prevent abuse:

Endpoint TypeRate Limit
Authentication50/min per IP
Gateway heartbeat120/min per gateway
Config generation30/min per user
Admin operations100/min per user

API Categories

User Endpoints

EndpointMethodDescription
/auth/oidc/loginGETInitiate OIDC login
/auth/oidc/callbackGETOIDC callback
/auth/local/loginPOSTLocal admin login
/auth/logoutPOSTLogout
/auth/sessionGETGet current session
/configs/generatePOSTGenerate VPN config
/gatewaysGETList available gateways
/mesh/hubsGETList available mesh hubs

Admin Endpoints

EndpointMethodDescription
/admin/usersGETList users
/admin/gatewaysGET/POSTManage gateways
/admin/gateways/:idPUT/DELETEUpdate/delete gateway
/admin/networksGET/POSTManage networks
/admin/access-rulesGET/POSTManage access rules
/admin/mesh/hubsGET/POSTManage mesh hubs
/admin/configsGETList all VPN configs
/admin/geo-fence/**Geo-fencing settings

Gateway Internal Endpoints

EndpointMethodDescription
/gateway/heartbeatPOSTSend heartbeat
/gateway/verifyPOSTVerify client cert
/gateway/connectPOSTReport connection
/gateway/disconnectPOSTReport disconnection
/gateway/provisionPOSTGet server certificates
/gateway/client-rulesPOSTGet client access rules
/gateway/all-rulesPOSTGet all rules for refresh

PKI Endpoints

EndpointMethodDescription
/pki/crlGETDownload CRL (DER)
/pki/crl.pemGETDownload CRL (PEM)
/pki/check/:serialGETCheck cert revocation
/admin/pki/revokePOSTRevoke certificate

Example: Generate VPN Config

# Get auth token first (via login)

# Generate OpenVPN config for a gateway
curl -X POST https://vpn.yourcompany.com/api/v1/configs/generate \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"gateway_id": "gw-001",
"protocol": "openvpn"
}'

Response:

{
"config_id": "cfg-abc123",
"download_url": "/api/v1/configs/download/cfg-abc123",
"expires_at": "2024-01-16T10:30:00Z"
}

Example: List Gateways

curl https://vpn.yourcompany.com/api/v1/gateways \
-H "Authorization: Bearer $TOKEN"

Response:

{
"data": [
{
"id": "gw-001",
"name": "us-east-1",
"description": "US East Coast Gateway",
"hostname": "vpn-us-east.example.com",
"port": 1194,
"protocol": "udp",
"status": "online",
"last_heartbeat": "2024-01-15T10:30:00Z"
}
]
}

SDK Libraries

Currently, GateKey provides a Go SDK for programmatic access. Community SDKs for other languages are welcome.

OpenAPI Specification

The full OpenAPI specification is available at:

https://vpn.yourcompany.com/api/v1/openapi.json