# TypeDB Cloud API

The TypeDB Cloud administration API can be used to perform certain actions programmatically, rather than through the TypeDB Cloud website.

To use the API, you will need a [TypeDB Cloud account](https://cloud.typedb.com).

## [](#_generate_an_api_token)Generate an API Token

1.  Visit your [team settings](https://cloud.typedb.com/?team_action=/settings) page, scroll to the API tokens section, and click "Generate API Token".
    
2.  Give your API token a descriptive name, and appropriate access to your chosen space and hit "Create token". See the [API reference](../../reference/cloud-http-api/index.md#accesslevels) for detailed access level info.
    
3.  Once created, the token details will be displayed - save the displayed client secret.
    

Make sure to save the client secret somewhere safe - you will only see it when you first generate the token, and will be unable to use the token without it.

## [](#_access_the_api)Access the API

Once you have your client ID and client secret, you will need to exchange these for a short-lived access token used to query the API.

1.  Make a `POST` request to `https://cloud.typedb.com/api/v1/auth`, with the client ID and client secret in a Basic authorization header, separated by a `:`.
    
    *   curl
        
    *   Python
        
    *   Rust
        
    
    ```console
    curl --request POST \
        --url https://cloud.typedb.com/api/v1/auth \
        --header 'Authorization: Basic {CLIENT-ID}:{CLIENT-SECRET}'
    ```
    
    ```python
    import requests
    
    url = "https://cloud.typedb.com/api/v1/auth"
    
    headers = {
        "Authorization": "Basic {CLIENT-ID}:{CLIENT-SECRET}"
    }
    
    response = requests.post(url, headers=headers)
    ```
    
    ```rust
    use reqwest;
    
    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let client = reqwest::Client::new();
        let resp = client
            .post("https://cloud.typedb.com/api/v1/auth")
            .header(reqwest::header::AUTHORIZATION, "Basic {CLIENT_ID}:{CLIENT_SECRET}")
            .send().await;
        Ok(())
    }
    ```
    
    The response body will be your access token.
    
    For security, your access token will expire after 1 hour.
    
2.  Make an API request to list clusters in the space you selected for your API token. The example below targets the `default` space in an team called `my-team`. You will use the access token you generated in the previous step to authenticate this request.
    
    *   curl
        
    *   Python
        
    *   Rust
        
    
    ```console
    curl --request GET \
        --url https://cloud.typedb.com/api/v1/team/TEAM_ID/spaces/SPACE_ID/clusters \
        --header 'Authorization: Bearer {ACCESS-TOKEN}'
    ```
    
    ```python
    import requests
    
    url = "https://cloud.typedb.com/api/v1/team/my-team/spaces/default/clusters"
    
    headers = {
        "Authorization": "Bearer {ACCESS-TOKEN}"
    }
    
    response = requests.get(url, headers=headers)
    ```
    
    ```rust
    use reqwest;
    
    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let client = reqwest::Client::new();
        let resp = client
            .get("https://cloud.typedb.com/api/v1/team/my-team/spaces/default/clusters")
            .header(reqwest::header::AUTHORIZATION, "Bearer {ACCESS-TOKEN}")
            .send().await;
        Ok(())
    }
    ```
    
    It will return information about the clusters in a JSON format, as below
    
    ```json
    [
        {
            "id":"my-cluster",
            "serverCount":1,
            "storageSizeGB":10,
            "isFree":true,
            "status":"running",
            "createdAt":1738256490070,
            "teamID":"my-team",
            "spaceID":"default",
            "version":"3.1.0",
            "provider":"gcp",
            "region":"europe-west2",
            "machineType":"c2d-highcpu-2",
            "storageType":"standard-rwo",
            "servers": [
                {
                  "address": "abc123-0.cluster.typedb.com:80",
                  "status": "running"
                }
            ]
        }
    ]
    ```
    

## [](#_next_steps)Next steps

Now that you know how to list the clusters in your space from the API, you can explore TypeDB Cloud further, either through further API use or back on the website.

[TypeDB Cloud](https://cloud.typedb.com)

Head back to TypeDB Cloud to keep exploring there.

[TypeDB Cloud API](../../reference/cloud-http-api/index.md)

View the API reference for more detail on what you can do with it.

[Example scripts](https://github.com/typedb/typedb-examples/tree/master/cloud-api-scripts)

Look at examples of using the Cloud API in simple command-line scripts

[IDE Plugins](../ide-plugins/index.md) [Maintenance & Operation](../../maintenance-operation/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/tools/modules/ROOT/pages/typedb-cloud-api.adoc) Edit this page on GitHub.