blog.cjcjameson.com · the COROS activity tool

Logging workouts to COROS from Telegram

I text my bot a workout and it shows up in COROS. COROS has no public upload API, so we read the web app's JavaScript to figure out how it uploads.

C.J. Jameson · November 2026 · built with Claude Code

soccer yesterday 6pm, 90 min

Soccer, Fri Nov 20, 6:00 PM PST, 90 min. About 900 kcal, HR steady around 143, peaks near 189. Upload?

yes

Done, it's in COROS. Training Load will fill in after COROS recomputes.

Background

coros.cjcjameson.com generates .fit files for workouts my watch didn't record, like a soccer game or a hike I forgot to start. It simulates per-second heart rate, and if you give it a GPX route it shapes the pace by grade. Then you import the file into COROS Training Hub by hand.

I already have a personal assistant bot on Telegram (it runs in AWS Lambda), so I wanted to skip the laptop and just text it.

Finding the API

COROS only offers its API to approved partners. But Training Hub is a single-page app, so its JavaScript is public and readable from the login screen.

The main bundle has the API paths as plain strings: /activity/query, /activity/update, /activity/fit/import. The upload code is in one of 253 lazy-loaded chunks. Grepping them turned up the one that bundles the AWS S3 SDK, so the browser uploads to S3 directly with temporary credentials and then tells COROS where the file is.

The upload flow

  1. POST teamapi.coros.com/account/login Email and an MD5 of the password. Returns an access token, your user ID, and your heart-rate profile, which the generator uses for realistic HR.
  2. GET t.coros.com/api/proxy/oss/sts Cookie-authenticated with that token. Returns short-lived AWS credentials for COROS's upload bucket, base64-encoded with a fixed junk string spliced in.
  3. PUT s3://<coros bucket>/fit_zip/<userId>/<md5>.zip The FIT file, zipped the same way the web app does it.
  4. POST teamapi.coros.com/activity/fit/import One form field, jsonParameter, with the bucket, object key, md5, size, filename and timezone.

The timezone is in 15-minute units, so Pacific Standard Time is -32. Places like Nepal (UTC+5:45) need the finer grain. The upload code also has a branch for Alibaba Cloud OSS, for accounts in China.

How it runs

The command-line version prints each request as it goes:

$ coros_api.py upload test-walk.fit
  → POST teamapi.coros.com/account/login
  → GET t.coros.com/api/proxy/oss/sts
  → PUT s3://coros-s3/fit_zip/…/ab94…59c6.zip
  → POST teamapi.coros.com/activity/fit/import
✅ COROS accepted the import

Imports always show up as runs, and Training Load fills in a while later once COROS recomputes. That's just how COROS treats imported files.

One surprise: COROS allows one live login per account. When I tested from my laptop while the bot was mid-upload, my login knocked out the bot's token, and it reported a failure for an upload that had actually gone through. Now it logs in again once if that happens, and it can't call an upload failed after COROS has accepted it.

Editing what's already there

Renaming is one call, POST /activity/update with the activity's ID and a new name. It's the same request the rename box on the activity page sends. It's reversible, so the bot renames anything without asking first and tells me the old name.

Fixing a recording is harder, because Training Hub can't edit distance, time or heart rate. My case was a treadmill run the watch recorded as an outdoor run: the heart rate was right, but GPS said I'd covered 0.27 miles in 26 minutes. The fix:

  1. Download the original FIT (/activity/detail/download, the same thing the Export button uses) and keep it as a backup.
  2. Keep every second of heart rate and cadence. Drop the GPS.
  3. Rebuild speed, distance and altitude from the treadmill settings: 6.2 mph at 1% incline.
  4. Use cadence to tell running from walking and stopping. My watch showed a 44-second stop at 8:22 when the machine hiccupped. The cooldown, walked holding the rails, reads as no steps at all, so the bot can be told "25:20 to the end was 3 mph".
  5. Encode it with the website's FIT encoder (now with a mode for "these exact records, altitude but no GPS") and upload.

The preview for that run came out at 2.59 miles and 137 feet of climb, with my real heart rate throughout. The bot never deletes the original recording. I do that myself in the app once the new one looks right.

Working with the agent

Claude Code did most of the digging. It wouldn't type my password into the COROS site even when I said it could, so it read the public JavaScript instead, which turned out to be enough. It's an unofficial API and could break whenever COROS ships a new web app, but it's my account and my data, and for now it works.

Next

Telling the bot how my heart rate actually behaves. My swims run easier than the generator assumes, so I'd like it to remember that per activity.