Skip to main content
This documentation is for Passwork version 6.0, no longer supported.

See documentation for version 7.0.
Version: 6.0

JS connector

The Passwork API allows you to retrieve, create and update passwords, folders and vaults. It is an easy way to integrate Passwork into your infrastructure. Actions performed with an API key will be executed on behalf of the user the API key belongs to.

Installation example

Create a directory you will clone the repository into:

mkdir js-connector

Use git to clone the connector repository:

git clone https://github.com/passwork-me/js-connector.git .

Install the project dependencies listed in the package.json file:

npm install

API key

Perform the following steps:

  • Authorise in the desktop version of Passwork;
  • Go to Settings and UsersAPI Settings;
  • Enter your password and get the API key.
Searching password by browser extension

It is important to keep the API key secure. It should not be shared with any third parties.

To get a temporary API token, use the login(...) method. Once received, the token is stored and automatically passed in HTTP request headers, making it easy to work with the API. This token is valid for the duration of the session, i.e. as long as requests to the API are made. When the token expires, you need to log in again to generate a new one.

info

The lifetime of a token can be configured in Passwork settings

Action examples

info

See all available Passwork API methods

Open session:

const Passwork = require('./src/passwork-api');
/** @type PassworkAPI */
const passwork = new Passwork("https://passwork/api/v4");
(async () => {
await passwork.login("api-key");
// or expect passwork.login("api-key", "master password"); if you are using client-side encryption

// Specify requests to Passwork

await passwork.logout();
})();

The session is valid for 10 minutes (can be changed). Thus, you can perform multiple actions within one session without logging in.

Obtain a password using the ID:

const Passwork = require('./src/passwork-api');
const passwork = new Passwork("https://passwork/api/v4");
(async () => {
await passwork.login("api-key");
let password = await passwork.getPassword("password-id");
await passwork.logout();
})();

More examples