# API access to Intervals.icu

**URL:** <https://forum.intervals.icu/t/api-access-to-intervals-icu/609>\
**Category:** Guide\
**Created:** [1 April 2020 16:18 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609 "2020-04-01T16:18:59Z")\
**Posts on this page:** 20\
**Page:** 18

<div class="post-metadata">

**Author:** ![Someone\_Else](https://forum.intervals.icu/user_avatar/forum.intervals.icu/someone_else/32/33978_2.png) [@Someone\_Else](https://forum.intervals.icu/u/Someone_Else)\
**Post date:** [19 December 2023 14:02 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/345 "2023-12-19T14:02:16Z")

</div>

Hi,  
I would like to create a training plan and import to the plan workout files (zwo format) which I have locally. How can I do that?  
I can do that on UI, but can’t find any API which can import the file straight into the training plan.  
There is `/api/v1/athlete/{id}/folders/{folderId}/import-workout` but seems it can’t assign workout on particular day in the training plan.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [19 December 2023 15:01 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/346 "2023-12-19T15:01:24Z")

</div>

You can use this endpoint:

```
POST /api/v1/athlete/{id}/workouts

```

Create a new workout in a folder in the athlete’s workout library. The folder\_id is the plan. Put the zwo in “file\_contents”. Use “day” to specify the day relative to the start of the plan.

This is one of the ones I am trying to sort out the schema for so the Swagger docs aren’t great.

---

<div class="post-metadata">

**Author:** ![Someone\_Else](https://forum.intervals.icu/user_avatar/forum.intervals.icu/someone_else/32/33978_2.png) [@Someone\_Else](https://forum.intervals.icu/u/Someone_Else)\
**Post date:** [19 December 2023 16:02 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/347 "2023-12-19T16:02:57Z")

</div>

Perfect, works nicely, thank you.

---

<div class="post-metadata">

**Author:** ![Tushar\_Bhangale](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@Tushar\_Bhangale](https://forum.intervals.icu/u/Tushar_Bhangale)\
**Post date:** [20 December 2023 12:10 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/348 "2023-12-20T12:10:46Z")

</div>

Wondering if someone can help me figure out where I can get the details for OAuth flow. For now Basic auth works well for me, but I wanted to try Oauth once as the app I am connecting the API to has just API key in the inputs for basic auth. So I think that won’t work unless we have username there which doesn’t have any provision to do so.

 ![Screenshot 2023-12-20 173614](https://forum.intervals.icu/uploads/default/original/3X/9/8/987f1ebf867d38479d455ea841a14e5da3736172.png)

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [20 December 2023 14:31 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/349 "2023-12-20T14:31:47Z")

</div>

The OAuth info is here:

> [@Intervals.icu OAuth support](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759):
>
> Intervals.icu uses OAuth2 for authentication to the API. OAuth allows external applications to request authorization to access an Intervals.icu user’s data. It allows users to grant and revoke API access on a per-application basis and keeps user authentication details safe. Creating An Application Please mail the following info to david@intervals.icu: App name Description Website URL Logo image URL (square, at least 128x128) Privacy policy URL Redirect URI’s ([http://localhost/](http://localhost/) is always allow…

---

<div class="post-metadata">

**Author:** ![Tushar\_Bhangale](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@Tushar\_Bhangale](https://forum.intervals.icu/u/Tushar_Bhangale)\
**Post date:** [20 December 2023 15:47 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/350 "2023-12-20T15:47:20Z")

</div>

thanks David.

---

<div class="post-metadata">

**Author:** ![Reseal3754](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/r/8baadc/32.png) [@Reseal3754](https://forum.intervals.icu/u/Reseal3754)\
**Post date:** [24 December 2023 03:01 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/351 "2023-12-24T03:01:31Z")

</div>

Hi I have two questions

– Is there anyway to filter the events for a given date range to only return rides? Or must I filter the API response?

– If I run the `GET /api/v1/athlete/{id}/events/{eventId}/download{ext}` endpoint that gives me exactly what I’m looking for, however is there a way to pull more than one eventId at a time, or need I design a method to first get a list of the eventId’s I’m interested in and then loop through the same api endpoint for each eventId and store it’s result?

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [24 December 2023 04:57 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/352 "2023-12-24T04:57:53Z")

</div>

Currently you need to filter the returned events yourself. You should try using this endpoint with the “ext” parameter: [get /api/v1/athlete/-id-/events](https://intervals.icu/api-docs.html#get-/api/v1/athlete/-id-/events)

- ext: Convert workouts to this format (zwo, mrc, erg or fit) and add workout\_filename and workout\_file\_base64 to workout object

Then you don’t have to download each one individually.

---

<div class="post-metadata">

**Author:** ![R\_S1](https://forum.intervals.icu/user_avatar/forum.intervals.icu/r_s1/32/27267_2.png) [@R\_S1](https://forum.intervals.icu/u/R_S1)\
**Post date:** [27 December 2023 21:27 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/353 "2023-12-27T21:27:46Z")

</div>

Hey Andrii ! In your script work , Still works? I have trouble for pull Wellness data.

---

<div class="post-metadata">

**Author:** ![stefcameron](https://forum.intervals.icu/user_avatar/forum.intervals.icu/stefcameron/32/63405_2.png) [@stefcameron](https://forum.intervals.icu/u/stefcameron)\
**Post date:** [29 December 2023 16:44 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/354 "2023-12-29T16:44:47Z")

</div>

I’m new to intervals.icu and checking things out. I love that there’s an API, but I can’t make any requests due to 500-status errors, {“status”:500,“error”:“java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at 48”}

I believe (per [1]) that this may have something to do with the server-side base64 decoding (or perhaps encoding on my end) of the basic auth string in the authorization header.

I tried the “try” button on [Intervals.icu API docs](https://intervals.icu/api-docs.html#get-/api/v1/athlete/-id-/activities) as well as the suggested CURL command. Both fail (same error) with the base64 string generated by the API docs system.

I also tried encoding the basic auth string myself with Node (`Buffer.from('username:password').toString('base64')`) and then making a CURL request, but still the same issue.

Am I doing something wrong in the encoding?

[1] [java - Input byte array has incorrect ending byte at 40 - Stack Overflow](https://stackoverflow.com/questions/35292836/input-byte-array-has-incorrect-ending-byte-at-40)

---

<div class="post-metadata">

**Author:** ![stefcameron](https://forum.intervals.icu/user_avatar/forum.intervals.icu/stefcameron/32/63405_2.png) [@stefcameron](https://forum.intervals.icu/u/stefcameron)\
**Post date:** [30 December 2023 21:38 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/355 "2023-12-30T21:38:38Z")

</div>

I found the solution in this other post I created: [Can't make any API requests due to 500 error - input byte array has incorrect ending byte - #3 by stefcameron](https://forum.intervals.icu/t/cant-make-any-api-requests-due-to-500-error-input-byte-array-has-incorrect-ending-byte/56412/3)

---

<div class="post-metadata">

**Author:** ![Someone\_Else](https://forum.intervals.icu/user_avatar/forum.intervals.icu/someone_else/32/33978_2.png) [@Someone\_Else](https://forum.intervals.icu/u/Someone_Else)\
**Post date:** [1 January 2024 13:35 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/356 "2024-01-01T13:35:28Z")

</div>

It turns out ZWO format is pretty limited. I’m thinking to import workouts by using FIT files.  
Is it possible to import and plan FIT workout the same as ZWO with just one REST request?

---

<div class="post-metadata">

**Author:** ![Marc](https://forum.intervals.icu/user_avatar/forum.intervals.icu/marc/32/30522_2.png) [@Marc](https://forum.intervals.icu/u/Marc)\
**Post date:** [1 January 2024 20:00 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/357 "2024-01-01T20:00:54Z")

</div>

Hi @david, could we add the following fields to the wellness endpoints? Body Mass Index (BMI), and Active and Resting Energy.

---

<div class="post-metadata">

**Author:** ![MedTechCD](https://forum.intervals.icu/user_avatar/forum.intervals.icu/medtechcd/32/40383_2.png) [@MedTechCD](https://forum.intervals.icu/u/MedTechCD)\
**Post date:** [1 January 2024 21:49 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/358 "2024-01-01T21:49:57Z")

</div>

All of those are already created and shared by other users. Click on the looking glass at the bottom of the wellness fields dialog and add them to your profile  
You can immediately acces them through the API for reading and writing.

 ![image](https://forum.intervals.icu/uploads/default/original/3X/9/a/9a2bf553441d32c544f26507ad68158231e66c0c.png) ![image](https://forum.intervals.icu/uploads/default/original/3X/9/d/9db372e8561dff673fce3ce07687672c2ff3d2da.png) ![image](https://forum.intervals.icu/uploads/default/original/3X/e/4/e476304d089db2fd7aabfce5a922228573fe93a9.png)

---

<div class="post-metadata">

**Author:** ![Marc](https://forum.intervals.icu/user_avatar/forum.intervals.icu/marc/32/30522_2.png) [@Marc](https://forum.intervals.icu/u/Marc)\
**Post date:** [2 January 2024 04:12 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/359 "2024-01-02T04:12:51Z")

</div>

Thanks @MedTechCD , I did see those, but I didn’t know adding them would allow API read and write access, as they’re not currently part of the schema. They’re pretty common, should be added by default, so apps like HealthFit can update them automatically?

---

<div class="post-metadata">

**Author:** ![MedTechCD](https://forum.intervals.icu/user_avatar/forum.intervals.icu/medtechcd/32/40383_2.png) [@MedTechCD](https://forum.intervals.icu/u/MedTechCD)\
**Post date:** [2 January 2024 10:47 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/360 "2024-01-02T10:47:05Z")

</div>

‘Automatically’ is doomed to fail if you have different sources.  
The reason is that the field names are not standardized. HealthFit may use B.M.I. while Garmin or others may use BodyMassIndex or similar. You will always need a mapper between the source and the destination.

Example: if HealthFit uses B.M.I., the mapper for HealthFit has to make a connection to the correct field in Intervals that may be named BMI. The mapper for Garmin would then need to link BodyMassIndex to the same BMI field.

Intervals is very versatile and tries to connect with any other platform that has a way of exporting data. Be it file-based, API based, connection initiated by the sending or requesting platform… etc

---

<div class="post-metadata">

**Author:** ![Marc](https://forum.intervals.icu/user_avatar/forum.intervals.icu/marc/32/30522_2.png) [@Marc](https://forum.intervals.icu/u/Marc)\
**Post date:** [2 January 2024 22:37 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/361 "2024-01-02T22:37:07Z")

</div>

> [@MedTechCD](#):
>
> ‘Automatically’ is doomed to fail if you have different sources.  
> The reason is that the field names are not standardized. HealthFit may use B.M.I. while Garmin or others may use BodyMassIndex or similar. You will always need a mapper between the source and the destiny.

Sure, yeah. If there’s no standard naming convention for health/wellness metrics, then the source that decides to integrate with intervals will need to perform the mapping before updating the data via the API. But, isn’t this already happening for the existing fields in the schema, though? I’m not sure I understand why adding BMI, ActiveEnergy, and RestingEnergy would change any of that.

When you said “You can immediately access them through the API for reading and writing.”, I suspect that’s only for the athlete that has decided to add that particular field not _all_ athletes, correct? If so, then how do you convince sources that decide to integrate with intervals to make the appropriate changes on their side to update it. If I were them, I’d only do it if that field was in the schema for _all_ the athletes.

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [2 January 2024 23:27 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/362 "2024-01-02T23:27:32Z")

</div>

due to the extensive configurability of intervals the the number of users who either don’t use the pre-defined fields (and create their own private versions) this will come as a challenge to any software developer to support. (This is also the case for Garmin’s Connect IQ Developer fields where developers has free rein to name Power as Power1, Power2, myPower, MyAwesomePower etc.. and then users in Intervals.icu will need to do the mapping themselves to pick up these fields)

Having said that, I do believe that a software developer can do their own mapping to a defined intervals.icu field and update that.

> [@Marc](#):
>
> how do you convince sources that decide to integrate with intervals to make the appropriate changes on their side to update it

I believe Marco (HRV4Training) has previously stated that he should have decided to only integrate with dropbox due to this situation.

---

<div class="post-metadata">

**Author:** ![johannesh83](https://forum.intervals.icu/user_avatar/forum.intervals.icu/johannesh83/32/28688_2.png) [@johannesh83](https://forum.intervals.icu/u/johannesh83)\
**Post date:** [3 January 2024 11:26 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/363 "2024-01-03T11:26:22Z")

</div>

Hello David,

I am not that sure if I ran into a rate limit today. I am running a gscript to update the LTHR with specific values. Are there any limitation to consider?

many thanks,  
Johannes

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [3 January 2024 11:32 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/364 "2024-01-03T11:32:57Z")

</div>

If you got a 429 then you did hit a rate limit. Just slow down the calls a bit. But I am not seeing any 429s in the logs? Validation errors will return a 422. What error did you get?

> [@Someone\_Else](#):
>
> It turns out ZWO format is pretty limited. I’m thinking to import workouts by using FIT files.  
> Is it possible to import and plan FIT workout the same as ZWO with just one REST request?

Yes it is. Use this endpoint: [POST /api/v1/athlete/{id}/events](https://intervals.icu/api-docs.html#post-/api/v1/athlete/-id-/events)

Include these in the payload:

```
"file_contents_base64": "string", // fit file contents
"filename": "string", // workout.fit or whatever

```

Along with the date etc..

[Previous page](https://forum.intervals.icu/t/api-access-to-intervals-icu/609.md?page=17)

[Next page](https://forum.intervals.icu/t/api-access-to-intervals-icu/609.md?page=19)
