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

# Create or update a project routing expression

Availability: Experimental

## Paths

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

#### Path parameters

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

## Required authorization

- Cluster privileges: `manage_project_routing`, `manage`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs use key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  For more information about where to find API keys for the Elasticsearch endpoint (${ES_URL}) for a project, go to [Get started with Elasticsearch Serverless](https://www.elastic.co/docs/solutions/search/serverless-elasticsearch-get-started).

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

