Send to iA Writer

Posted by @davenicholls, Last update over 5 years ago

Sends current draft to iA Writer using the new x-callback-URL scheme

Default folder “/test/drafts” is set in the script and can be changed. Note that the folder must exist or the action will fail

Filename is set to the file safe version of the draft title

Requires auth token, which can be found in iA Writer -> Settings -> URL Commands


  • script

    const baseURL = "ia-writer://x-callback-url/write/";
    const basePath = "/test/drafts/";
    var credential = Credential.create("IA-Writer", "IA-Writer Token");
    credential.addTextField("token", "Token");
    var result = credential.authorize();
    if (!result) {
       alert("Failed to obtain credentials. Please check and retry");
       context.cancel("Failed to obtain credentials");
    else {
       // create and configure callback object
       var cb = CallbackURL.create();
       cb.baseURL = baseURL;
       cb.addParameter("auth-token", credential.getValue("token"));
       cb.addParameter("path", basePath+draft.processTemplate("[[safe_title]]"+".txt"));
       cb.addParameter("text", draft.content);
       var success =;
       if (success) {
          console.log("File created: "+ cb.callbackResponse.path);
       else {
          if (cb.status == "cancel") {
          else {


  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.