{"openapi":"3.1.0","info":{"title":"PGYM agent API","version":"1.0.0","summary":"Read-only access to one PGYM user's own data, for that user's AI agent.","description":"Send a personal access token as `Authorization: Bearer pgym_pat_...`. The owner creates it in the app (Profile, Agent access) and picks its scopes.\n\nLimits: 60 requests a minute per token; lists are paginated at 50 with a cursor.\n\nAll weights are kilograms. All times are ISO 8601 in UTC. There is no write access.","license":{"name":"MIT","identifier":"MIT"}},"servers":[{"url":"https://{apiDomain}","variables":{"apiDomain":{"default":"api.example.com","description":"The PGYM API host."}}}],"tags":[{"name":"v1","description":"Version 1, read-only."}],"paths":{"/v1/me":{"get":{"operationId":"getMe","summary":"The owner's profile","description":"Display name, units, time zone, weekly goal and gym days.\n\nScope: `read:profile`.","tags":["v1"],"security":[{"bearerAuth":["read:profile"]}],"x-required-scope":"read:profile","parameters":[],"responses":{"200":{"description":"The owner's profile","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Error"}}}},"/v1/stats":{"get":{"operationId":"getStats","summary":"Streak, counts and this week","description":"Streak, longest streak, pass weeks, proof count, stamped sessions this week against the goal, and total weight lifted.\n\nScope: `read:stats`.","tags":["v1"],"security":[{"bearerAuth":["read:stats"]}],"x-required-scope":"read:stats","parameters":[],"responses":{"200":{"description":"Streak, counts and this week","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Stats"}}}},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Error"}}}},"/v1/sessions":{"get":{"operationId":"listSessions","summary":"Sessions, newest first","description":"Finished and stamped sessions, 50 per page. Drafts are not listed.\n\nScope: `read:sessions`.","tags":["v1"],"security":[{"bearerAuth":["read:sessions"]}],"x-required-scope":"read:sessions","parameters":[{"name":"from","in":"query","required":false,"description":"`YYYY-MM-DD`, read in the owner's time zone. Inclusive.","schema":{"type":"string","format":"date","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"}},{"name":"to","in":"query","required":false,"description":"`YYYY-MM-DD`, read in the owner's time zone. Inclusive.","schema":{"type":"string","format":"date","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"}},{"name":"cursor","in":"query","required":false,"description":"`nextCursor` from the previous page.","schema":{"type":"string","minLength":1,"maxLength":512}}],"responses":{"200":{"description":"Sessions, newest first","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionList"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Error"}}}},"/v1/sessions/{id}":{"get":{"operationId":"getSession","summary":"One session with every set","description":"Structured workout data only. Local proof media and local AI insight are never exposed.\n\nScope: `read:sessions`.","tags":["v1"],"security":[{"bearerAuth":["read:sessions"]}],"x-required-scope":"read:sessions","parameters":[{"name":"id","in":"path","required":true,"description":"A document ID: letters, digits, `_` and `-`, at most 128 characters.","schema":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$"}}],"responses":{"200":{"description":"One session with every set","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionDetail"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Error"}}}},"/v1/exercises/{id}/history":{"get":{"operationId":"getExerciseHistory","summary":"One exercise over time","description":"Every done set of one exercise in stamped sessions, newest first, with the best set and the estimated one-rep max per session.\n\nScope: `read:sessions`.","tags":["v1"],"security":[{"bearerAuth":["read:sessions"]}],"x-required-scope":"read:sessions","parameters":[{"name":"id","in":"path","required":true,"description":"A document ID: letters, digits, `_` and `-`, at most 128 characters.","schema":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$"}},{"name":"from","in":"query","required":false,"description":"`YYYY-MM-DD`, read in the owner's time zone. Inclusive.","schema":{"type":"string","format":"date","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"}},{"name":"to","in":"query","required":false,"description":"`YYYY-MM-DD`, read in the owner's time zone. Inclusive.","schema":{"type":"string","format":"date","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"}},{"name":"cursor","in":"query","required":false,"description":"`nextCursor` from the previous page.","schema":{"type":"string","minLength":1,"maxLength":512}}],"responses":{"200":{"description":"One exercise over time","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExerciseHistory"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Error"}}}},"/v1/openapi.json":{"get":{"operationId":"getOpenApi","summary":"This document","description":"Needs no token.","tags":["v1"],"security":[],"responses":{"200":{"description":"The OpenAPI 3.1 description of this API.","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"pgym_pat_ followed by 40 letters and digits","description":"Scopes: `read:profile`, `read:sessions`, `read:stats`."}},"headers":{"X-RateLimit-Limit":{"description":"Requests allowed per minute for this token.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests left in the current minute.","schema":{"type":"integer"}}},"responses":{"Error":{"description":"An error. See `error.code`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"More than 60 requests in a minute. Code `rate_limited`.","headers":{"Retry-After":{"description":"Seconds to wait.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","enum":["invalid_request","invalid_token","insufficient_scope","not_found","method_not_allowed","rate_limited","server_error","unavailable"],"description":"Stable, machine-readable. Branch on this, not on `message`."},"message":{"type":"string"},"requiredScope":{"description":"Only on `insufficient_scope`.","type":"string","enum":["read:profile","read:sessions","read:stats"]}},"required":["code","message"]}},"required":["error"],"description":"Every error has this body."},"Me":{"type":"object","properties":{"displayName":{"type":["string","null"]},"units":{"type":"string","enum":["kg","lb"],"description":"For display only. Every weight in this API is in kilograms."},"timezone":{"type":"string","description":"IANA time zone. Weeks and query dates are read in it."},"goalPerWeek":{"type":"integer","minimum":2,"maximum":6,"description":"Sessions per week for the current week. A change applies from the next Monday."},"gymDays":{"type":"array","items":{"type":"string","enum":["mon","tue","wed","thu","fri","sat","sun"]}}},"required":["displayName","units","timezone","goalPerWeek","gymDays"]},"Stats":{"type":"object","properties":{"streakWeeks":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"longestStreak":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"passWeeks":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"proofCount":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"thisWeek":{"type":"object","properties":{"weekKey":{"type":"string","pattern":"^\\d{4}-W\\d{2}$","description":"ISO week, for example `2026-W46`.","example":"2026-W46"},"sessions":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991,"description":"Stamped sessions this week."},"goal":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["weekKey","sessions","goal"]},"totalVolumeKg":{"type":"number","description":"All-time weight x reps over working sets of stamped sessions."}},"required":["streakWeeks","longestStreak","passWeeks","proofCount","thisWeek","totalVolumeKg"]},"SessionList":{"type":"object","properties":{"sessions":{"maxItems":50,"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$","description":"A document ID: letters, digits, `_` and `-`, at most 128 characters."},"status":{"type":"string","enum":["finished","stamped"],"description":"`stamped` sessions have a photo, a server timestamp and a proof number, and count toward the week. `finished` ones do not."},"routineName":{"type":["string","null"]},"startedAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$","description":"ISO 8601 in UTC."},"durationSec":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"timezone":{"type":["string","null"]},"weekKey":{"anyOf":[{"type":"string","pattern":"^\\d{4}-W\\d{2}$","description":"ISO week, for example `2026-W46`.","example":"2026-W46"},{"type":"null"}]},"setCount":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"totalVolumeKg":{"type":"number","description":"Kilograms."},"proofNumber":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","status","routineName","startedAt","durationSec","timezone","weekKey","setCount","totalVolumeKg","proofNumber"]}},"nextCursor":{"description":"Pass as `cursor` to get the next page. `null` on the last page.","type":["string","null"]}},"required":["sessions","nextCursor"]},"SessionDetail":{"type":"object","properties":{"id":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$","description":"A document ID: letters, digits, `_` and `-`, at most 128 characters."},"status":{"type":"string","enum":["finished","stamped"],"description":"`stamped` sessions have a photo, a server timestamp and a proof number, and count toward the week. `finished` ones do not."},"routineId":{"type":["string","null"]},"routineName":{"type":["string","null"]},"startedAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$","description":"ISO 8601 in UTC."},"endedAt":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$","description":"ISO 8601 in UTC."},{"type":"null"}]},"stampedAt":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$","description":"ISO 8601 in UTC."},{"type":"null"}],"description":"Set by the server when the proof was stamped."},"durationSec":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"timezone":{"type":["string","null"]},"weekKey":{"anyOf":[{"type":"string","pattern":"^\\d{4}-W\\d{2}$","description":"ISO week, for example `2026-W46`.","example":"2026-W46"},{"type":"null"}]},"proofNumber":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"exercises":{"type":"array","items":{"type":"object","properties":{"exerciseId":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$","description":"A document ID: letters, digits, `_` and `-`, at most 128 characters."},"name":{"type":["string","null"]},"sets":{"type":"array","items":{"type":"object","properties":{"n":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"type":{"description":"`working`, `warmup`, `drop` or `failure`.","type":["string","null"]},"weightKg":{"anyOf":[{"type":"number","description":"Kilograms."},{"type":"null"}]},"reps":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"done":{"type":"boolean"},"rpe":{"type":["number","null"]}},"required":["n","type","weightKg","reps","done","rpe"]}}},"required":["exerciseId","name","sets"]}},"setCount":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"totalVolumeKg":{"type":"number","description":"Kilograms."},"newBests":{"type":"array","items":{"type":"string"}}},"required":["id","status","routineId","routineName","startedAt","endedAt","stampedAt","durationSec","timezone","weekKey","proofNumber","exercises","setCount","totalVolumeKg","newBests"]},"ExerciseHistory":{"type":"object","properties":{"exerciseId":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$","description":"A document ID: letters, digits, `_` and `-`, at most 128 characters."},"name":{"type":["string","null"]},"bestSet":{"anyOf":[{"type":"object","properties":{"weightKg":{"type":"number","description":"Kilograms."},"reps":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["weightKg","reps"]},{"type":"null"}],"description":"The set with the highest estimated one-rep max."},"bestE1rmKg":{"type":"number","description":"Epley: weight x (1 + reps / 30)."},"lastPerformedAt":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$","description":"ISO 8601 in UTC."},{"type":"null"}]},"history":{"maxItems":50,"type":"array","items":{"type":"object","properties":{"sessionId":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$","description":"A document ID: letters, digits, `_` and `-`, at most 128 characters."},"startedAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$","description":"ISO 8601 in UTC."},"e1rmKg":{"type":"number","description":"Best estimated one-rep max in this session, working sets only."},"sets":{"type":"array","items":{"type":"object","properties":{"type":{"type":["string","null"]},"weightKg":{"type":"number","description":"Kilograms."},"reps":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["type","weightKg","reps"]}}},"required":["sessionId","startedAt","e1rmKg","sets"]},"description":"Newest first. A page can hold fewer than 50 items while `nextCursor` is not null."},"nextCursor":{"description":"Pass as `cursor` to get the next page. `null` on the last page.","type":["string","null"]}},"required":["exerciseId","name","bestSet","bestE1rmKg","lastPerformedAt","history","nextCursor"]}}}}