From 2.0.5 to 2.1.0

Between StoredSafe 2.0.5 and 2.1.0 there is a few minor changes in the format of returned data. A few fields and some new endpoints have been added.

New fields

  • HEADERS

  • CALLINFO.audit
    • Returned at login, information about warning and/or violations from the StoredSafe server.

  • BREADCRUMB
    • Returned by the /object endpoint. List parent objects, when object is not in the root of the vault.

  • ERRORCODES
    • Returned when errors occur.

    • The ERRORS field still exists and displays user-facing error messages.

    • CALLINFO.errorcodes will be set to 1 if ERRORCODES exist.

    • CALLINFO.error will be set to 1 if ERRORS exist.

It is now possible to send the StoredSafe token as a header instead of as a parameter by using x-http-token: your-storedsafe-token.

Changed fields

Most results that previously was returned in object form (key-value), is now returned as lists where each object has the field id.

Some fields has changed name, to better reflect its purpose.

  • Vault
    • Field: GROUP => VAULT (specific vault) / VAULTS

    • Type: Object => Array (field id)

  • Object
    • Field: OBJECT => OBJECT (/object endpoint) / OBJECTS (/vault endpoint)

    • Type: Object => Array (field id)

  • Templates
    • Field: TEMPLATESINFO (/object och /vault endpoint) -> TEMPLATES

    • Type: Object => Array (field INFO.id)

    • TEMPLATES.INFO
      • Field: INFO => info

    • TEMPLATES.STRUCTURE
      • Field: STRUCTURE => structure

      • Type: Object => Array (field fieldname)

Note

The /template endpoint has changed from Object => Array but is otherwise unchanged from 2.0.5

Examples

JSON example #1

GET /api/1.0/vault

Using StoredSafe v2.0.5:

{
  ...
  "GROUP": {
    "10": {
      "id": "10",
      "groupname": "Vault 1",
      ...
    },
    ...
  },
}

Using StoredSafe v2.1.0:

{
  ...
  "VAULTS": [
    {
      "id": "10",
      "groupname": "Vault 1",
      ...
    },
    ...
  ],
}

JSON example #2

GET /api/1.0/vault/:vaultid

Using StoredSafe v2.0.5:

{
  "GROUP": {
    "id": "10",
    "groupname": "Vault 1",
    ...
  },
  "OBJECT": {
    "6": {
      "id": "6",
      "parentid": "0",
      "templateid": "1",
      "groupid": "10",
      ...
    },
  },
  "TEMPLATESINFO": {
    "1": {
      "INFO": {
        "id": "1",
        ...
      },
      "STRUCTURE": {
        "host": {
          ...
        },
        "username": {
          ...
        }
      }
    }
  }
}

Using StoredSafe v2.1.0:

{
  "VAULT": {
    "id": "10",
    "groupname": "Vault 1",
    ...
  },
  "OBJECTS": [
    {
      "id": "6",
      "parentid": "0",
      "templateid": "1",
      "groupid": "10",
      ...
    },
  ],
  "TEMPLATES": [
    {
      "INFO": {
        "id": "1",
        ...
      },
      "STRUCTURE": [
        {
          "fieldname": "host",
          ...
        },
        {
          "fieldname": "username",
          ...
        }
      ]
    }
  ]
}

Python Example

Using StoredSafe v2.0.5:

import requests

host = "old.storedsafe.com"
token = "my-storedsafe-token"

## Retrieve vault 10
res = requests.get(f"https://{host}/api/1.0/vault", params={ 'token': token }).json()
vault_10 = res['GROUP']['10']

# Retrieve objekt 6
res = requests.get(f"https://{host}/api/1.0/object/6", headers={ 'x-http-token': token }).json()
object_6 = res['OBJECT']['6']

## Print all object and template names for all objects in vault 10
res = requests.get(f"https://{host}/api/1.0/vault/10", params={ 'token': token }).json()
[print(obj['objectname'], template['INFO']['name']) for _id, obj in res['OBJECT'] for template_id, template in res['TEMPLATESINFO'] if obj['templateid'] == template_id]

Using StoredSafe v2.1.0:

import requests

host = "new.storedsafe.com"
token = "my-storedsafe-token"

## Retrieve vault 10
res = requests.get(f"https://{host}/api/1.0/vault", headers={ 'x-http-token': token }).json()
# Hitta vault med ID 10
vault_10 = next((vault for vault in vaults['VAULTS'] if vault['id'] == '10'), None)

# Retrieve object 6
res = requests.get(f"https://{host}/api/1.0/object/6", headers={ 'x-http-token': token }).json()
object_6 = None
if res['OBJECT']:
  object_6 = res['OBJECT'][0] # First and only object

## Print all object and template names for all objects in vault 10
res = requests.get(f"https://{host}/api/1.0/vault/10", headers={ 'x-http-token': token }).json()
[print(obj['objectname'], template['info']['name']) for obj in res['OBJECTS'] for template in res['TEMPLATES'] if obj['templateid'] == template['info']['id']]