Record a weigh-in

POST/api/public/trainees/{traineeId}/body-metrics

Record a weigh-in for a trainee: weight, body fat, and/or body measurements. This is the only way to write weight through the API, because weight is kept as a dated history rather than a single field: the previous value is moved into the history and the new one becomes current. PATCH /trainees/{traineeId} therefore does NOT accept weight.

Every field is optional, but send at least one. Send only what was actually measured; omitted fields are left untouched, and each measurement field keeps its own dated history. Measurements are in cm, weight in kg, bodyFat in percent.

Authentication

Requires an API key, sent as Authorization: Bearer cp_live_....

API keys carry scopes. Get the catalog of scopes and webhook events lists every scope.

Path parameters

Path parameters
NameTypeDescription
traineeIdrequiredstring

Header parameters

Header parameters
NameTypeDescription
Idempotency-Keystring

Optional. Send a unique key (e.g. a UUID) to make this POST safe to retry. The same key within 24h returns the original result instead of creating a duplicate.

Request body

application/json, required

Request body fields
NameTypeDescription
weightnumber

Body weight in kg. Becomes the current weight; the previous one is pushed onto the weight history.

Minimum: 0

bodyFatnumber

Body fat percentage. Kept as a dated history, exactly like weight.

Minimum: 0

datestring

ISO date this measurement was taken. Defaults to now. Use it to backfill an earlier weigh-in.

chestnumber

chest in cm.

Minimum: 0

waistnumber

waist in cm.

Minimum: 0

rightArmnumber

rightArm in cm.

Minimum: 0

leftArmnumber

leftArm in cm.

Minimum: 0

rightThighnumber

rightThigh in cm.

Minimum: 0

leftThighnumber

leftThigh in cm.

Minimum: 0

rightCalfnumber

rightCalf in cm.

Minimum: 0

leftCalfnumber

leftCalf in cm.

Minimum: 0

necknumber

neck in cm.

Minimum: 0

buttnumber

butt in cm.

Minimum: 0

navelnumber

navel in cm.

Minimum: 0

lowerAbdomennumber

lowerAbdomen in cm.

Minimum: 0

upperAbdomennumber

upperAbdomen in cm.

Minimum: 0

upperHipnumber

upperHip in cm.

Minimum: 0

lowerHipnumber

lowerHip in cm.

Minimum: 0

Request examples

cURL
curl --request POST \
  --url 'https://api.coach-platform.com/api/public/trainees/<traineeId>/body-metrics' \
  --header 'Authorization: Bearer cp_live_...' \
  --header 'Content-Type: application/json' \
  --data '{
  "weight": 123
}'
JavaScript (fetch)
const response = await fetch('https://api.coach-platform.com/api/public/trainees/<traineeId>/body-metrics', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer cp_live_...',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "weight": 123
  }),
});

const data = await response.json();

Responses

201 Created

Example body (application/json)
{
  "data": {
    "traineeId": "<string>",
    "date": "<date-time>",
    "weight": 123,
    "bodyFat": 123,
    "measurements": {}
  },
  "warnings": [
    {
      "field": "<string>",
      "message": "<string>"
    }
  ]
}
Response fields (9)
Response fields
NameTypeDescription
dataobject
data.traineeIdstring
data.datestring<date-time>
data.weightnumber | null
data.bodyFatnumber | null
data.measurementsobject

The measurement fields recorded by this request, in cm.

warningsobject[]

Non-fatal problems with follow-up writes. The resource was created, but each listed field was not applied.

warnings[].fieldstring
warnings[].messagestring

Error responses

  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • 409 Conflict
  • 429 Too Many Requests
  • 500 Internal Server Error

These statuses share the same response body.

Example body (application/json)
{
  "error": {
    "code": "<string>",
    "message": "<string>",
    "fix": "<string>",
    "details": {},
    "retryAfterMs": 123
  }
}
Error fields (6)
Error fields
NameTypeDescription
errorobject
error.codestring
error.messagestring
error.fixstring | null
error.detailsobject | null
error.retryAfterMsnumber | null

This page is also available as Markdown. Browse it in the interactive explorer or download the OpenAPI spec.