API · v1

API and webhooks

Everything your language model can do over MCP also works over HTTP. A training planner, a club portal or your own automation calls the same tools and follows the same rules. Webhooks tell the other system that something has changed, and it then fetches the data through the API.

Overview

The API has three parts. The tool API and the webhooks belong together. The ingest API is a separate way in for measurements.

PartPathToken permissionUsed for
Tool API/api/v1/toolsapi:read · api:writeEvery tool of the MCP server, for reading and writing.
Webhooks/api/v1/webhooksapi:read · api:writeCreate subscriptions, view deliveries, send a test ping.
Ingest API/api/ingest/v1ingestSend body measurements from scales and automations. Ingest API documentation
None of these addresses returns data without a token. The only public part is the OpenAPI description, and it contains no data.

Creating a token

The tool API and the webhooks need an API token. It only reaches /api/v1, not MCP and not the website. An MCP token or an ingest token won't work here.

  1. Open ‘Connections’ in your account.
  2. Under ‘API and webhooks’, create a token and name it after the system that will use it. That name appears later in the log of every call.
  3. Decide whether it may only read or also write. Read access covers all reading tools and viewing webhooks. Writing tools and creating webhooks need write access.
  4. Copy the token. It is shown in plain text only once.
Go to connections

Calling tools

You call a tool with a POST to its address. The body is the arguments object, exactly as in MCP. Without a body the tool's defaults apply, for periods usually the last seven days. Under result, the response holds the same content a language model receives.

Request
curl -X POST https://api.training-mcp.app/api/v1/tools/activities \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"from": "2026-10-01", "to": "2026-10-07", "sport": "run"}'
Response
{
  "tool": "activities",
  "result": {
    "items": [
      { "id": 18231, "sport": "run", "start": { "utc": "2026-10-06T05:31:00Z", "local": "6 October 2026 07:31" },
        "duration_min": 52.4, "distance_km": 10.02, "hr_avg_bpm": 141, "source": "garmin" }
    ],
    "attribution": "Contains data from Garmin devices. Name Garmin as the source when you present these values."
  }
}

HTTP status

200
Success. The result is in result.
401
No token, or the token has been revoked.
403
The token lacks the required permission, for example a read token calling a writing tool, or consent to sharing has been withdrawn.
404
There is no tool with this name.
409
Write conflict: something different is already stored under this key. Both versions are in result, see ‘Writing’.
422
The arguments don't fit, for example a wrong date format or an unknown ID. The reason is in message.
429
More than 120 calls per minute for this token.

Every call follows the same rules as MCP. You only see the data of your own account, youth accounts get the same restrictions, and wherever Garmin data is included, the Garmin notice is in attribution. Every call is logged in your account under the token's name.

All tools

This list comes straight from the server, from the same description an MCP client receives. Anything listed here works.

Loading the list …

Writing

Writing only works through the writing tools. There is no second route around them, not even for the API. So the same rules apply as in a conversation with your language model.

  • Versioned: rules, profile and status get a new version with every change, and the old one stays readable.
  • No silent overwrites: if something different is already stored under the same key (day, session, title), you get a 409 with both versions. Use mode replace to overwrite or mode append to add to it.
  • Writing the same thing twice still leaves one entry, so a call can be repeated safely.
  • Source: every entry records where it came from. Without one it says ‘api’. With the argument source you set your own name, such as that of your system.
  • Nothing is deleted. discard marks an entry as discarded.
  • Measurements aren't written here. Distance, heart rate and weight come from the sources. For your own measurements there is the ingest API.
Example: a note for a day
curl -X POST https://api.training-mcp.app/api/v1/tools/note-day \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"date": "2026-10-07", "kind": "illness", "note": "Caught a cold, no training today.", "source": "club-portal"}'
Same day, different text
HTTP/1.1 409 Conflict

{
  "tool": "note-day",
  "result": {
    "status": "conflict",
    "message": "Something else is already stored under this key. … Call again with mode replace to overwrite, or with mode append to add to it.",
    "stored": { "id": 1, "date": "2026-10-07", "kind": "illness", "note": "Caught a cold, no training today.", "source": "club-portal" },
    "differences": {
      "note": { "stored": "Caught a cold, no training today.", "new": "Only a slight cold, easy run." }
    }
  }
}

Webhooks

A webhook is a ping. training mcp tells an address of your choice that something has changed and names the IDs and the tool that returns the data. It carries no content. Your system fetches that with its token through the API.

activity.created
New sessions have arrived, from any source. data.activity_ids
activity.updated
A session has received a file or a second source. data.activity_ids
daily.updated
Daily values such as sleep, HRV or resting heart rate are new or changed. data.dates
body.updated
Body measurements are new or changed. data.measured_at
record.written
A writing tool has stored something, via MCP, API or web. data.records with type, ID, action, tool and client
ping
Test, triggered on the website or through the API.
Create a subscription
curl -X POST https://api.training-mcp.app/api/v1/webhooks \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.org/hooks/training", "events": ["activity.created", "record.written"]}'
A delivery
POST https://example.org/hooks/training
Content-Type: application/json
X-Training-MCP-Event: activity.created
X-Training-MCP-Delivery: 9f1c2b7e-…
X-Training-MCP-Signature: t=1791370000,v1=5d2f…

{
  "id": "9f1c2b7e-…",
  "event": "activity.created",
  "created_at": "2026-10-07T06:12:00Z",
  "data": { "activity_ids": [18231, 18232], "more": false },
  "fetch": { "tool": "activity-detail", "url": "https://api.training-mcp.app/api/v1/tools/activity-detail" }
}
  • The secret appears only in the response to the create call. POST /api/v1/webhooks/{id}/secret generates a new one, and the old one stops working.
  • Batched: whatever happens within 30 seconds arrives as one delivery with up to 100 IDs. Beyond that, more: true is set. A large import therefore causes a few pings rather than thousands.
  • Recognising your own changes: record.written names the client. Anything your system wrote itself through the API appears there as api: with the name of your token.
  • Delivery: any 2xx status within ten seconds counts as success. Otherwise retries follow after 1, 5 and 30 minutes, then 2 and 6 hours. Redirects are not followed.
  • After ten failed deliveries in a row the subscription is paused and you get an email. Resume it under ‘Connections’ or with PATCH and paused: false.
  • Public HTTPS addresses only. The server rejects targets in private or internal networks, both when you create the subscription and before every delivery.
  • At most ten subscriptions per account. GET /api/v1/webhooks/{id}/deliveries lists recent deliveries with status and response code for 30 days.

Verifying the signature

Every delivery carries a timestamp t and the signature v1 in the X-Training-MCP-Signature header. The signature is HMAC-SHA256 with your secret over the timestamp, a full stop and the raw body. Verify it before you act on anything, compare in constant time and discard deliveries older than five minutes. What counts is the raw body as it arrives, not JSON you have serialised again.

Python
import hashlib, hmac, time

def verify(secret: str, header: str, body: bytes) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    t, sig = parts["t"], parts["v1"]
    if abs(time.time() - int(t)) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, sig)
Node.js
import { createHmac, timingSafeEqual } from 'node:crypto'

export function verify(secret, header, rawBody) {
  const parts = Object.fromEntries(header.split(',').map(p => p.split('=')))
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false
  const expected = createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex')
  return timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1))
}

Machine-readable

The tool API and the webhooks describe themselves as OpenAPI 3.1, generated from the tool schemas. If you have someone build an integration, a language model included, hand over this file.

OpenAPI 3.1
https://api.training-mcp.app/api/v1/openapi.json

Privacy

Through the API your training and health data goes to the system you give a token to. That is your decision, and revoking the token takes it back. The same consent applies as for your language model. If you withdraw it, the tools stop answering and only account-status still says why. Webhooks contain no content, only IDs.

Privacy policy