Create a new credential

Send a POST request to create a new credential.

Prerequisites

JSON Web Token (JWT)
All Control Room APIs require a JSON Web Token (JWT) to access the APIs. Generate an authentication token using the Enterprise 11 Authentication API.
Note:
  • Use the Swagger definition files installed with your Control Room to test the APIs. View the available Swagger APIs at http://<your_control_room_url>/swagger/.
  • You can also use a REST client to complete this task.

Procedure

  1. Add an authentication token to the request header.
    Note: Use the Enterprise 11 Authentication API to generate a JSON Web Token.
  2. Specify the method and URL.
    • Method: POST
    • URL: http://<your_control_room_url>/v2/credentialvault/credentials
  3. Add values to configure the credential.
    The example request includes the following options:
    • Credential name is Email.
    • Credential description (optional) is Used for email login and password.
    • Attribute name is Password.
    • The value is user-provided.

      Once this credential is saved to locker, the locker consumers will receive an email notification to provide the attribute value.

    • The value is masked. When called, the value returns as an empty string.
    • The value is flagged as a password.

      An attribute with this option selected will only be available for use in password-type fields. This ensures the attribute is not exposed and its value cannot be printed to a notepad or any other 'plain text' application. For more information, see Commands that support Credential Variables.

    Request body:
    {
      "name": "Email",
      "description": "Used for email login and password",
      "attributes": [
        {
          "name": "Password",
          "userProvided": true,
          "masked": true,
          "passwordFlag": true
        }
      ]
    }
  4. Send the request.
    • In a REST Client, click SEND.
    • In the Swagger interface, click Execute.
    The response for this example returns information on the new credential. The example response includes the following information:
    • Credential id is 17.
    • Owner id is 14.
    • Attribute id is 70.

    Response body:

    {
    "id": "17",
    "name": "Email",
    "description": "Used for email login and password",
    "ownerId": "14",
    "attributes":[
        {
            "id": "70",
            "name": "Password",
            "description": "",
            "userProvided": true,
            "masked": true,
            "createdBy": "14",
            "createdOn": "2019-12-23T19:01:13.449Z",
            "updatedBy": "14",
            "updatedOn": "2019-12-23T19:01:13.449Z",
            "version": "0",
            "passwordFlag": true
        }
    ],
    "createdBy": "14",
    "createdOn": "2019-12-23T17:42:43.802Z",
    "updatedBy": "14",
    "updatedOn": "2019-12-23T17:42:43.802Z",
    "version": "0"
    }
Note: You can also run REST requests from a command terminal. The following is a curl request example. This example is formatted for readability. Replace the text inside the angle brackets, <authentication_token>, with your authentication token.
curl -X POST "<your_control_room_url>/v2/credentialvault/credentials" -H "accept: application/json"
        -H "X-Authorization: <authentication_token>" -H "Content-Type: application/json"
        -d "{
             \"name\": \"Email\",
             \"description\": \"Used for email login and password\",
             \"attributes\":
              [
                { \"name\": \"Password\",
                  \"userProvided\": true,
                  \"masked\": true,
                  \"passwordFlag\": true } 
               ]
            }"