---
type: api
title: Create or update project routing expressions
description: ## Required authorization
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-project-create-many-routing
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-project-create-many-routing
products:
  - Elasticsearch Serverless
---

# Create or update project routing expressions

Availability:

## Paths

- `PUT` `/_project_routing`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

## Description



## Required authorization

* Cluster privileges: `manage_project_routing`,`manage`

## Request Body

`application/json`

Type: `NamedProjectRoutingExpressions`


## Response

`application/json`

- `acknowledged` (boolean)
  For a successful response, this value is always true. On failure, an exception is returned instead.
## Code Examples

#### Console

```console
PUT /_project_routing/
{
 "aws-us-only": { "expression": "_csp:aws AND _region:us*" },
 "aws-eu-only": { "expression": "_csp:aws AND _region:eu*" }
}
```

#### JavaScript

```javascript
const response = await client.project.createManyRouting({
  expressions: {
    "aws-us-only": {
      expression: "_csp:aws AND _region:us*",
    },
    "aws-eu-only": {
      expression: "_csp:aws AND _region:eu*",
    },
  },
});
```

#### Python

```python
resp = client.perform_request(
    "PUT",
    "/_project_routing",
    headers={"Content-Type": "application/json"},
    body={
        "aws-us-only": {
            "expression": "_csp:aws AND _region:us*"
        },
        "aws-eu-only": {
            "expression": "_csp:aws AND _region:eu*"
        }
    },
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_project_routing/" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "aws-us-only": {
      "expression": "_csp:aws AND _region:us*"
    },
    "aws-eu-only": {
      "expression": "_csp:aws AND _region:eu*"
    }
  }'
```

#### Java

```java
client.project().createManyRouting(c -> c
    .expressions(Map.of("aws-eu-only", ProjectRoutingExpression.of(p -> p
            .expression("_csp:aws AND _region:eu*")
        ),"aws-us-only", ProjectRoutingExpression.of(p -> p
            .expression("_csp:aws AND _region:us*")
        )))
);
```

#### C#

```c#
var response = await client.Project
    .CreateManyRoutingAsync(d1 => d1
        .Expressions(d2 => d2
            .Add("aws-us-only", d3 => d3
                .Expression("_csp:aws AND _region:us*")
            )
            .Add("aws-eu-only", d3 => d3
                .Expression("_csp:aws AND _region:eu*")
            )
        )
    );
```

#### PHP

```php
$resp = $client->project()->createManyRouting([
    "body" => [
        "aws-us-only" => [
            "expression" => "_csp:aws AND _region:us*",
        ],
        "aws-eu-only" => [
            "expression" => "_csp:aws AND _region:eu*",
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.project.create_many_routing(
  body: {
    "aws-us-only": {
      "expression": "_csp:aws AND _region:us*"
    },
    "aws-eu-only": {
      "expression": "_csp:aws AND _region:eu*"
    }
  }
)
```

## Response Examples

#### Multiple expressions

```json
{
  "acknowledged": true
}
```

