---
title: "Open a port proxy"
description: "Returns a one-minute ticket for a WebSocket that proxies to a TCP port inside the computer, such as Postgres on 127.0.0.1:5432 (the cool proxy start command opens a local listener on top of it)."
canonical: "https://www.cool.computer/docs/api-reference/terminals/open-a-port-proxy"
---
# Open a port proxy

> Returns a one-minute ticket for a WebSocket that proxies to a TCP port inside the computer, such as Postgres on 127.0.0.1:5432 (the cool proxy start command opens a local listener on top of it).

```http
POST https://api.cool.computer/api/computers/{id}/proxy-ticket
```

Returns a one-minute ticket for a WebSocket that proxies to a TCP port inside the computer, such as Postgres on 127.0.0.1:5432 (the cool proxy start command opens a local listener on top of it). On the WebSocket each binary or text message carries bytes for the port, and every message from the server carries bytes it sent; an empty message ends the client's input: the server half-closes the port's connection and keeps sending its reply until the program closes it, then closes the WebSocket normally. A site with no VM answers 409 needs_vm. When nothing listens on the port inside the computer, the WebSocket handshake answers 409 port_not_listening; start the program that listens there, then connect again. Callers: an account bearer of the owner or of someone the computer is shared with.

## Authorization

- A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.

## Parameters

- `id` (path, string, at least 1 characters, required): The computer's name, such as agent-atlas, or its id (cmp_…). Every caller may use either, the computer's own runtime token included.

## Request body

Required.

- `application/json` (object)
  - `port` (integer, 1 to 65535, required)

## Responses

- `200`: A WebSocket ticket.
  - `application/json` (object)
    - `ticket` (string, required)
    - `expires_at` (string, date-time, required)
    - `ws_url` (string, required)
- `400`: Bad Request.
- `401`: Unauthorized.
- `402`: Payment Required. `pro_required`: VMs need Pro; start Pro with cool billing upgrade, or fix a lapsed subscription with cool billing portal, or use the Account page.
- `403`: Forbidden.
- `404`: Not Found. `computer_not_found`: the computer does not exist or is not yours.
- `409`: Conflict.
- `429`: Too Many Requests. If the problem code is api_request_rate_exceeded, wait for Retry-After seconds; other problem codes describe a separate limit.
- `500`: Internal Server Error.
- `502`: Bad Gateway.
- `default`: A machine-readable API error with a stable code and recovery instruction.

An error is an `application/problem+json` document with a stable `code`; [API errors](/docs/api-reference/errors) says how to handle one.

## Example

```sh
curl -X POST "https://api.cool.computer/api/computers/$PARAM_ID/proxy-ticket" \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  --data '{"port":1}'
```
