Sending Logs via API

That article explains what is needed to send log entries from your app to Crypto Cloud. It is strongly recommended to use one of the existing frameworks which support logging to SwiftyBever instead of consuming the API directly.

For Swift an implementation is available in the  SBPlatformDestination class inside SwiftyBeaver Framework on Github. The documentation of the framework is here

Request Options

To send logs of your app to SwiftyBeaver you need to do a POST request to

The request needs to have the following headers:

  • Content-Type: application/json
  • Accept: application/json
  • Basic Auth with your app credentials

The format of the request, as well as the response, is JSON.

Request Payload

You send to the server an AES256-encrypted JSON of a dictionary called payload . The root object payload contains the array entries and the dictionary device .


It is strongly recommended to bundle multiple log entries (= events) in a single request. For that purpose  entries  is an array of dictionaries where each dinctionary represents a single log entry.

A log entry must contain the following keys:

  • timestamp: seconds since 1970 in double precision
  • level: the level priority as integer with 0 for Verbose, 1 for Debug, 2 for Info, 3 for Warning and 4 for Error
  • message: a string
  • thread: a string of the thread where the logging occurred. For the main thread you can use "" or "main"
  • fileName: a string, for example "AppDelegate.swift"
  • function: a string, for example "viewDidLoad()"
  • line: an integer of the line number inside the file where the logging occurred


SwiftyBeaver also allows the sending of analytics data of the user and the user’s device with the  device dictionary. The most important key is uuid which must be a unique device identifier. The setting of a userName also makes the browsing of log entries much more convenient and adds important user context.

The   device dictionary must contain the following keys:

  • os: a string of the operating system platform ("OSX", "iOS", "watchOS", "tvOS", "Linux")
  • osVersion: a string, for example "10.11.2" for Mac OS X El Capitan
  • hostName: a string of the device’s network name
  • deviceName: a string
  • deviceModel: a string of the official device model identifier (if Apple)
  • userName: a string of the email or username of your user
  • uuid: a string conforming to the NSUUID().UUIDString ASCII format
  • firstStart: timestamp of the first start of the app in double precision
  • lastStart: timestamp of the last start of the app in double precision
  • starts: integer of a counter how often the app was started so far
  • firstAppVersion: a string of the version of the app when it was installed
  • appVersion: a string of the current app version
  • firstAppBuild: an integer of the build number of the app when it was installed
  • appBuild: an integer of the current build number of the app

Example Payload

Here is a typical JSON object with 3 log entries of an iPhone app before it is encrypted.

["entries": (
    fileName: "AppDelegate.swift",
    function: "initStuff()",
    level: 1,
    line: 5,
    message: "the app was started",
    thread: "",
    timestamp: "1461051474.093244"
    fileName: "ViewController.swift",
    functiob: "viewDidLoad()",
    level: 2,
    line: 20,
    message: "the view was loaded",
    thread: "",
    timestamp: "1461051474.111909"
    fileName: "ViewController.swift",
    function: "myLittleFunction()",
    level: 3,
    line: 45,
    message: "oh oh, something in the background",
    thread: "bgThread12",
    timestamp: "1461051474.112721"
"device": {
    appBuild: 128,
    appVersion: "1.2.3",
    deviceModel: "iPhone 7,2",
    deviceName: "Steve’s iPhone",
    firstAppBuild: 70,
    firstAppVersion: "1.0.1",
    firstStart: 1461139881.595012,
    hostName: "steve-iphone.local",
    lastStart: 1462193372.294958,
    osVersion: "9.3.0",
    starts: 332,
    userName: "",
    uuid: "C28D515A-0424-49FC-A8E2-065EE8CDA146"

Encrypt before Sending

The  payload dictionary consisting of entries and device needs to be converted into a JSON string. That JSON string needs to be encrypted via AES256-CBC encryption into a string. For Swift you can use SwiftyBeaver's AES256CBC framework.

Finally, you need to send the encrypted string as value of the JSON POST parameter  payload  to the server.


If your credentials and your request were valid then the server will reply with the HTTP status code 200 and after some seconds the logs will be visible inside the SwiftyBeaver Mac App. On error please see the  status codes article and contact us if you need help.


Please send any error reports, questions and feedback via Slack or email. Also if you want to see this article improved, please feel free to reach out to us. Thank you!

Still need help? Contact Us Contact Us