Skip to main content
Version: 7.0

API mode (api)

Overview

The api mode allows executing direct calls to the Passwork API with responses in JSON format.

Syntax

passwork-cli api [options]

API parameters

The api command requires the following parameters:

ParameterDescription
--methodHTTP method (GET, POST, PUT, DELETE, PATCH)
--endpointAPI path (e.g., v1/vaults)
--paramsJSON string with parameters (optional)
--fieldField name to extract from the response (optional)

How it works

  1. Authentication: Connects to the Passwork server;
  2. Request formation: Creates an HTTP request with the specified path and method;
  3. Request sending: Sends the request with the necessary authorization headers;
  4. Response handling: Receives and parses the API response;
  5. Filtering (optional): Extracts the specified field using --field;
  6. Output: The result is output in JSON format.

Usage examples

Get a list of all vaults:

passwork-cli api --method GET --endpoint "v1/vaults"

Get an item and extract only the name:

passwork-cli api --method GET --endpoint "v1/items/password_id" --field "name"

Search items by tags and get names from items:

passwork-cli api \
--method GET \
--endpoint "v1/items/search" \
--params '{"tags":["api","production"]}' \
--field "name"

Rotating accessToken and refreshToken:

passwork-cli api \
--host "https://passwork.example.com" \
--token "your_expired_token" \
--refresh-token "your_refresh_token" \
--method POST \
--endpoint "v1/sessions/refresh" \
--field "token"

Using with a self-signed certificate:

passwork-cli api --no-ssl-verify --method GET --endpoint "v1/user/profile"

Notes

  • All responses are returned in JSON format;
  • The --field parameter allows extracting a specific field from the response;
  • The --params parameter is used to pass data in POST, PUT, PATCH requests;
  • For self-signed certificates, you must use --no-ssl-verify.