Can this be done with Drafts 5?

I don’t use Anki, but maybe try this:


In a step configured like this.

It fails as I don’t have the app, but I don’t get an invalid URL.

Made some progress, now the Anki App gives an error that says: Unknown Argument x-cancel

Just copy mine and replace your values. Mine works perfectly. I see you have curly brackets remove those.

What I see:

  1. stock market learning has spaces replace with the proper values.

  2. curly brackets remove those from your drafts tags

  3. make sure there are no empty spaces in your action

Once corrected it should works


and my Draft for the like this:

[[Front]]What is the stock market?

[[Body]]It aggregates votes

I managed to add a card, but Anki gives an error that says ‘Unknown Argument x-cancel’. The card is created, so my purpose is achieved. Thanks to all. This is how the final action looks:


My draft looks like this, this was what I was probably getting wrong:

What is the Stock Market?

It aggregates votes

Any idea why I’m getting the error?

if you could take a screenshot of the actual action and its settings that would be helpful to diagnose. Or share it to the action directory.

You have URL encoded the square brackets that define the Drafts template tags.

I would simply the URL slight using Drafts’ template engine’s built-in ability to do URL encoding with {{ }} curly braces, like:

anki://x-callback-url/addnote?profile={{User 1}}&type=Basic&deck={{Stock Market Learning}}&fldFront=[[title]]&fldBack=[[body]]

To clarify what is happening here…

The value is a template for a URL. When Drafts runs the action, it runs that template through it’s template engine, and substitutes values. The [[body]], [[title]] are template tags and Drafts replaces those values with the appropriate text from your draft.

In the case of URL action steps, if you have the “Encode tags” option on (the default), Drafts will also automatically URL encode the text when substituting those tag values, so they are all ready and valid to be a parameter in a URL.

You also have included some static parameter values in your URL (“Stock Market Learning”, “User 1”) which have characters which need to be URL encoded. You can manually encode those values, or the template engine has a special syntax using double curly braces, that will encode the value in the braces (removing the braces in the process), so {{User 1}} will become User%201 in the resulting URL.

There is also another slightly easier way to manage this that keeps the URL from getting too complicated, which is to use the Define Template Tag action step to define the values you need to include in your URL. In this example you might have a define template tag step with the tag name “deck”, and the template “Stock Market Learning” - then in the URL template you can use [[deck]] instead of deck={{Stock Market Learning}}

The action looks like this, I copied something wrong earlier, I’m sorry


Regarding this error, this would be a bug in Anki’s x-callback-url implementation, because the x-cancel parameter is a standard parameter in the spec - which Anki should just ignore if it is not using it.

Drafts adds these standard callback parameters use a Callback URL action step.

To workaround, if you do not need to return to Drafts after creating the card in Anki, you could use the same URL template in an Open URL action step instead of a Callback URL step and Drafts will not add that x-cancel parameter.

The open URL did the trick. Many Thanks

If I want to add tags, what should I add, as in tags=

As I described above, you might use a Prompt step in your action. Then you would be prompted to type in some tags. Your URL would then look like this:


If want to add tags to the Draft text itself, then you need to be able to tell the action step how to find that text. You can use the template tags to specify certain lines in the URL above. E.g.,


This says: front of card is the first line, tags are the second line, back of the card is lines 3 to the end.

It might seem obvious to just add tags to the Draft itself and then add [[tags]] to the URL, but I think that will cause problems. Drafts sends tags as " Comma-separated list of tags linked to the draft." but Anki wants tags as words with spaces in between.

Many thanks, I really appreciate all the help. There is a lot to unpack in what you’ve just sent about tagging. So, I’ll play around with it and revert.

I used the first option with the [[prompt tags]]. It adds the note with a tag that says [[prompt tags]]. I added the tags one line after the body, this time it add as the tag to the body and the tag that gets added is called [[prompt_tags]]

I’m sorry I’m not following what you’ve done. If you want to use a prompt, you need to create a prompt step in your action. Have you done that?

And if you want to add tags to a specific line of the draft, you need to use the [[line|2]] template tag, not the [[prompt_text]] template tag.

Yes, I’ll copy and paste the action here.


I am following the first method that you suggested, the second one involves line numbers, so I found this easier

I tried it with both the Open URL and the callback url