POST | Secret
  • 1 minute to read
  • Dark
    Light
  • PDF

POST | Secret

  • Dark
    Light
  • PDF

Article summary

Allows you to create or update a secret.

Request

POST https://vault_url/iso/sctm/secret

Request Examples

{
    "identity": "secret-postman",
    "name": "secret-postman",
    "engine": "Generic",
    "expiration_date": "",
    "description": "secret created by postman",
    "data": {
        "hostname": "masked_hostname",
        "username": "masked_username",
        "password": "masked_password",
        "additional_information": "masked_additional_information",
        "ip": "masked_ip"
    }
}

It's also possible to add credentials to the secret. For this, the API will use the date field:{{secret}} as mentioned. To use this field, you must use the following script:

{
    "access_keys": [
        {
            "access_key": {
                "type": "aws",
                "fields": {
                    "access_key_id": "MASKED_ACCESS_KEY_ID",
                    "access_key_id_label": "AWS_ACCESS_KEY_ID",
                    "secret_access_key": "MASKED_SECRET_ACCESS_KEY",
                    "secret_access_key_label": "AWS_SECRET_ACCESS_KEY"
                }
            }
        }
    ],
    "credentials": [
        {
            "credential": {
                "fields": {
                    "user": "masked_user_1",
                    "user_label": "USERNAME",
                    "host": "masked_host_1",
                    "host_label": "HOSTNAME",
                    "password": "masked_password_1",
                    "password_label": "PASSWORD",
                    "additional_information": "masked_additional_info_1",
                    "additional_information_label": "CONNECTION_String"
                }
            }
        },
        {
            "credential": {
                "fields": {
                    "user": "masked_user_2",
                    "user_label": "USERNAME",
                    "host": "masked_host_2",
                    "host_label": "HOSTNAME",
                    "password": "masked_password_2",
                    "password_label": "PASSWORD",
                    "additional_information": "masked_additional_info_2"
                }
            }
        }
    ]
}

This script should be used in the scripts field inside the Postman or another API client you are using.

Parameters for the request

FieldTypeDescription
NameStringSecret’s name.
IdentityStringSecret's identity.
Expiration_DateStringSecret’s expiration date.
DescriptionStringSecret description.
EngineStringThe Secret’s engine must be a valid engine registered in senhasegura.
renew_cloud_timeIntegerTime, in minutes, to renew cloud access keys. If omitted, disable auto-renewal.
renew_credential_timeIntegerTime, in minutes, to renew credentials. If omitted, disables auto-renewal.
renew_ephemeral_credential_timeIntegerTime, in minutes, to renew credentials. If omitted, disables auto-renewal.
DateStringMust be a valid base64 encoded .json.

Example response

{
    "response": {
        "status": 201,
        "message": "Secret created successfully.",
        "error": false,
        "error_code": 0
    },
    "application": {
        "name": "postman",
        "description": "test",
        "tags": [
            "abc",
            "def",
            "test"
        ],
        "system": "inetconfig",
        "environment": "stage",
        "secrets": [
            {
                "secret_id": "7",
                "secret_name": "state_secret",
                "identity": "example_2",
                "version": "2",
                "description": "API Call",
                "expiration_date": "2022-08-18 11:10:00",
                "engine": "GitLab",
                "data": [
                    {
                        "AWS_ACCESS_KEY_ID": "MASKED_ACCESS_KEY_ID",
                        "AWS_SECRET_ACCESS_KEY": "MASKED_SECRET_ACCESS_KEY",
                        "TTL": ""
                    },
                    {
                        "APP": "Postman",
                        "CONNECTION_String": "mongodb://api-server/auth",
                        "DATE": "date",
                        "HOSTNAME": "masked_hostname",
                        "PASSWORD": "masked_password",
                        "USERNAME": "masked_username"
                    }
                ]
            }
        ]
    }
}

Parameters for the response

FieldTypeDescription
nameStringApplication's name.
descriptionStringApplication’s description.
tagsStringApplication’s identification tags.
systemStringSecret's system.
environmentStringSecret's environment.
secret_idIntegeregerSecret's ID.
secret_nameStringSecret's name.
IdentityStringSecret's identifier.
versionStringSecret's version.
expiration_dateStringSecret’s expiration date.
engineStringSecret's engine.
dateStringSecret's value.

Was this article helpful?