Creates a new card in Supernotes using the Drafts’ title and body.

Configuration

  • Replace YOUR-SUPERNOTES-API-KEY with your Supernotes API key.

How it works

  1. Extracts the Draft’s title and body using templates.
  2. Sends a POST request to the Supernotes API to create a new card.
  3. Logs an error and fails the action if the request fails.
var http = HTTP.create();

let title = draft.processTemplate("[[title]]");
let body = draft.processTemplate("[[body]]");

var response = http.request({
  url: "https://api.supernotes.app/v1/cards/simple",
  method: "POST",
  headers: {
    "Api-key": "YOUR-SUPERNOTES-API-KEY",
    "Content-Type": "application/json",
  },
  data: {
    icon: "",
    name: title,
    markup: body,
  },
});

if (response.error) {
  console.log(response.error);
  context.fail();
}

Note

Make sure to replace YOUR-SUPERNOTES-API-KEY with your actual Supernotes API key.