Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cloudnode-pro/ts-client
A client library for the Cloudnode API, written in TypeScript.
https://github.com/cloudnode-pro/ts-client
api client cloudnode library
Last synced: about 1 month ago
JSON representation
A client library for the Cloudnode API, written in TypeScript.
- Host: GitHub
- URL: https://github.com/cloudnode-pro/ts-client
- Owner: cloudnode-pro
- License: gpl-3.0
- Created: 2022-10-31T06:07:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-11T03:43:20.000Z (about 1 year ago)
- Last Synced: 2024-11-16T05:24:37.246Z (about 2 months ago)
- Topics: api, client, cloudnode, library
- Language: JavaScript
- Homepage: https://cloudnode.pro
- Size: 687 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloudnode API Client
[![npm](https://img.shields.io/npm/v/cloudnode-ts)](https://www.npmjs.com/package/cloudnode-ts)
![API Version: 5.13.0](https://img.shields.io/badge/API%20Version-5.13.0-%232563eb)
[![Build](https://github.com/cloudnode-pro/ts-client/actions/workflows/build.yml/badge.svg)](https://github.com/cloudnode-pro/ts-client/actions/workflows/build.yml)
[![CodeQL](https://github.com/cloudnode-pro/ts-client/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/cloudnode-pro/ts-client/actions/workflows/github-code-scanning/codeql)
[![npm downloads](https://img.shields.io/npm/dt/cloudnode-ts?label=downloads)](https://www.npmjs.com/package/cloudnode-ts)A client library for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
## Install
```shell
npm install cloudnode-ts
```## Usage
### JavaScript
#### Node.js (ES6)
```js
import Cloudnode from 'cloudnode-ts';const cloudnode = new Cloudnode("token_YourSecretToken123");
// get a newsletter
const newsletter = await cloudnode.newsletter.get("newsletter_123asd");
// get response status code
console.log(newsletter._response.status); // 200
```#### Node.js (CommonJS)
```js
const Cloudnode = require('cloudnode-ts');const cloudnode = new Cloudnode("token_YourSecretToken123");
// get a newsletter
const newsletter = await cloudnode.newsletter.get("newsletter_123asd");
console.log(newsletter._response.status); // 200
```#### Browser
Download the browser version from `browser/Cloudnode.js` or use our hosted version.
```htmlconst cloudnode = new Cloudnode();
// get a newsletter
const newsletter = await cloudnode.newsletter.get("newsletter_123asd");
console.log(newsletter._response.status); // 200```
> **Warning**: You most likely don't want to set your private token in a public front-end website, as this will allow anyone who sees your front-end JavaScript code to use it for possibly malicious purposes. We advise you use a back-end server to proxy requests to our API, so you do not expose your token to the public.### TypeScript
```ts
import Cloudnode from 'cloudnode-ts';const cloudnode = new Cloudnode("token_YourSecretToken123");
// get a newsletter
const newsletter: Cloudnode.Newsletter = await cloudnode.newsletter.get("newsletter_123asd");
```
If you want to access response metadata (headers, status code, etc.), use `Cloudnode.ApiResponse`, e.g.:
```ts
const newsletter: Cloudnode.ApiResponse = await cloudnode.newsletter.get("newsletter_123asd");
console.log(newsletter.id); // newsletter_123asd
console.log(newsletter._response.status); // 200
```# Documentation
Table of contents
- [Class: `Cloudnode`](#class-cloudnode)
- [`new Cloudnode([token], [options])`](#new-cloudnodetoken-options)
- [`cloudnode.getPage(response, page)`](#cloudnodegetpagetresponse-page)
- [`cloudnode.getNextPage(response)`](#cloudnodegetnextpagetresponse)
- [`cloudnode.getPreviousPage(response)`](#cloudnodegetpreviouspagetresponse)
- [`cloudnode.getAllPages(response)`](#cloudnodegetallpagestresponse)
- [`cloudnode.checkCompatibility()`](#cloudnodecheckcompatibility)
- [`cloudnode.account.changePassword(currentPassword, newPassword)`](#cloudnodeaccountchangepasswordcurrentpassword-newpassword)
- [`cloudnode.account.get()`](#cloudnodeaccountget)
- [`cloudnode.account.getEmail()`](#cloudnodeaccountgetemail)
- [`cloudnode.account.getIdentity()`](#cloudnodeaccountgetidentity)
- [`cloudnode.account.listEmails()`](#cloudnodeaccountlistemails)
- [`cloudnode.account.listPermissions()`](#cloudnodeaccountlistpermissions)
- [`cloudnode.account.replaceIdentity(username, name)`](#cloudnodeaccountreplaceidentityusername-name)
- [`cloudnode.account.setEmail(email)`](#cloudnodeaccountsetemailemail)
- [`cloudnode.account.updateIdentity(username, [name])`](#cloudnodeaccountupdateidentityusername-name)
- [`cloudnode.auth.login(user, password)`](#cloudnodeauthloginuser-password)
- [`cloudnode.auth.register(username, email, password)`](#cloudnodeauthregisterusername-email-password)
- [`cloudnode.newsletters.get(id)`](#cloudnodenewslettersgetid)
- [`cloudnode.newsletters.list([limit], [page])`](#cloudnodenewsletterslistlimit-page)
- [`cloudnode.projects.create(name)`](#cloudnodeprojectscreatename)
- [`cloudnode.projects.delete(id)`](#cloudnodeprojectsdeleteid)
- [`cloudnode.projects.get(id)`](#cloudnodeprojectsgetid)
- [`cloudnode.projects.list([limit], [page])`](#cloudnodeprojectslistlimit-page)
- [`cloudnode.projects.update(id, name)`](#cloudnodeprojectsupdateid-name)
- [`cloudnode.subscriptions.create(newsletter, email, [data])`](#cloudnodesubscriptionscreatenewsletter-email-data)
- [`cloudnode.subscriptions.delete(id)`](#cloudnodesubscriptionsdeleteid)
- [`cloudnode.subscriptions.get(id)`](#cloudnodesubscriptionsgetid)
- [`cloudnode.subscriptions.list([limit], [page])`](#cloudnodesubscriptionslistlimit-page)
- [`cloudnode.tokens.create(permissions, lifetime, [note])`](#cloudnodetokenscreatepermissions-lifetime-note)
- [`cloudnode.tokens.get(id)`](#cloudnodetokensgetid)
- [`cloudnode.tokens.getRequest(id, request)`](#cloudnodetokensgetrequestid-request)
- [`cloudnode.tokens.list([limit], [page], [internal])`](#cloudnodetokenslistlimit-page-internal)
- [`cloudnode.tokens.listRequests(id, [limit], [page])`](#cloudnodetokenslistrequestsid-limit-page)
- [`cloudnode.tokens.refresh(id)`](#cloudnodetokensrefreshid)
- [`cloudnode.tokens.revoke(id)`](#cloudnodetokensrevokeid)- [Namespace: `Cloudnode`](#namespace-cloudnode)
- [Class: `Cloudnode.ApiResponse`](#class-cloudnodeapiresponset)
- [Class: `Cloudnode.RawResponse`](#class-cloudnoderawresponse)
- [Enum: `Cloudnode.CompatibilityStatus`](#enum-cloudnodecompatibilitystatus)
- [Interface: `Cloudnode.AccountDetails`](#interface-cloudnodeaccountdetails)
- [Interface: `Cloudnode.AccountEmail`](#interface-cloudnodeaccountemail)
- [Interface: `Cloudnode.AccountIdentity`](#interface-cloudnodeaccountidentity)
- [Interface: `Cloudnode.DatedNewsletterSubscription`](#interface-cloudnodedatednewslettersubscription)
- [Interface: `Cloudnode.DatedPrimaryEmail`](#interface-cloudnodedatedprimaryemail)
- [Interface: `Cloudnode.Error`](#interface-cloudnodeerror)
- [Interface: `Cloudnode.Newsletter`](#interface-cloudnodenewsletter)
- [Interface: `Cloudnode.NewsletterData`](#interface-cloudnodenewsletterdata)
- [Interface: `Cloudnode.NewsletterSubscription`](#interface-cloudnodenewslettersubscription)
- [Interface: `Cloudnode.Options`](#interface-cloudnodeoptions)
- [Interface: `Cloudnode.PaginatedData`](#interface-cloudnodepaginateddatat)
- [Interface: `Cloudnode.PartialToken`](#interface-cloudnodepartialtoken)
- [Interface: `Cloudnode.Permission`](#interface-cloudnodepermission)
- [Interface: `Cloudnode.PrimaryEmail`](#interface-cloudnodeprimaryemail)
- [Interface: `Cloudnode.Project`](#interface-cloudnodeproject)
- [Interface: `Cloudnode.Request`](#interface-cloudnoderequest)
- [Interface: `Cloudnode.ShortRequest`](#interface-cloudnodeshortrequest)
- [Interface: `Cloudnode.Token`](#interface-cloudnodetoken)
- [Interface: `Cloudnode.TokenMetadata`](#interface-cloudnodetokenmetadata)## Class: `Cloudnode`
A client library for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
### `new Cloudnode([token], [options])`
Construct a new Cloudnode API client
- `token`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
API token to use for requests.
- `options`[Partial](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype)<[Cloudnode.Options](#interface-cloudnodeoptions)>
API client options. Default: `{baseUrl: "https://api.cloudnode.pro/v5/", autoRetry: true, maxRetryDelay: 5, maxRetries: 3}`### `cloudnode.getPage(response, page)`
Get another page of paginated results
- `response`
[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>>
Response to get a different page of.
- `page`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
Page to get.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)>
The new page or null if the page is out of bounds
- Throws:[Cloudnode.Error](#interface-cloudnodeerror)
Error returned by the API### `cloudnode.getNextPage(response)`
Get next page of paginated results
- `response`
[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>>
Response to get the next page of.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)>
The next page or null if this is the last page
- Throws:[Cloudnode.Error](#interface-cloudnodeerror)
Error returned by the API### `cloudnode.getPreviousPage(response)`
Get previous page of paginated results
- `response`
[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>>
Response to get the previous page of.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)>
The previous page or null if this is the first page
- Throws:[Cloudnode.Error](#interface-cloudnodeerror)
Error returned by the API### `cloudnode.getAllPages(response)`
Get all other pages of paginated results and return the complete data
> **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.- `response`
[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>>
Response to get all pages of.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<T>>
All of the data in 1 page
- Throws:[Cloudnode.Error](#interface-cloudnodeerror)
Error returned by the API### `cloudnode.checkCompatibility()`
Check compatibility with the API
- Returns:
[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.CompatibilityStatus](#enum-cloudnodecompatibilitystatus)>
### `cloudnode.account.changePassword(currentPassword, newPassword)`
Change account password. Requires token with scope `account.details.password.update`.
- `currentPassword`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Your current password.
- `newPassword`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.get()`
Get account details. Requires token with scope `account.details`.
- Returns:
[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountDetails](#interface-cloudnodeaccountdetails)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.getEmail()`
Get your primary e-mail address. Requires token with scope `account.details.email`.
- Returns:
[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.DatedPrimaryEmail](#interface-cloudnodedatedprimaryemail)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.getIdentity()`
Get account identity. Requires token with scope `account.details.identity`.
- Returns:
[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountIdentity](#interface-cloudnodeaccountidentity)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.listEmails()`
List account e-mail addresses. Requires token with scope `account.details.email.list`.
- Returns:
[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.AccountEmail[]](#interface-cloudnodeaccountemail)>>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.listPermissions()`
List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description. Requires token with scope `account.details`.
- Returns:
[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.Permission[]](#interface-cloudnodepermission)>>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.replaceIdentity(username, name)`
Replace account identity. Requires token with scope `account.details.identity.update`.
- `username`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.
- `name`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountIdentity](#interface-cloudnodeaccountidentity)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.setEmail(email)`
Set your primary e-mail address. Requires token with scope `account.details.email.update`.
- `email`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
E-mail address to set as primary.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.account.updateIdentity(username, [name])`
Update account identity. Requires token with scope `account.details.identity.update`.
- `username`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start with `user_`.
- `name`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Your full name. Set to `null` to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z `',-.,` and `ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ`.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.AccountIdentity](#interface-cloudnodeaccountidentity) | [void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>>
`void` if nothing was changed.
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.auth.login(user, password)`
Create a session using user ID/username/e-mail and password.
> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.
- `user`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
User ID (starts with `user_`), username or e-mail address.
- `password`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The password of the account.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<{session: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>>
Session token. Also returned in `Set-Cookie` header.
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "IP_REJECTED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.auth.register(username, email, password)`
Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.
> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.
- `username`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The username to use for the account. Must be between 3 and 20 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.
- `email`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.
- `password`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<{session: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>>
Session token. Also returned in `Set-Cookie` header.
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "IP_REJECTED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.newsletters.get(id)`
Get newsletter
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
A newsletter ID.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Newsletter](#interface-cloudnodenewsletter)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.newsletters.list([limit], [page])`
List newsletters
- `limit`
[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The number of newsletters to return per page. No more than 50. Default: `10`
- `page`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The page number. No more than 2³² (4294967296). Default: `1`
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.Newsletter[]](#interface-cloudnodenewsletter)>>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.projects.create(name)`
Create a project. Requires token with scope `projects.create.own`.
- `name`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Project name. Max 255 characters.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Project](#interface-cloudnodeproject)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.projects.delete(id)`
Delete a project. Requires token with scope `projects.delete.own`.
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Project ID.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.projects.get(id)`
Get a project. Requires token with scope `projects.get.own`.
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Project ID.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Project](#interface-cloudnodeproject)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.projects.list([limit], [page])`
List projects. Requires token with scope `projects.get.own`.
- `limit`
[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The number of projects to return per page. No more than 100. Default: `20`
- `page`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The page number. No more than 2³² (4294967296). Default: `1`
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.Project[]](#interface-cloudnodeproject)>>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.projects.update(id, name)`
Update a project. Requires token with scope `projects.update.own`.
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Project ID.
- `name`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Project name. Max 255 characters.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Project](#interface-cloudnodeproject)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.subscriptions.create(newsletter, email, [data])`
Subscribe to newsletter
- `newsletter`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the newsletter to subscribe to.
- `email`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Subscriber's email address.
- `data`[Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>
Additional data that this newsletter requires.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.NewsletterSubscription](#interface-cloudnodenewslettersubscription)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "CONFLICT"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.subscriptions.delete(id)`
Unsubscribe from newsletter
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the subscription to revoke.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.subscriptions.get(id)`
Get newsletter subscription
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the subscription to get.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.DatedNewsletterSubscription](#interface-cloudnodedatednewslettersubscription)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.subscriptions.list([limit], [page])`
List newsletter subscriptions. Requires token with scope `newsletter.subscriptions.list.own`.
- `limit`
[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The number of subscriptions to return per page. No more than 50. Default: `10`
- `page`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The page number. No more than 2³² (4294967296). Default: `1`
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.DatedNewsletterSubscription[]](#interface-cloudnodedatednewslettersubscription)>>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.tokens.create(permissions, lifetime, [note])`
Create token. Requires token with scope `tokens.create.own`.
- `permissions`
[string[]](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
List of permissions to grant to the token. You must already have each of these permissions with your current token.
- `lifetime`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).
- `note`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
A user-specified note to label the token. Max length: 2⁸ (256) characters.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Token](#interface-cloudnodetoken)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.tokens.get(id)`
Get token details. Requires token with scope `tokens.get.own`.
- `id`
string | "current"
The ID of the token to get. Specify `current` to get information about the token that was used to authenticate the request.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Token](#interface-cloudnodetoken)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.tokens.getRequest(id, request)`
Get a recent request by ID. Requires token with scope `tokens.get.own.requests`.
- `id`
string | "current"
The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.
- `request`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the request.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Request](#interface-cloudnoderequest)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MODIFICATION_NOT_ALLOWED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.tokens.list([limit], [page], [internal])`
List tokens of user. Requires token with scope `tokens.list.own`.
- `limit`
[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The number of tokens to return per page. No more than 50. Default: `10`
- `page`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The page number. No more than 2³² (4294967296). Default: `1`
- `internal`[any](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
Internal tokens are returned as well if this parameter is present.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.PartialToken[]](#interface-cloudnodepartialtoken)>>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.tokens.listRequests(id, [limit], [page])`
Get list of recent requests made with the token. Requires token with scope `tokens.get.own.requests`.
- `id`
string | "current"
The ID of the token. Specify `current` to get information about the token that was used to authenticate the request.
- `limit`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The number of requests to return per page. No more than 50. Default: `10`
- `page`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The page number. No more than 2³² (4294967296). Default: `1`
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)<[Cloudnode.ShortRequest[]](#interface-cloudnodeshortrequest)>>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.tokens.refresh(id)`
Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. Requires token with scope `token.refresh`.
- `id`
string | "current"
The ID of the token to refresh. Specify `current` to refresh the token that was used to authenticate the request.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[Cloudnode.Token](#interface-cloudnodetoken)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
### `cloudnode.tokens.revoke(id)`
Revoke token. Requires token with scope `tokens.revoke.own`.
- `id`
string | "current"
The ID of the token to revoke. Specify `current` to revoke the token that was used to authenticate the request.
- Returns:[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)<[void](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>>
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RESOURCE_NOT_FOUND"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MODIFICATION_NOT_ALLOWED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "NO_PERMISSION"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}
- Throws:[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}
## Namespace: `Cloudnode`
A client library for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
### Class: `Cloudnode.ApiResponse`
An API response. This class implements the interface provided as `T` and includes all of its properties.
- `_response`
[Cloudnode.RawResponse](#class-cloudnoderawresponse)
Raw API response### Class: `Cloudnode.RawResponse`
Raw API response
- `headers`
[Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>
The headers returned by the server. (read-only)
- `ok`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
A boolean indicating whether the response was successful (status in the range `200` – `299`) or not. (read-only)
- `redirected`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry). (read-only)
- `status`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The status code of the response. (read-only)
- `statusText`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The status message corresponding to the status code. (e.g., `OK` for `200`). (read-only)
- `url`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The URL of the response. (read-only)### Enum: `Cloudnode.CompatibilityStatus`
API client compatibility status
- `COMPATIBLE`
"compatible"
Fully compatible (API patch version may differ)
- `OUTDATED`"outdated"
Compatible, but outdated (i.e. existing APIs will work, but you are missing out on new features).
- `INCOMPATIBLE`"incompatible"
API has implemented breaking changes which are not compatible with this client.### Interface: `Cloudnode.AccountDetails`
Details about your account
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Your user ID
- `password`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether you have a password set
- `group`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The name of your permission group
- `permissions`[string[]](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
A list of all permission that you have access to
- `identity`[AccountIdentity](#interface-cloudnodeaccountidentity) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Personal information associated with your account. Requires `account.details.identity` to see. Maybe be null if the account is anonymised or you don't have permission to access the account identity.
- `email`[PrimaryEmail](#interface-cloudnodeprimaryemail) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Your current primary account e-mail address. Requires `account.details.email` to see. Maybe be null if you don't have a primary e-mail address or you don't have permission to access the account's e-mail address.### Interface: `Cloudnode.AccountEmail`
An e-mail address you have added to your account
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the e-mail address
- `address`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Your e-mail address. May ben null if anonymised.
- `verified`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether this e-mail address has been verified
- `primary`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether this e-mail address is your primary e-mail address
- `added`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)
The date and time when this e-mail address was added to your account### Interface: `Cloudnode.AccountIdentity`
Personal information associated with your account
- `username`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Your unique username
- `name`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Your name### Interface: `Cloudnode.DatedNewsletterSubscription`
A newsletter subscription with a creation date
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the subscription. Can be used to unsubscribe.
- `email`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The email address of the subscriber
- `newsletter`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the newsletter that was subscribed to
- `date`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)
The date the subscription was created### Interface: `Cloudnode.DatedPrimaryEmail`
Your current primary account e-mail address with a timestamp of when it was added to your account
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the e-mail address
- `address`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Your e-mail address. May ben null if anonymised.
- `verified`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether this e-mail address has been verified
- `added`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)
The date and time when this e-mail address was added to your account### Interface: `Cloudnode.Error`
An API error response.
- `message`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
A human-readable description of this error
- `code`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Error code
- `fields`[Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>>
Affected request fields. The key is the name of the input parameter (e.g. from the request body or query string) and the value is a human-readable error message for that field.### Interface: `Cloudnode.Newsletter`
A newsletter that you can subscribe to
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The unique identifier for this newsletter
- `name`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The name of this newsletter
- `data`[Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [NewsletterData](#interface-cloudnodenewsletterdata)>
Additional data that is required to subscribe to this newsletter### Interface: `Cloudnode.NewsletterData`
A data field that is required to subscribe to this newsletter
- `name`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The name of the field
- `description`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)
Description of the field
- `type`"string" | "number" | "boolean"
The type of data
- `required`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether this field is required### Interface: `Cloudnode.NewsletterSubscription`
Your subscription to a newsletter
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the subscription. Can be used to unsubscribe.
- `email`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The email address of the subscriber
- `newsletter`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the newsletter that was subscribed to### Interface: `Cloudnode.Options`
API client options
- `baseUrl`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The base URL of the API
- `autoRetry`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether to automatically retry requests that fail temporarily.
If enabled, when a request fails due to a temporary error, such as a rate limit, the request will be retried after the specified delay.
- `maxRetryDelay`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The maximum number of seconds that is acceptable to wait before retrying a failed request.
This requires `autoRetry` to be enabled.
- `maxRetries`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The maximum number of times to retry a failed request.
This requires `autoRetry` to be enabled.### Interface: `Cloudnode.PaginatedData`
Paginated response
- `items`
T[]
The page items
- `total`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The total number of items
- `limit`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The number of items per page
- `page`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The current page number### Interface: `Cloudnode.PartialToken`
A token, however, the `permissions` field is not included
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID or key of the token
- `created`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)
Date and time when this token was created
- `expires`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Date and time when this token expires. Null if it never expires.
- `internal`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)
Whether this token is for internal use only, e.g. to power a session. In other words, an internal token is one that was **not** created by the client.
- `metadata`[Cloudnode.TokenMetadata](#interface-cloudnodetokenmetadata)
Additional metadata about this token### Interface: `Cloudnode.Permission`
A permission node
- `permission`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The permission node string
- `description`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
User-friendly description of the permission node
- `note`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Additional user-friendly information about the permission node
- `group`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
A group/category title that can be used to group permissions together### Interface: `Cloudnode.PrimaryEmail`
Your current primary account e-mail address
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the e-mail address
- `address`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Your primary e-mail address. May ben null if anonymised.
- `verified`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether this e-mail address has been verified### Interface: `Cloudnode.Project`
An isolated group of servers
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the project
- `name`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Project name
- `user`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
ID of the user that owns this project### Interface: `Cloudnode.Request`
A request
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the request
- `method`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The request method (e.g. GET, POST, HEAD, etc.
- `scheme`"http" | "https"
The URL scheme
- `host`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The requested host name
- `url`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The request URL path
- `status`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The HTTP status code that was returned to this request
- `ip`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The IP address of the client that made the request (can be both IPv4 and IPv6)
- `date`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)
The time when the request was received
- `responseTime`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The time in milliseconds that the request took to process
- `hasEvents`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether any server-side error events occurred while processing this request
- `requestHeaders`[Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
The request headers that were received
- `requestBody`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
The request body that was received (likely parsed and formatted as JSON)
- `responseHeaders`[Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
The headers that were returned by the server
- `responseBody`{type: "Buffer", data: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)[]} | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
The response body that was returned by the server in response to this request### Interface: `Cloudnode.ShortRequest`
Overview of a request
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID of the request
- `method`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The request method (e.g. GET, POST, HEAD, etc.
- `scheme`"http" | "https"
The URL scheme
- `host`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The requested host name
- `url`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The request URL path
- `status`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The HTTP status code that was returned to this request
- `ip`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The IP address of the client that made the request (can be both IPv4 and IPv6)
- `date`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)
The time when the request was received
- `responseTime`[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
The time in milliseconds that the request took to process
- `hasEvents`[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
Whether any server-side error events occurred while processing this request### Interface: `Cloudnode.Token`
An authentication token
- `id`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
The ID or key of the token
- `created`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)
Date and time when this token was created
- `expires`[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)
Date and time when this token expires. Null if it never expires.
- `permissions`[string[]](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
Permission scopes that this token holds
- `internal`[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)
Whether this token is for internal use only, e.g. to power a session. In other words, an internal token is one that was **not** created by the client.
- `metadata`[Cloudnode.TokenMetadata](#interface-cloudnodetokenmetadata)
Additional metadata about this token### Interface: `Cloudnode.TokenMetadata`
Token metadata
- `note`
[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)
A user-supplied note for this token