Sample code

The following cURL examples create a company and a user. Make sure you have your secret key before beginning. See Endpoints and authentication for steps to copy the secret key.

  1. Use POST /api/tokens/apikey to make the authorization request. The API key secret has not been displayed in the following example because of the length, which will be over 500 characters long.

    Copy
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d
    '{
       "ApiKeySecret": "CopiedSecretCopied",
       "Email": "Name@domain.com",
    }'
    'https://red-region.mysecuredatavault.com/api/tokens/apikey'

    The authorization request, if successful, will return a JWT. The actual token has not been displayed in the following example because of the length. which will be over 1250 characters long. You will need to use the value of the access_token in the header of your API calls.

    Copy
    {
    "access_token": "StringOver1200CharactersLong"
    }
  2. Use POST /api/companies to create a company.

    Copy
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer StringOver1200CharactersLong' -d
    '{
       'Company': {
          'CompanyName': 'CompanyName', 
          'PartnerId': '1ab23cde-4567-8901-23a4-bc56dea7b890', 
          'IsTrial': False, 
          'UserGroupRule': 'UsesUserGroups'}, 
       'AuditMessage': 'Message text'
    }'
    'https://red-region.mysecuredatavault.com/api/companies'
  3. Use POST /api/users to create a user.

    Copy
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer StringOver1200CharactersLong' -d 
    '{
       'User': {
          'UserGroupId': '45678901-23a4-bc56-dea7-b8901ab23cde', 
          'CompanyId': '098b7aed-65cb-4a32-1098-7654edc32ba1', 
          'Email': 'UserName@domain.com', 
          'FirstName': 'UserFirstName', 
          'LastName': 'UserLastName', 
          'Custom1': 'Any info needed', 
          'Custom2': '', 
          'Custom3': '', 
          'TimeZone': 'Eastern Standard Time', 
          'CanLoginToDashboard': True, 
          'CanLoginToAccess': True, 
          'APIEnabled': True, 
          'RoleNumber': 3, 
          'RoleAssignments': [{
             'RoleNumber': '1', 
             'EntityId': '890123a4-bc56-dea7-b890-1ab23cde4567'}]}, 
       'AuditMessage': 'Message text'
    }'
    'https://red-region.mysecuredatavault.com/api/users'

You can create a company and a user in the same call. See the /api/companies entry in the Swagger documentation for details. To open the Swagger documentation in your vault, type: <vault name>/swagger. For example: https ://red-region.mysecuredatavault.com/swagger.