# Create Route

{% hint style="info" %}
**Prerequisite:** You need an IONOS Cloud account with API credentials configured with the appropriate permissions.
{% endhint %}

To create the object, the full route needs to be provided. Optional data will be filled with defaults or left empty.

To create a new route, you need to use the following [<mark style="color:blue;">Cloud API</mark>](https://api.ionos.com/docs/cloud/v6/) `POST` request:

`POST /gateways/{apigatewayId}/routes`

## Request

```bash
curl -X 'POST' \
  'https://apigateway.de-txl.ionos.com/gateways/0620c174-dd3c-5eb4-87c8-e2b516553a00/routes' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "metadata": {},
  "properties": {
    "name": "example-route",
    "type": "http",
    "paths": [
      "/foo/*",
      "/bar"
    ],
    "methods": [
      "GET",
      "POST"
    ],
    "websocket": false,
    "upstreams": [
      {
        "scheme": "http",
        "loadbalancer": "roundrobin",
        "host": "www.example.com",
        "port": 80,
        "weight": 100
      }
    ]
  }
}'
```

## Response

**201 Route successfully created**

```json
{
  "id": "50982018-bb17-5cb9-bcd4-97f8bbc7dc23",
  "type": "route",
  "href": "/gateways/{apigatewayId}/routes/50982018-bb17-5cb9-bcd4-97f8bbc7dc23",
  "metadata": {
    "createdDate": "2020-12-10T13:37:50+01:00",
    "createdBy": "john.doe@example.com",
    "createdByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
    "lastModifiedDate": "2020-12-11T13:37:50+01:00",
    "lastModifiedBy": "john.doe@example.com",
    "lastModifiedByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
    "resourceURN": "ionos:<product>:<location>:<contract>:<resource-path>",
    "status": "AVAILABLE",
    "statusMessage": null,
    "publicEndpoint": "jf8u4tgr73sd-ag.87uhr654gq90.apigateway.de-txl.ionos.com"
  },
  "properties": {
    "name": "example-route",
    "type": "http",
    "paths": [
      "/foo/*",
      "/bar"
    ],
    "methods": [
      "GET",
      "POST"
    ],
    "websocket": false,
    "upstreams": [
      {
        "scheme": "http",
        "loadbalancer": "roundrobin",
        "host": "www.example.com",
        "port": 80,
        "weight": 100
      }
    ]
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionos.com/cloud/~/revisions/AMiYziCllTKB2y2lmONY/serverless/api-gateway/api-how-tos/create-route.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
