﻿---
title: Manage serverless projects using the API
description: On this page, you can find examples of how to create and manage serverless projects using the Elastic Cloud Serverless API, covering common operations...
url: https://www.elastic.co/elastic/docs-builder/docs/3650/deploy-manage/deploy/elastic-cloud/manage-serverless-projects-using-api
products:
  - Elastic Cloud Serverless
applies_to:
  - Elastic Cloud Serverless: Generally available
---

# Manage serverless projects using the API
On this page, you can find examples of how to create and manage serverless projects using the [Elastic Cloud Serverless API](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/), covering common operations such as:
- [Creating a project](#general-manage-project-with-api-create-a-serverless-elasticsearch-project)
- [Retrieving project details](#general-manage-project-with-api-get-project)
- [Retrieving the project's status](#general-manage-project-with-api-get-project-status)
- [Deleting a project](#general-manage-project-with-api-delete-project)
- [Updating a project](#general-manage-project-with-api-update-project)
- [Listing regions where projects can be created](#general-manage-project-with-api-list-available-regions)

To try the examples in this section, start by [setting up an API key](#general-manage-project-with-api-set-up-api-key).
<agent-skill url="https://github.com/elastic/agent-skills/tree/main/skills/cloud/manage-project">
  A skill is available to help AI agents with this topic.
</agent-skill>


## API resources

To learn about API principles, authentication, and how to use the OpenAPI specification, refer to the [Elastic Cloud Serverless API](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/) documentation.
The available APIs are grouped by project type:
- APIs for [Search projects](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/group/endpoint-elasticsearch-projects)
- APIs for [Observability projects](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/group/endpoint-observability-projects)
- APIs for [Security projects](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/group/endpoint-security-projects)


## Set up an API key

To create and manage projects with the Elastic Cloud Serverless API, you must authenticate your requests with an Elastic Cloud API key.
1. As an **Organization owner**, [create an Elastic Cloud API key](https://www.elastic.co/elastic/docs-builder/docs/3650/deploy-manage/api-keys/elastic-cloud-api-keys) with one of the following roles:
   - **Organization owner**
- **Cloud resource access** with the **Admin** role assigned to **all projects** of the relevant type (Elasticsearch, Observability, or Security)
   Select the key's **API access** level based on what you need it to do: **Cloud API** access is enough to manage projects, while **Cloud, Elasticsearch, and Kibana API** access also grants access to the project's Elasticsearch and Kibana endpoints. For more details, refer to [User roles and privileges](https://www.elastic.co/elastic/docs-builder/docs/3650/deploy-manage/users-roles/cloud-organization/user-roles).
2. Store the generated API key as an environment variable so that you don’t need to specify it again for each request:
   ```json
   export API_KEY="YOUR_GENERATED_API_KEY"
   ```


## Create an Elastic Cloud Serverless project

<agent-skill url="https://github.com/elastic/agent-skills/tree/main/skills/cloud/create-project">
  A skill is available to help AI agents with this topic.
</agent-skill>

```bash
curl -H "Authorization: ApiKey $API_KEY" \
     -H "Content-Type: application/json" \
     "https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch" \
     -XPOST --data '{
        "name": "My project",  
        "region_id": "aws-us-east-1"  
     }'
```

The response from the create project request will include the created project details, including the project ID, the endpoints to access different apps such as Elasticsearch and Kibana, and a set of default credentials.
Example of `Create project` response:
```json
{
    "id": "cace8e65457043698ed3d99da2f053f6",
    "endpoints": {
        "elasticsearch": "https://sample-project-c990cb.es.us-east-1.aws.elastic.cloud",
        "kibana": "https://sample-project-c990cb-c990cb.kb.us-east-1.aws.elastic.cloud"
    },
    "credentials": {
        "username": "admin",
        "password": "abcd12345"
    }
    (...)
}
```

<note>
  For programmatic access to the project's Elasticsearch and Kibana APIs, we recommend creating an [Elastic Cloud API key with access to the Elasticsearch and Kibana APIs](/elastic/docs-builder/docs/3650/deploy-manage/api-keys/elastic-cloud-api-keys#project-access) rather than using the default credentials.The default credentials returned in the `credentials` field serve as a fallback mechanism to access the project when no API key is available. Store them in a secure location, and use the [reset credentials API](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/operation/operation-resetelasticsearchprojectcredentials) if you need to recover or rotate them.
</note>

You can store the project ID as an environment variable for the next requests:
```json
export PROJECT_ID=cace8e65457043698ed3d99da2f053f6
```


## Get project details

You can retrieve your project details through an API call:
```bash
curl -H "Authorization: ApiKey $API_KEY" \
    "https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}"
```


## Get the project status

The 'status' endpoint indicates whether the project is initialized and ready to be used. In the response, the project's `phase` will change from "initializing" to "initialized" when it is ready:
```bash
curl -H "Authorization: ApiKey $API_KEY" \
    "https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}/status"
```

Example response:
```json
{
    "phase":"initializing"
}
```


## Delete a project

You can delete your project via the API:
```bash
curl -XDELETE -H "Authorization: ApiKey $API_KEY" \
    "https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}"
```


## Update a project

You can update your project using a PATCH request. Only the fields included in the body of the request will be updated.
```bash
curl -H "Authorization: ApiKey $API_KEY" \
    -H "Content-Type: application/json" \
    "https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}" \
    -XPATCH --data '{
        "name": "new name",
        "alias": "new-project-alias"
     }'
```


## List available regions

You can obtain the list of regions where projects can be created using the API:
```bash
curl -H "Authorization: ApiKey $API_KEY" \
    "https://api.elastic-cloud.com/api/v1/serverless/regions"
```