> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camposcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Make your first request to the CamposCloud API and control an application in a few minutes.

**1. Generate your API Key**

In the [Dashboard](https://camposcloud.com/dashboard/applications), open "Your Account", go to **Developer** and click **Generate New API Key**. Copy it right away: you cannot see it again. See [Authentication](https://docs.camposcloud.com/api-reference/authentication.md).

```bash theme={null}
export CAMPOSCLOUD_TOKEN="YOUR_API_KEY_HERE"
```

**2. Check that it works**

[`GET /v1/users/@me`](https://docs.camposcloud.com/api-reference/endpoint/v1/users/@me) returns your account. A `401` means the key is wrong, see [Authentication errors](https://docs.camposcloud.com/api-reference/authentication.md#authentication-errors).

```bash theme={null}
curl https://api.camposcloud.com/v1/users/@me \
  -H "Authorization: Bearer $CAMPOSCLOUD_TOKEN"
```

**3. List your applications**

Each application has an `_id`, which you use in the other endpoints, and `currentResourceMetrics.online`, which tells if it is running. See [`GET /v1/apps`](https://docs.camposcloud.com/api-reference/endpoint/v1/applications/list).

```bash theme={null}
curl https://api.camposcloud.com/v1/apps \
  -H "Authorization: Bearer $CAMPOSCLOUD_TOKEN"
```

**4. Start, stop or restart one**

Use the `_id` of the application. Starting one that is already running returns `500`, so check `online` first.

```bash theme={null}
curl -X POST https://api.camposcloud.com/v1/apps/APP_ID/start \
  -H "Authorization: Bearer $CAMPOSCLOUD_TOKEN"
```

The same works for [`stop`](https://docs.camposcloud.com/api-reference/endpoint/v1/applications/stop) and [`restart`](https://docs.camposcloud.com/api-reference/endpoint/v1/applications/restart).

**5. Follow its logs**

[`GET /v1/apps/{appId}/logs`](https://docs.camposcloud.com/api-reference/endpoint/v1/applications/logs) streams the console of the application while it runs.

## The same thing in code

```typescript JavaScript theme={null}
import CamposCloudSDK from "@camposcloud/sdk";

const api = new CamposCloudSDK({ apiToken: process.env.CAMPOSCLOUD_TOKEN! });

const { applications } = await api.getApplications();
for (const app of applications) {
  console.log(app._id, app.name, app.currentResourceMetrics?.online ? "online" : "offline");
}
```

```python Python theme={null}
import os
import requests

response = requests.get(
    "https://api.camposcloud.com/v1/apps",
    headers={"Authorization": f"Bearer {os.environ['CAMPOSCLOUD_TOKEN']}"},
    timeout=30,
)
response.raise_for_status()

for app in response.json()["applications"]:
    online = app.get("currentResourceMetrics", {}).get("online")
    print(app["_id"], app["name"], "online" if online else "offline")
```

## When something does not work

> [accordion] The application is offline and I did not stop it
>
> Read [Why an application stopped](https://docs.camposcloud.com/guides/why-an-application-stopped.md). The cause is in the `shutdownNotice` and `suspension` fields of the application, and in the message the dashboard shows when you open it.

> [accordion] I get 429
>
> You went over a [rate limit](https://docs.camposcloud.com/api-reference/api-limits.md). Wait the number of seconds in the `Retry-After` header.

> [accordion] I get 403 when starting an application
>
> The owner of the application does not have an active plan, or you do not have the team permission the endpoint needs. See [Teams and permissions](https://docs.camposcloud.com/api-reference/introduction.md#teams-and-permissions).

## Next steps

> [card] [API reference](https://docs.camposcloud.com/api-reference/introduction.md)
>
> Base URL, errors, pagination and every endpoint.

> [card] [JavaScript SDK](https://docs.camposcloud.com/sdk/javascript/getting-started.md)
>
> The same API as methods for Node.js.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.