> For the complete documentation index, see [llms.txt](https://sm-fund.gitbook.io/sm-fund-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sm-fund.gitbook.io/sm-fund-docs/reference/tickets.md).

# Create a WSS Ticket

Create a short-lived WebSocket ticket before opening a data connection. The ticket endpoint is server-to-server: keep the API key on your server and send it only in the `X-API-Key` header.

## Issue a ticket

```http
POST https://sm.fund/v1/wss/tickets
X-API-Key: <SERVER_SIDE_API_KEY>
Content-Type: application/json

{"feed":"polymarket"}
```

The request body is optional. Omitting the body, or omitting `feed`, selects the Polymarket feed. The only accepted feed values are `polymarket` and `raw`.

For the raw feed, request `{"feed":"raw"}`. The endpoint does not accept an API key in a URL, and an API key is not a WebSocket credential.

## Response

```json
{
  "ticket": "<WSS_TICKET>",
  "token_type": "Bearer",
  "expires_at": "<RFC3339_UTC_EXPIRY>",
  "wss_url": "wss://stream.sm.fund/ws",
  "feed": "polymarket",
  "subprotocol": "mmp.trade-batch.v1"
}
```

| Field         | Meaning                                                   |
| ------------- | --------------------------------------------------------- |
| `ticket`      | Short-lived credential for one WebSocket handshake.       |
| `token_type`  | `Bearer`.                                                 |
| `expires_at`  | Ticket handshake expiry as an RFC 3339 timestamp.         |
| `wss_url`     | The WebSocket URL to use for the selected feed.           |
| `feed`        | The selected feed: `polymarket` or `raw`.                 |
| `subprotocol` | The required WebSocket subprotocol for the selected feed. |

Use the returned `wss_url`, `feed`, and `subprotocol` exactly. The production WSS endpoint is `wss://stream.sm.fund/ws`, but clients must not hardcode it, construct a feed URL, or fall back to another endpoint. Send the ticket only as the WebSocket `Authorization` header:

```
Authorization: Bearer <WSS_TICKET>
Sec-WebSocket-Protocol: <RETURNED_SUBPROTOCOL>
```

Do not put the ticket in a query string, and do not send the API key during the WebSocket handshake. A ticket can be consumed once; request a fresh ticket after a ticket has expired or been consumed.

## Feed and plan behavior

Both feeds use one connection per user. The limit is shared across all API keys and both feed types. When a new valid connection for the same user is registered, the previous connection is closed with `4001 connection replaced`.

Free adds a fixed 500 ms server-side delivery delay. Developer adds no delivery delay. See [plans and billing](/sm-fund-docs/get-started/plans-and-billing.md) for plan details.

See [Quickstart](/sm-fund-docs/get-started/quickstart.md), [connection lifecycle](/sm-fund-docs/guides/connection-lifecycle.md), [the Polymarket feed reference](/sm-fund-docs/reference/polymarket-feed.md), [the raw feed reference](/sm-fund-docs/reference/raw-feed.md), and [error handling](/sm-fund-docs/reference/errors.md) for connection examples and recovery behavior.
