# Using API to create goals with leeway

**URL:** <https://forum.beeminder.com/t/using-api-to-create-goals-with-leeway/11500>\
**Category:** Tech\
**Created:** [March 19, 2024, 9:10am UTC](https://forum.beeminder.com/t/using-api-to-create-goals-with-leeway/11500 "2024-03-19T09:10:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![clivemeister](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/clivemeister/32/2034_2.png) [@clivemeister](https://forum.beeminder.com/u/clivemeister)\
**Post date:** [March 19, 2024, 9:10am UTC](https://forum.beeminder.com/t/using-api-to-create-goals-with-leeway/11500/1 "2024-03-19T09:10:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![zzq](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/zzq/32/6471_2.png) [@zzq](https://forum.beeminder.com/u/zzq)\
**Post date:** [March 19, 2024, 12:14pm UTC](https://forum.beeminder.com/t/using-api-to-create-goals-with-leeway/11500/2 "2024-03-19T12:14:20Z")

</div>

Searching the forum, I found that two years ago I wrote this in response to a similar question:

> [@API - Days Until Progress Parameter?](https://forum.beeminder.com/t/api-days-until-progress-parameter/10207/2):
>
> I believe that parameter is called buffer\_days, though I don’t see it documented in the API docs. Nevertheless, I’m pretty sure you can pass it as a parameter to the goal creation API (but perhaps it being undocumented is meant as a hint not to use it, for some reason, not just an accidental omission? Not sure.)

I don’t know if that information is still up to date, but it’s worth trying.

---

<div class="post-metadata">

**Author:** ![clivemeister](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/clivemeister/32/2034_2.png) [@clivemeister](https://forum.beeminder.com/u/clivemeister)\
**Post date:** [March 19, 2024, 5:39pm UTC](https://forum.beeminder.com/t/using-api-to-create-goals-with-leeway/11500/3 "2024-03-19T17:39:07Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![galius](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@galius](https://forum.beeminder.com/u/galius)\
**Post date:** [March 26, 2024, 4:53pm UTC](https://forum.beeminder.com/t/using-api-to-create-goals-with-leeway/11500/4 "2024-03-26T16:53:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![clivemeister](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/clivemeister/32/2034_2.png) [@clivemeister](https://forum.beeminder.com/u/clivemeister)\
**Post date:** [March 27, 2024, 11:46am UTC](https://forum.beeminder.com/t/using-api-to-create-goals-with-leeway/11500/5 "2024-03-27T11:46:18Z")

</div>

Thanks - @zzq was correct, there is an undocumented parameter ‘buffer\_days’ that you can pass to the [create goal](http://api.beeminder.com/#creategoal) 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.
