Amazon API Gateway
Developer Guide

Set up Routes for a WebSocket API in API Gateway

When you first create a new WebSocket API, there are three predefined routes: $connect, $disconnect, and $default. You can create them by using the console, API, or AWS CLI. If desired, you can create custom routes. For more information, see About WebSocket APIs in API Gateway.

Note

In the CLI, you can create routes before or after you create integrations, and you can reuse the same integration for multiple routes.

Create a Route Using the API Gateway Console

To create a route using the API Gateway console

  1. Sign in to the API Gateway console, choose the API, and choose Routes.

  2. To create one of the predefined routes ($connect, $disconnect, and $default), choose its name.

  3. If desired, you can create custom routes. To do so, enter the route key name in the New Route Key text box and choose the checkmark icon.

    Note

    When you create a custom route, do not use the $ prefix in the route key name. This prefix is reserved for predefined routes.

Create a Route Using the AWS CLI

To create a route using the AWS CLI, call create-route as shown in the following example:

aws apigatewayv2 --region us-east-1 create-route --api-id aabbccddee --route-key $default

Example output:

{ "ApiKeyRequired": false, "AuthorizationType": "NONE", "RouteKey": "$default", "RouteId": "1122334" }