I’m adding to my little set of Python scripts, this time with something to create new goals. In particular, I want to make it as easy as possible to set goals with a deadline - so to create goals that just run for a month, for example.
So far, so good. But I wanted to be able to create goals to run for next month, and to do that now - which means creating a goal with initial leeway: for example, if I’m creating a goal for next month, and that’s 10 days away, I want to have 10 days of leeway on the new goal before the slope takes effect.
This is straightforward to do this via the web pages, but I can’t see a parameter to set the starting leeway in the Create Goal API docs. Am I just not able to spot it, is there something missing from the docs, or is it just not possible via the API?
Thanks for the clue! I was able to search the code base for buffer_days, and it does look like it should work. Now I’ll actually try it out in my Python scripts when I get a moment, and report back!
Hey, have you checked the API docs for a parameter to set starting leeway? If not, it might be worth reaching out to support or the community for advice. As a workaround, recalculating the start date could do the trick for now.
Thanks - @zzq was correct, there is an undocumented parameter ‘buffer_days’ that you can pass to the create goal API, and that sets up initial leeway.
Interesting side note: using the create goal API, if you pass a rate, by default it’s interpreted as a rate per week, rather than per day, which is what I’d expect. So if you pass a rate of 1, that’s set up as 0.141 per day. You need to use another undocumented parameter, “runits”, and set runits to ‘d’ for the rate to be per-day. You can also use ‘w’ for weekly, or ‘m’ for monthly and ‘y’ for yearly.