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

# Create or update a project routing expression

Availability:

## Paths

- `PUT` `/_project_routing/{name}`

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

#### Path Parameters

- `name` (string)
  The name of project routing expression

## Description



## Required authorization

* Cluster privileges: `manage_project_routing`,`manage`

## Request Body

`application/json`

- `expression` (string) — required

## 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*"
}
```

#### JavaScript

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

#### Python

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

#### curl

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

#### Java

```java
client.project().createRouting(c -> c
    .name("aws-us-only")
    .expressions(e -> e
        .expression("_csp:aws AND _region:us*")
    )
);
```

#### C#

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

#### PHP

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

#### Ruby

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

## Response Examples

#### A single expressions

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

