Access Sandbox Endpoints
This guide shows how to reach services running inside your sandbox.
Get an endpoint
Section titled “Get an endpoint”Ask the API for a signed endpoint for the port your service listens on. It returns the cluster’s gateway hostname and the headers to send:
curl https://api.nirvanalabs.io/v1/sandboxes/{sandbox_id}/endpoints/{port} \ -H "OPEN-SANDBOX-API-KEY: $NIRVANA_API_KEY"{ "endpoint": "gw.0123456789ab.nirvanacloud.net", "headers": { "OpenSandbox-Ingress-To": "<sandbox_id>-8080-<token>" }}The endpoint is the sandbox cluster’s gateway hostname, shown as
gateway_hostname on the sandbox cluster.
The headers route the request to the sandbox’s port. Always send the headers
the response returns.
Use the endpoint
Section titled “Use the endpoint”Send requests over HTTPS to the returned endpoint, with the returned headers:
curl "https://gw.0123456789ab.nirvanacloud.net/path" \ -H "OpenSandbox-Ingress-To: <value from headers>"Use endpoint and headers exactly as the API returns them, and don’t build
the routing yourself: how the gateway routes requests may change. Every sandbox
is created with secure access, so requests without the returned headers are
rejected.
Expiry
Section titled “Expiry”An endpoint is valid for a limited time:
- By default, it expires with the sandbox, or after 1 hour if the sandbox doesn’t expire.
- Pass
?expires={unix_seconds}to choose the expiry yourself. It must be in the future. - An endpoint never lasts more than 24 hours.
When an endpoint expires, request a new one.
Troubleshooting
Section titled “Troubleshooting”Getting 404 or no response?
Check that the sandbox is Running, the port number is correct, and the
service is listening on that port.
Requests rejected after working before? The endpoint has probably expired. Request a new one.
Can’t connect from your network?
Allow outbound HTTPS to the cluster’s gateway_hostname.
Next steps
Section titled “Next steps”- Delete Sandbox: clean up when done.