Skip to main content
CamposCloudSDK is the entry point of the SDK. Every method is asynchronous and performs exactly one request to https://api.camposcloud.com/v1/.

Constructor

string
required
Your CamposCloud API Key. See Authentication.
Throws Error("API Token is required to initialize CamposCloudSDK.") when apiToken is empty. The base URL is fixed and no request timeout is configured.
Methods validate some of their arguments before sending the request and throw a plain Error when they are invalid. Errors returned by the API are thrown as Axios errors. See Errors and pitfalls.

Account

getMe

Returns the account that owns the API token (GET /v1/users/@me). The SDK unwraps the user object of the API response.
Returns: UserData

Applications

getApplications

Returns the first page of your personal applications (GET /v1/apps).
This method takes no parameters, so it always returns at most the first 10 personal applications. It cannot request other pages, change the page size, or list the applications of a team. If pagination.hasNextPage is true, call GET /v1/apps directly with the page, limit and team query parameters to get the rest.
totalUsedRAM is declared as string in the SDK types, but the API returns a number (megabytes).

getApplication

Fetches one application (GET /v1/apps/{appId}) and wraps it in an Application instance.
string
required
ID of the application.
Returns: Application. The raw API response is in app.data. Throws: Error("Application ID (appId) must be a valid string.") when appId is empty or not a string.

createApplication

Creates an application from a zip file (POST /v1/apps/create) and returns it as an Application instance.
Buffer
required
The application source as a .zip file. It is always sent to the API with the file name file.zip.
string
required
Name of the application (the API requires at least 3 characters).
string
required
Main file of the application, for example index.js.
number
required
Memory to allocate, in MB.
"nodejs" | "python"
required
Runtime of the application. The API also accepts "bun", but the SDK type does not include it (see pitfalls).
string
Custom command used to start the application. When omitted, the API uses the default of the runtime.
boolean
Restart the application automatically. The API default is false.
boolean
Expose the application to the web. Do not set it to true: the API then requires port and assignedSubdomain, which the SDK cannot send, so the request fails with 400.
string
ID of the team to create the application in. It is sent to the API as the team field.
{ key: string; value: string }[]
Environment variables of the application. Values must not be empty.
Returns: Application Throws: a plain Error before sending the request when file, appName, mainFile or runtimeEnvironment is missing, when memoryMB is missing or not a number, or when an environment variable has a key or value that is not a string.
The API accepts 1 creation every 3 seconds. Creating applications in a loop without waiting results in 429 errors.

updateApplication

Updates the settings of an application (POST /v1/apps/{appId}/update).
string
required
ID of the application.
string
required
Name of the application.
number
required
Memory to allocate, in MB.
"nodejs" | "python"
required
Runtime of the application.
string
required
Command used to start the application. It is required by the TypeScript type; at runtime it is only sent when it is not empty.
boolean
Restart the application automatically.
boolean
Expose the application to the web. Only false is useful here: true makes the API require port, which the SDK cannot send.
{ key: string; value: string }[]
Replaces all environment variables. Omit it to keep the current ones; pass [] to remove all of them.
string
Present in the TypeScript type but ignored: it is never sent to the API.
Returns: ApplicationResponseData with the updated application (not an Application instance). Throws: a plain Error before sending the request when appId, appName or runtimeEnvironment is missing, when memoryMB is missing or not a number, or when an environment variable has a key or value that is not a string.
Even though the API can update a single field, the SDK always requires and sends appName, memoryMB and runtimeEnvironment. Most changes only take effect after the application is started or restarted; check restartRequired in the result.
The API accepts 1 update every 3 seconds.

startApplication

Starts an application (POST /v1/apps/{appId}/start).
Returns: ApplicationResponseData
The API answers with 500 when the application is already running, which makes this method throw.

stopApplication

Stops an application (POST /v1/apps/{appId}/stop).
Returns: ApplicationResponseData
The API answers with 500 when the application is already stopped, which makes this method throw.

restartApplication

Restarts an application (POST /v1/apps/{appId}/restart). If the application has pending settings (restartRequired), it is rebuilt with them.
Returns: ApplicationResponseData
The API answers with 500 when the application is not running and has no pending settings. Use startApplication for stopped applications.

deleteApplication

Deletes an application (DELETE /v1/apps/{appId}/delete). This cannot be undone.
Returns: the complete Axios response, not only the body. The body of the API is in response.data. startApplication, stopApplication, restartApplication and deleteApplication throw Error("Application ID (appId) must be a valid string.") when appId is empty or not a string.

Files

uploadFile

Uploads a zip file and extracts it inside the application (POST /v1/apps/{appId}/upload).
string
required
ID of the application.
Buffer
required
A .zip file. The API only accepts zip files and extracts them into path. To upload a single file, put it in a zip first.
string
Directory of the application where the zip is extracted, for example / or /src. Optional in the signature, but always pass it (see the warning below).
Returns: { message: string }. The AxiosError in the declared return type is never actually returned: failures are thrown. Throws: a plain Error when appId is not a string, when path is not a string, or when file is not a Buffer.
When path is omitted, the SDK sends the literal text undefined as the path, so the zip is extracted into a folder called undefined inside your application. Always pass path; use "/" for the root of the application.
path is added to the URL as is, without URL encoding. Avoid spaces and characters such as &, #, ? and %, or encode the value yourself with encodeURIComponent.
The SDK cannot send the restart query parameter of the API, so the application is not restarted after the upload. Call restartApplication if you need it. The API accepts 1 upload every 3 seconds.

downloadFile

Downloads a file or a directory of the application (GET /v1/apps/{appId}/download).
string
required
ID of the application.
string
File or directory to download. When omitted, the whole application is downloaded.
Returns: a Buffer with a zip archive. The API always answers with a zip, even when path points to a single file, so unzip the result to get the file. Throws: a plain Error when appId is not a string or when path is not a string.
As in uploadFile, path is not URL encoded by the SDK. The API accepts 20 downloads per minute and does not include node_modules, .npm, .git, .cache and .bun folders in the archive.

Teams

getTeams

Returns every team you own or are a member of (GET /v1/teams). Teams you own come first.
Returns: TeamResponseData[]

getTeam

Returns one team you own or are a member of (GET /v1/teams/{teamId}).
string
required
ID of the team.
Returns: TeamResponseData. The API does not return applicationsCount for a single team, so that property is undefined here even though the type declares it. Throws: Error("Team ID (teamId) must be a valid string.") when teamId is empty or not a string.
The SDK has no method to list the applications of a team, nor to create, rename or delete teams or manage their members and invites. Use the Teams endpoints of the API for that.