Example code

Check your API key

You can check if your API keys works by calling the authenticated health endpoint of the API. You can also use this endpoint to see if the mSafe API is healthy. Below are 3 examples of how to do this.

Python

import requests

url = "https://api.msafe.nl/health-authenticated"

payload = {}
headers = { 'Authorization': '{your_api_key_here}' }

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

curl

curl https://api.msafe.nl/health
curl -H 'Authorization: {your_api_key_here}' https://api.msafe.nl/health-authenticated

Postman

Postman example image

Upload Files

Uploading files to mSafe works in three steps.

  1. Request a SAS URI from mSafe
  2. Upload your file to the SAS URI
  3. Share the file in mSafe
Requesting a SAS URI can be done by sending a GET to /v1/shares/{shareIdentifier}/files/sasuri. It requires an API key with the Upload scope that has been added to the share to which you are uploading. The response of this endpoint contains a file identifier, which is a GUID, and a URI. Temporarily store the file identifier. Upload your file to the URI. Below are two examples of how you can achieve this. Once the upload has completed, send a POST to /v1/shares/{shareIdentifier}/files/{fileIdentifier} with the file metadata. This will make the file available in mSafe.

Using AzCopy

azcopy cp "{path to file}" "{SAS URI}"

Using C#

using Azure.Storage.Blobs;

Uri sasUri = new("{SAS URI}");
BlobClient blobClient = new(sasUri);
await using var fileStream = File.OpenRead(@"{path to file}");
await blobClient.UploadAsync(fileStream);