
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@userdocks/javascript-rest-api
Advanced tools
Call the userdocks REST API via the JavaScript rest function (node + browser)
Call the userdocks REST API via the JavaScript rest function (node + browser)
npm i @userdocks/javascript-rest-api
Documentation of all the functions and methods this SDK exposes.
This method must be called before using any other methods.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.initialize(headers, options);
<object>: an object holding either the api key headers (server-only) or an authentication header (client-only)
<string>: the readOnly or writeOnly api key for userdocks (server-only)<string>: the id of the userdocks app (server-only)<'write' | 'read'>: type of the api key (server-only)<string>: an accesstoken for userdocks Bearer x.y.z (client-only)<object>: an object holding three keys
<string>: the url of the api server (default: https://api.userdocks.com)<string>: the version of the api server (default: v1)<boolean>: an boolean indicating the mode for the stripe payment api (default: true)<object>: an object holdiung three keys
<object>: an object holding four keys
<string>: the url of the api server (default: https://api.userdocks.com)<string>: the version of the api server (default: v1)<boolean>: an boolean indicating the mode for the stripe payment api (default: true)<object>: an object holding either the api key headers (server-only) or an authentication header (client-only)
<string>: the readOnly or writeOnly api key for userdocks (server-only)<string>: the id of the userdocks app (server-only)<'write' | 'read'>: type of the api key (server-only)<string>: an accesstoken for userdocks Bearer x.y.z (client-only)<string>: an uuid created when initialized the userdocks api<boolean>: an boolean indicating if the api is used on the server or on the clientThis method will return all one-time payments for an application between a two dates and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.analytics.oneTimePayments.list(from, to);
<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12// GET /v1/analytics/one-time-payments
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "analyticsOneTimePayment",
"itemsLength": Number,
"items": [
{
"id": String,
"paid": Boolean,
"test": Boolean,
"stripePriceId": String,
"units": Number,
"unitsBefore": Number,
"stripeCustomerId": String,
"stripeCouponId": String,
"mailchimpMemberId": String,
"user": {
"id": String,
"appId": String,
"language": String,
"salutation": String,
"salutationOther": String,
"acceptedNewsletter": Boolean,
"acceptedNewsletterDate": String,
"lastAskedNewsletterSignUp": String,
"mailchimpMemberId": String,
"name": String,
// open id fields use snake case
"given_name": String,
"family_name": String,
"middle_name": String,
"nickname": String,
"preferred_username": String,
"profile": String,
"picture": String,
"website": String,
"email": String,
"email_verified": Boolean,
"gender": String,
"other_gender": String,
"birthdate": String,
"zoneinfo": String,
"locale": String,
"phone_number": String,
"phone_number_verified": Boolean,
"freezed": Boolean,
"deleted": Boolean,
"tenantId": Boolean,
"tenant": {
"id": String,
"name": String,
"stripeCustomerId": String,
"stripePriceId": String,
"stripeProductId": String,
"stripeSubscriptionId": String,
"stripeTrialingPriceId": String,
"stripeTrialingProductId": String,
"stripeTrialingSubscriptionId": String,
"stripeCheckoutSessionId": String,
"stripeDefaultPaymentMethodId": String,
"stripeSubscriptionCancelAtPeriodEnd": Boolean,
"stripeSubscriptionCancelAt": String,
"stripePaymentMethod": String, // 'card' or 'userdocks_promo_code' or somthing with 'promo' specified by the user
"mode": String,// 'payment' or 'subscription'
"description": String,
"stripeOneTimePaymentValidThru": String,
"freezedDueFailedPayment": Boolean,
"paidUntil": String,
"freeUntil": String,
"paidUnits": String,
"freeUnits": String,
"companyName": String,
"companyVATId": String, // value added tax identification number
"companyTaxType": String,
"companyTaxExempt": String, // none, exempt or reverse
"isBusinessCustomer": Boolean,
"isInvoicePending": Boolean,
"freezed": Boolean,
"paymentFailed": Boolean,
"paymentFailedCount": Number,
"paymentFailedDate": String,
"deleted": Boolean,
}
}
},
]
}
}
This method will return all sign ins for an application between a two dates and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.analytics.signIns.list(from, to);
<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12// GET /api/v1/analytics/sign-ins
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "analyticsSignIn",
"itemsLength": Number,
"items": [
{
"id": String,
"lastSignInAt": String,
"daysSinceLastSignIn": String,
"mailchimpMemberId": String,
"user": {
"id": String,
"appId": String,
"language": String,
"salutation": String,
"salutationOther": String,
"acceptedNewsletter": Boolean,
"acceptedNewsletterDate": String,
"lastAskedNewsletterSignUp": String,
"mailchimpMemberId": String,
"name": String,
// open id fields use snake case
"given_name": String,
"family_name": String,
"middle_name": String,
"nickname": String,
"preferred_username": String,
"profile": String,
"picture": String,
"website": String,
"email": String,
"email_verified": Boolean,
"gender": String,
"other_gender": String,
"birthdate": String,
"zoneinfo": String,
"locale": String,
"phone_number": String,
"phone_number_verified": Boolean,
"freezed": Boolean,
"deleted": Boolean,
"tenantId": Boolean,
"tenant": {
"id": String,
"name": String,
"stripeCustomerId": String,
"stripePriceId": String,
"stripeProductId": String,
"stripeSubscriptionId": String,
"stripeTrialingPriceId": String,
"stripeTrialingProductId": String,
"stripeTrialingSubscriptionId": String,
"stripeCheckoutSessionId": String,
"stripeDefaultPaymentMethodId": String,
"stripeSubscriptionCancelAtPeriodEnd": Boolean,
"stripeSubscriptionCancelAt": String,
"stripePaymentMethod": String, // 'card' or 'userdocks_promo_code' or somthing with 'promo' specified by the user
"mode": String,// 'payment' or 'subscription'
"description": String,
"stripeOneTimePaymentValidThru": String,
"freezedDueFailedPayment": Boolean,
"paidUntil": String,
"freeUntil": String,
"paidUnits": String,
"freeUnits": String,
"companyName": String,
"companyVATId": String, // value added tax identification number
"companyTaxType": String,
"companyTaxExempt": String, // none, exempt or reverse
"isBusinessCustomer": Boolean,
"isInvoicePending": Boolean,
"freezed": Boolean,
"paymentFailed": Boolean,
"paymentFailedCount": Number,
"paymentFailedDate": String,
"deleted": Boolean,
}
}
},
]
}
}
This method will return all subscriptions for an application between a two dates and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.analytics.subscriptions.list(from, to);
<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12// GET /v1/analytics/subscriptions
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "analyticsSubscription",
"itemsLength": Number,
"items": [
{
"id": String,
"paid": Boolean,
"test": Boolean,
"until": Number,
"cancelled": Boolean,
"stripeSubscriptionId": String,
"stripePriceId": String,
"stripeCustomerId": String,
"stripeCouponId": String,
"userId": String,
"mailchimpMemberId": String,
"appId": String,
"tenantId": String,
"user": {
"id": String,
"appId": String,
"language": String,
"salutation": String,
"salutationOther": String,
"acceptedNewsletter": Boolean,
"acceptedNewsletterDate": String,
"lastAskedNewsletterSignUp": String,
"mailchimpMemberId": String,
"name": String,
// open id fields use snake case
"given_name": String,
"family_name": String,
"middle_name": String,
"nickname": String,
"preferred_username": String,
"profile": String,
"picture": String,
"website": String,
"email": String,
"email_verified": Boolean,
"gender": String,
"other_gender": String,
"birthdate": String,
"zoneinfo": String,
"locale": String,
"phone_number": String,
"phone_number_verified": Boolean,
"freezed": Boolean,
"deleted": Boolean,
"tenantId": Boolean,
"tenant": {
"id": String,
"name": String,
"stripeCustomerId": String,
"stripePriceId": String,
"stripeProductId": String,
"stripeSubscriptionId": String,
"stripeTrialingPriceId": String,
"stripeTrialingProductId": String,
"stripeTrialingSubscriptionId": String,
"stripeCheckoutSessionId": String,
"stripeDefaultPaymentMethodId": String,
"stripeSubscriptionCancelAtPeriodEnd": Boolean,
"stripeSubscriptionCancelAt": String,
"stripePaymentMethod": String, // 'card' or 'userdocks_promo_code' or somthing with 'promo' specified by the user
"mode": String,// 'payment' or 'subscription'
"description": String,
"stripeOneTimePaymentValidThru": String,
"freezedDueFailedPayment": Boolean,
"paidUntil": String,
"freeUntil": String,
"paidUnits": String,
"freeUnits": String,
"companyName": String,
"companyVATId": String, // value added tax identification number
"companyTaxType": String,
"companyTaxExempt": String, // none, exempt or reverse
"isBusinessCustomer": Boolean,
"isInvoicePending": Boolean,
"freezed": Boolean,
"paymentFailed": Boolean,
"paymentFailedCount": Number,
"paymentFailedDate": String,
"deleted": Boolean,
}
}
},
]
}
}
This method will return all subscriptions for an application between a two dates and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.analytics.subscriptions.list(from, to);
<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12<string>: a date in the follwing format YYYY-MM-DD e.g. 2022-31-12// GET /v1/analytics/tenants
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "analyticsTenant",
"itemsLength": Number,
"items": [
{
id: String,
name: String,
stripeCustomerId: String,
stripePriceId: String,
stripeProductId: String,
stripeSubscriptionId: String,
stripeTrialingPriceId: String,
stripeTrialingProductId: String,
stripeTrialingSubscriptionId: String,
stripeCheckoutSessionId: String,
stripeDefaultPaymentMethodId: String,
stripeSubscriptionCancelAtPeriodEnd: Boolean,
stripeSubscriptionCancelAt: String,
stripePaymentMethod: String, // 'card' or 'userdocks_promo_code' or somthing with 'promo' specified by the user
mode: String,// 'payment' or 'subscription'
description: String,
stripeOneTimePaymentValidThru: String,
freezedDueFailedPayment: Boolean,
paidUntil: String,
freeUntil: String,
paidUnits: String,
freeUnits: String,
companyName: String,
companyVATId: String, // value added tax identification number
companyTaxType: String,
companyTaxExempt: String, // none, exempt or reverse
isBusinessCustomer: Boolean,
isInvoicePending: Boolean,
freezed: Boolean,
paymentFailed: Boolean,
paymentFailedCount: Number,
paymentFailedDate: String,
deleted: Boolean,
tenantAddresses: [
{
id: String,
name: String,
city: String,
country: String,
line1: String,
line2: String,
postal_code: String,
state: String,
type: String,
deleted: Boolean,
}
],
users: [
{
id: String,
appId: String,
language: String,
salutation: String,
salutationOther: String,
acceptedNewsletter: Boolean,
acceptedNewsletterDate: String,
lastAskedNewsletterSignUp: String,
mailchimpMemberId: String,
name: String,
// open id fields use snake case
given_name: String,
family_name: String,
middle_name: String,
nickname: String,
preferred_username: String,
profile: String,
picture: String,
website: String,
email: String,
email_verified: Boolean,
gender: String,
other_gender: String,
birthdate: String,
zoneinfo: String,
locale: String,
phone_number: String,
phone_number_verified: Boolean,
password: String,
freezed: Boolean,
deleted: Boolean,
verified_by_admin: Boolean,
github_email_verified: Boolean,
google_email_verified: Boolean,
facebook_email_verified: Boolean,
twitter_email_verified: Boolean,
lastSignInAt: Boolean,
lastSignInIp: Boolean,
tenantId: Boolean,
}
]
}
]
}
}
This method will return all promotions for an application and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.apps.promotions.list(appId);
<string>: the id of an userdocks application (uuid)// GET /v1/apps/:appId/promotions
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "promotion",
"itemsLength": Number,
"items": [
{}
]
}
}
This method will return the public key for an application and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.apps.publicKeys.retrieve(appId);
<string>: the id of an userdocks application (uuid)// GET /v1/apps/:appId/public-keys
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "publicKey",
"publicKey": String
}
}
This method will return all user roles for an application and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.apps.userRoles.list(appId);
<string>: the id of an userdocks application (uuid)// GET /v1/apps/:appId/user-roles
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "userRole",
"itemsLength": Number,
"items":[
{
id: String,
name: String,
},
],
},
}
This method will update the access status (freezed, unfreezed) of an user for an application and can only be accessed from the server with api keys.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.apps.users.accessStatus.update(appId, userId, accessStatus);
<string>: the id of an userdocks application (uuid)<string>: the id of an userdocks user (uuid)<string>: '0' - freezed (unable to sign in); '1' - unfreezed (able to sign in)// POST /v1/apps/:appId/users/:userId/access-status/:accessStatus
{
"success": Boolean,
"message": String,
"error": null,
"data": null,
}
This method will create a new checkout session (used to redirect to the payment page).
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.checkoutSession.create(tenantId, checkoutSession);
<string>: the id of an userdocks tenant (uuid)<object>: holding up to 10 keys
<string>: a stripe price id<string>: a stripe tax rate id<string>: a two character country code e.g. US<'card' | 'sepa' | 'sofort'><boolean><'payment' | 'subscription' | 'setup'><number><boolean><string>: 64 character long random string<boolean>: indicates if using the stripe payment api in testmode (optional)// POST /v1/tenants/:tenantId/checkout-sessions
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "checkoutSession",
"id": String,
"hash": String,
"nextAction": {
url: String, // the url to the payment page (you need to add the state as query parameter)
}
}
}
This method will list all stripe invoices for a userdocks tenant.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.stripe.invoices.list(tenantId);
<string>: the id of an userdocks tenant (uuid)// GET /v1/tenants/:tenantId/stripe-invoices
{
"success": Boolean,
"message": String,
"error": null,
"data": null,
}
This method will create a new stripe invoice for a userdocks tenant.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.stripe.invoices.create(tenantId, stripeInvoice);
<string>: the id of an userdocks tenant (uuid)<object>: holding up to eight keys
<string>: a stripe price id<string>: a stripe tax rate id<number><string>: the id of an userdocks tenant (uuid)<string>: the id of an userdocks user (uuid)<'payment' | 'subscription' | 'setup'><string>: text that should appear on the invoice (optional)<boolean>: indicates if using the stripe payment api in testmode (optional)// POST /v1/tenants/:tenantId/stripe-invoices
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "stripePaymentIntent",
// https://stripe.com/docs/api/payment_intents/object?lang=node
},
}
This method will delete all stripe payment methods for a userdocks tenant.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.stripe.paymentMethods.del(tenantId);
<string>: the id of an userdocks tenant (uuid)// DELETE /v1/tenants/:tenantId/stripe-payment-methods
{
"success": Boolean,
"message": String,
"error": null,
"data": null,
}
This method will delete all stripe subscriptions for a userdocks tenant.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.stripe.susbcriptions.del(tenantId);
<string>: the id of an userdocks tenant (uuid)// DELETE /v1/tenants/:tenantId/stripe-subscriptions
{
"success": Boolean,
"message": String,
"error": null,
"data": null,
}
This method will upgrade or downgrade an stripe subscription for a userdocks tenant.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.stripe.susbcriptions.update(tenantId, stripeSubscription);
<string>: the id of an userdocks tenant (uuid)<string>: an object holding up to six keys
<string>: a stripe price id<string>: a stripe tax rate id<number><string>: the id of an userdocks tenant (uuid)<string>: the id of an userdocks user (uuid)<boolean>: indicates if using the stripe payment api in testmode (optional)// PUT /v1/tenants/:tenantId/stripe-subscriptions
{
"success": Boolean,
"message": String,
"error": null,
"data": null,
}
This method will return a userdocks tenant.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.retrieve(tenantId);
<string>: the id of an userdocks tenant (uuid)// GET /v1/tenants/:tenantId
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "tenant",
"id": String,
"name": String,
"stripeCustomerId": String,
"stripePriceId": String,
"stripeProductId": String,
"stripeSubscriptionId": String,
"stripeTrialingPriceId": String,
"stripeTrialingProductId": String,
"stripeTrialingSubscriptionId": String,
"stripeCheckoutSessionId": String,
"stripeDefaultPaymentMethodId": String,
"stripeSubscriptionCancelAtPeriodEnd": Boolean,
"stripeSubscriptionCancelAt": String,
"stripePaymentMethod": String, // 'card' or 'userdocks_promo_code' or somthing with 'promo' specified by the user
"mode": String,// 'payment' or 'subscription'
"description": String,
"stripeOneTimePaymentValidThru": String,
"freezedDueFailedPayment": Boolean,
"paidUntil": String,
"freeUntil": String,
"paidUnits": String,
"freeUnits": String,
"companyName": String,
"companyVATId": String, // value added tax identification number
"companyTaxType": String,
"companyTaxExempt": String, // none, exempt or reverse
"isBusinessCustomer": Boolean,
"isInvoicePending": Boolean,
"freezed": Boolean,
"paymentFailed": Boolean,
"paymentFailedCount": Number,
"paymentFailedDate": String,
"deleted": Boolean,
"shippingAddress": {
"id": String,
"name": String,
"city": String,
"country": String,
"line1": String,
"line2": String,
"postal_code": String,
"state": String,
"type": String,
"deleted": Boolean
},
"billingAddress": {
"id": String,
"name": String,
"city": String,
"country": String,
"line1": String,
"line2": String,
"postal_code": String,
"state": String,
"type": String,
"deleted": Boolean
},
"users": [
{
"id": String,
"appId": String,
"language": String,
"salutation": String,
"salutationOther": String,
"acceptedNewsletter": Boolean,
"acceptedNewsletterDate": String,
"lastAskedNewsletterSignUp": String,
"mailchimpMemberId": String,
"name": String,
// open id fields use snake case
"given_name": String,
"family_name": String,
"middle_name": String,
"nickname": String,
"preferred_username": String,
"profile": String,
"picture": String,
"website": String,
"email": String,
"email_verified": Boolean,
"gender": String,
"other_gender": String,
"birthdate": String,
"zoneinfo": String,
"locale": String,
"phone_number": String,
"phone_number_verified": Boolean,
"freezed": Boolean,
"deleted": Boolean,
"verified_by_admin": Boolean,
"github_email_verified": Boolean,
"google_email_verified": Boolean,
"facebook_email_verified": Boolean,
"twitter_email_verified": Boolean,
"lastSignInAt": Boolean,
"lastSignInIp": Boolean,
"tenantId": Boolean
}
]
}
}
This method will update a userdocks tenant.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.tenants.retrieve(tenantId, tenant);
<string>: the id of an userdocks tenant (uuid)<object>: all values are optional
<string><string><string><string><string><'none' | 'exempt' | 'reverse'><boolean><object>:
<string><string><string>: a two character country code e.g. US<string><string><string><string><string><object>:
<string><string><string>: a two character country code e.g. US<string><string><string><string><string>// PUT /v1/tenants/:tenantId
{
"success": Boolean,
"message": String,
"error": null,
"data": null,
}
This method will return a userdocks user.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.users.retrieve(userId);
<string>: the id of an userdocks user (uuid)// GET /v1/users
{
"success": Boolean,
"message": String,
"error": null,
"data": {
"kind": "user",
"id": String,
"appId": String,
"language": String,
"salutation": String,
"salutationOther": String,
"acceptedNewsletter": Boolean,
"acceptedNewsletterDate": String,
"lastAskedNewsletterSignUp": String,
"mailchimpMemberId": String,
"name": String,
// open id fields use snake case
"given_name": String,
"family_name": String,
"middle_name": String,
"nickname": String,
"preferred_username": String,
"profile": String,
"picture": String,
"website": String,
"email": String,
"email_verified": Boolean,
"gender": String,
"other_gender": String,
"birthdate": String,
"zoneinfo": String,
"locale": String,
"phone_number": String,
"phone_number_verified": Boolean,
"freezed": Boolean,
"deleted": Boolean,
"tenantId": Boolean
}
}
This method will update a userdocks user.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.users.retrieve(userId, user);
<string>: the id of an userdocks user (uuid)<object>: all values are optional
language: <string>: a two character country code e.g. US
salutation <'o' | 'f' | 'm'>
salutationOther <string>
acceptedNewsletter <boolean>
name <string>
given_name <string>
family_name <string>
middle_name <string>
nickname <string>
preferred_username <string>
profile <string>
picture <string>
website <string>
email <string>
gender <string>
birthdate <string>: YYYY-MM-DD e.g. 2022-31-12
zoneinfo <string>
locale <string>
phone_number <string>// POST /v1/users/:userId
{
"success": Boolean,
"message": String,
"error": null,
"data": null
}
This method will delete a userdocks user.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.users.retrieve(userId);
<string>: the id of an userdocks user (uuid)// DELETE /v1/users/:userId
{
"success": Boolean,
"message": String,
"error": null,
"data": null,
}
This method will use a userdocks promotion code for a user (e.g. price or subscription for free).
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.users.promotionCodes.use(userId, promotionCode);
<string>: the id of an userdocks user (uuid)<string>: a userdocks promotion code// PUT /v1/users/:userId/promotion-codes/:promotionCode
{
"success": Boolean,
"message": String,
"error": null,
"data": null
}
This method invite a new user based on an email address.
Returns a promise
import userdocks from '@userdocks/javascript-rest-api';
await userdocks.users.promotionCodes.use(userId, user);
<string>: the id of an userdocks user (uuid)<object>: an object holding two keys
<string><string>: a two character country code// POST /v1/users/:userId/referral-invites
{
"success": Boolean,
"message": String,
"error": null,
"data": null
}
Import the library and call the methods.
import userdocks from '@userdocks/javascript-rest-api';
// method to receive the token
const token = await getToken();
// initialize the userdocks api whenever api keys or the access token changes
await userdocks.initialize({
Authentication: `Bearer ${token}`, // or use the api keys if you make requests from a server
// 'X-API-KEY': process.env.USERDOCKS_API_KEY,
// 'X-API-KEY-TYPE': process.env.USERDOCKS_API_KEY_TYPE,
// 'X-CLIENT-ID': process.env.USERDOCKS_APP_ID,
}, {
url: 'https://api.userdocks.com', // use your own api url e.g. when used with CNAME in userdocks
version: 'v1', // the api version, currently v1 is the only version
test: true, // indicate if used in test mode for payment
});
// use the api to e.g. get a user
const user = await userdocks.users.retrieve('me');
Start the watcher and link the package locally:
npm run watch
npm run link
Link the package in the project where it will be used:
# if you run "npm i" in your project you need to re-run this command
npm link @userdocks/javascript-rest-api
To use this module with typescript and with npm link add the follwing to your tsconfig.json:
{
"compilerOptions": {
"paths": {
"@userdocks/javascript-rest-api": [
"./node_modules/@userdocks/javascript-rest-api"
]
}
}
}
FAQs
Call the userdocks REST API via the JavaScript rest function (node + browser)
We found that @userdocks/javascript-rest-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.