import requests
url = "https://api.13-215-85-171.sslip.io/v1/machines/{id}/ports/{port}/preview-proxy-target"
payload = {
"expires_in_seconds": 900,
"transports": ["http", "websocket"],
"token_transport": "header",
"include_traffic_token_hint": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
{
"grant": {
"id": "<string>",
"machine_id": "<string>",
"port": 123,
"status": "active",
"auth_mode": "direct",
"bootstrap_transport": "query",
"token_kinds": [
"http_port"
],
"principal_kind": "user",
"issued_at": "2023-11-07T05:31:56Z",
"expires_at": "2023-11-07T05:31:56Z",
"use_count": 123,
"http_request_count": 123,
"websocket_connection_count": 123,
"bytes_in_count": 123,
"bytes_out_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"principal_id": "<string>",
"revoked_at": "2023-11-07T05:31:56Z",
"first_used_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"last_error_code": "<string>",
"last_error_at": "2023-11-07T05:31:56Z",
"disabled_at": "2023-11-07T05:31:56Z"
},
"machine_id": "<string>",
"port": 123,
"token_header_name": "x-nullspace-preview-proxy-token",
"expires_at": "2023-11-07T05:31:56Z",
"token_transport": "header",
"required_forwarded_headers": [
"x-forwarded-host"
],
"warnings": [
"<string>"
],
"http_url": "https://3000-s-public.nullspace.dev/?__ns_preview_transport=header",
"websocket_url": "wss://3000-s-public.nullspace.dev/?__ns_preview_transport=header",
"http_token": "<string>",
"websocket_token": "<string>",
"traffic_access_required": true,
"traffic_access_header_name": "x-nullspace-traffic-access-token"
}
Machines
Create a custom preview proxy target
Creates a durable preview proxy grant for a customer-run reverse proxy.
The returned upstream URL(s) use header token transport and include the
non-secret __ns_preview_transport=header marker. The proxy must send
the returned token value in x-nullspace-preview-proxy-token on every
upstream request. HTTP and WebSocket tokens are kind-scoped and returned
separately when both transports are requested.
POST
/
v1
/
machines
/
{id}
/
ports
/
{port}
/
preview-proxy-target
import requests
url = "https://api.13-215-85-171.sslip.io/v1/machines/{id}/ports/{port}/preview-proxy-target"
payload = {
"expires_in_seconds": 900,
"transports": ["http", "websocket"],
"token_transport": "header",
"include_traffic_token_hint": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
{
"grant": {
"id": "<string>",
"machine_id": "<string>",
"port": 123,
"status": "active",
"auth_mode": "direct",
"bootstrap_transport": "query",
"token_kinds": [
"http_port"
],
"principal_kind": "user",
"issued_at": "2023-11-07T05:31:56Z",
"expires_at": "2023-11-07T05:31:56Z",
"use_count": 123,
"http_request_count": 123,
"websocket_connection_count": 123,
"bytes_in_count": 123,
"bytes_out_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"principal_id": "<string>",
"revoked_at": "2023-11-07T05:31:56Z",
"first_used_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"last_error_code": "<string>",
"last_error_at": "2023-11-07T05:31:56Z",
"disabled_at": "2023-11-07T05:31:56Z"
},
"machine_id": "<string>",
"port": 123,
"token_header_name": "x-nullspace-preview-proxy-token",
"expires_at": "2023-11-07T05:31:56Z",
"token_transport": "header",
"required_forwarded_headers": [
"x-forwarded-host"
],
"warnings": [
"<string>"
],
"http_url": "https://3000-s-public.nullspace.dev/?__ns_preview_transport=header",
"websocket_url": "wss://3000-s-public.nullspace.dev/?__ns_preview_transport=header",
"http_token": "<string>",
"websocket_token": "<string>",
"traffic_access_required": true,
"traffic_access_header_name": "x-nullspace-traffic-access-token"
}
Path Parameters
Body
application/json
Response
Preview proxy target metadata and header token values