product icon

Use the LastPass Enterprise API Postman Collection

    LastPass provides a Postman collection (a group of saved API requests) to assist with building workflows and simplifying admin tasks (such as provisioning, updating, and deleting users). The "LastPass Enterprise API" Postman collection contains commonly used API requests, which you can issue at the click of a button. Once a request has been sent, the response (data you requested, a status message, or an error message) is displayed within the Postman application itself for easy viewing.

    Before you begin: Make sure you have downloaded Postman from https://www.postman.com/downloads/ and installed it on your computer. Alternatively, you can sign up to use the web version of Postman at https://www.postman.com/.
    Note: The example screenshots displayed in this article use the Windows version of Postman.

      Import the "LastPass Enterprise API" Postman collection into Postman.

      1. Download the Postman collection from here: LastPass Enterprise API Postman Collection (ZIP)
      2. Unzip the file so you have a .json file called LastPass Enterprise API.postman_collection.json.
      3. Open the Postman application, and select Import.
        Postman

        Result: The Import dialog box pops up.

        Import file in Postman

      4. On the File tab, select Upload Files.
      5. Browse your computer and select the unzipped LastPass Enterprise API.postman_collection.json file, then select Open.
      6. Select Import.
        Import collection to Postman

        Result: The "LastPass Enterprise API" Postman collection has now been imported into Postman.

        In the left navigation, select Collections, and expand LastPass Enterprise API. All the API requests in the collection are displayed.

        Collection imported into Postman

      Set up variables in Postman for your company's account number (CID) and provisioning hash (API secret).

      1. Retrieve and save your company's account number (CID) and provisioning hash (API secret) from LastPass. To obtain your LastPass account number and provisioning hash, follow instructions in this article: Where can I find the CID (account number) and API secret?
        Note: As soon as you navigate away from or refresh the page showing your provisioning hash, it will be gone. Make sure your copy the information while it is visible, and then save it as a secure note in the LastPass vault.
      2. In Postman, select the "Environment quick look" eye icon Environment quick look icon in the top right corner. In the Globals section, select Add.
        Add global variable in Postman

        Result: The Globals table is displayed.

      3. In the Globals table:
        1. In the VARIABLE column, in the first row, enter CID.
          Note: The variable name is case-sensitive so make sure you enter it exactly as it is indicated here.
        2. Leave TYPE as default.
        3. In the INITIAL VALUE column, in the first row, enter your company's account number (CID) that you have just retrieved from LastPass.
      4. In the Globals table:
        1. In the VARIABLE column, in the second row, enter ProvisionHash.
          Note: The variable name is case-sensitive so make sure you enter it exactly as it is indicated here.
        2. Leave TYPE as default.
        3. In the INITIAL VALUE column, in the second row, enter the provisioning hash (API secret) that you have just retrieved from LastPass.
          Add CID and ProvisionHash in Postman
      5. Select Save, and close the Globals tab.

        Result: You have set up variables for your company's account number (CID) and provisioning hash (API secret). From now on, these will be automatically populated in the relevant fields of any API request that you execute from the Postman collection.

      Make a test API call to see if everything works as expected.

      1. In the LastPass Enterprise API collection on the left, select an API request.
        Details of the request are displayed on the right. For example, the Body tab displays the body of your request, including the cid and provhash values, which are retrieved from the variables you set up earlier.
        Making an API call from Postman
      2. Make any required changes in the body of the request. For example, if you wish to use the "Get User Data" request for testing, change the value of "username" to a known username.
      3. Click Send.
      4. To check the response, click the Body tab in the bottom half of the screen.

        Depending on the request you issued, you will either get the requested data in the response or information abut the outcome of your request (for example, {"status": "OK"}).

        Tip: To see the well-formatted version of a JSON object returned, click the XML drop-down and select JSON. To set up Postman so that it always displays responses as prettified JSON, follow instructions in: How do I set up Postman so that API response data is always shown as JSON?.
    Results: You are now ready to use the "LastPass Enterprise API" Postman collection.

    How do I access the documentation for the "LastPass Enterprise API" Postman collection?

    The "LastPass Enterprise API" Postman collection comes with its own documentation. Once you have imported the collection into Postman, you can access the document from Postman itself.

    1. Open Postman and select the Collections tab.
    2. Click the three dots displayed next to LastPass Enterprise API, and select View documentation.
      View documentation in Postman

      Result: You are presented with the API documentation.

    How do I set up Postman so that API response data is always shown as JSON?

    It may happen that the API response that you get back displays data in a way that is hard to read because it is not well-formatted JSON with line breaks and indentation in the right places. There is a way to set up Postman so that it always displays data as JSON.

    1. In Postman, click the cog icon Postman cog Settings icon in the top toolbar on the right, and select Settings.

      Result: The SETTINGS dialog box is displayed.

    2. On the General tab, in the Request section, set Language detection to JSON.
      Postman language detection
    3. Close the SETTINGS dialog box.
    Results: From now on, all API responses will display data in JSON format.

    What should I look for if I am getting an error when trying to make an API call?

    When you get an error (for example, "Authorization Error") after issuing an API call, there is some basic troubleshooting that you can do locally.

    1. In Postman, select the "Environment quick look" eye icon Environment quick look icon in the top right corner.
    2. In the Globals section, make sure that CID and ProvisionHash have both the INITIAL VALUE and the CURRENT VALUE set.