{"openapi":"3.0.3","info":{"title":"Clieto Fit API","version":"1.0.0","description":"REST API for Clieto Fit web and mobile applications. Protected endpoints accept the web session cookie or a Bearer access token."},"servers":[{"url":"/","description":"Current API server"}],"tags":[{"name":"System","description":"Service status"},{"name":"Authentication","description":"Sign-in and session operations"},{"name":"Account","description":"Current account settings"},{"name":"Gym","description":"Current gym settings"},{"name":"Branding","description":"Gym logo operations"},{"name":"Portal","description":"Role-specific dashboard data"},{"name":"Platform","description":"Super-admin operations"},{"name":"Records","description":"Gym members and operational records"}],"paths":{"/api/health":{"get":{"tags":["System"],"summary":"Check API and database health","responses":{"200":{"description":"API and database are available.","content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["ok"]}}}}}},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/auth/login":{"post":{"tags":["Authentication"],"summary":"Sign in to a portal","description":"Use client=mobile to receive a Bearer token for Swagger's Authorize button. The default client=web creates an HTTP-only session cookie.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}}},"responses":{"200":{"description":"Sign-in succeeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"429":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/auth/logout":{"post":{"tags":["Authentication"],"summary":"End the current session","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"responses":{"200":{"description":"Session ended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"403":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/auth/me":{"get":{"tags":["Authentication"],"summary":"Get the signed-in user","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"responses":{"200":{"description":"Current user.","content":{"application/json":{"schema":{"type":"object","required":["user"],"properties":{"user":{"$ref":"#/components/schemas/Principal"}}}}}},"401":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/account":{"patch":{"tags":["Account"],"summary":"Update the current account","description":"At least one of name or newPassword is required. Changing a password also requires currentPassword and revokes existing sessions.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountUpdate"}}}},"responses":{"200":{"description":"Account updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/gym":{"get":{"tags":["Gym"],"summary":"Get the current gym","description":"Available to gym administrators.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"responses":{"200":{"description":"Current gym.","content":{"application/json":{"schema":{"type":"object","required":["gym"],"properties":{"gym":{"$ref":"#/components/schemas/Gym"}}}}}},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}},"patch":{"tags":["Gym"],"summary":"Update the current gym","description":"Available to gym administrators.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GymUpdate"}}}},"responses":{"200":{"description":"Gym updated.","content":{"application/json":{"schema":{"type":"object","required":["gym"],"properties":{"gym":{"$ref":"#/components/schemas/Gym"}}}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/branding":{"put":{"tags":["Branding"],"summary":"Upload the current gym logo","description":"Available to gym administrators. Maximum file size is 2 MB.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["logo"],"properties":{"logo":{"type":"string","format":"binary","description":"PNG, JPEG, or WebP image, up to 2 MB."}}}}}},"responses":{"200":{"description":"Logo uploaded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrandingResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"413":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}},"delete":{"tags":["Branding"],"summary":"Remove the current gym logo","description":"Available to gym administrators.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"responses":{"200":{"description":"Logo removed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/branding/{gymId}":{"get":{"tags":["Branding"],"summary":"Get a gym logo","description":"Requires an authenticated user. Gym users may only access their own gym's logo; super administrators may access any gym.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"parameters":[{"name":"gymId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Logo image.","content":{"image/png":{"schema":{"type":"string","format":"binary"}},"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/webp":{"schema":{"type":"string","format":"binary"}}}},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/portal":{"get":{"tags":["Portal"],"summary":"Get role-specific dashboard data","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"responses":{"200":{"description":"Dashboard data for the current role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortalResponse"}}}},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/platform":{"get":{"tags":["Platform"],"summary":"Get platform administration data","description":"Available to super administrators.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"responses":{"200":{"description":"Platform data.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformResponse"}}}},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}},"post":{"tags":["Platform"],"summary":"Create a gym, account, or setting","description":"Available to super administrators. Select the payload by setting action to create-gym, create-account, or set-setting.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformCreateRequest"}}}},"responses":{"200":{"description":"Setting updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformSettingResponse"}}}},"201":{"description":"Gym or account created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformCreateResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"409":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}},"patch":{"tags":["Platform"],"summary":"Update a gym or account","description":"Available to super administrators.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformUpdateRequest"}}}},"responses":{"200":{"description":"Gym or account updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformUpdateResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/records/{resource}":{"get":{"tags":["Records"],"summary":"List records for a resource","description":"Resources: members, training, diets, attendance, fees, payments, offers, or equipment. Results are scoped to the signed-in user's gym and role.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"parameters":[{"$ref":"#/components/parameters/Resource"}],"responses":{"200":{"description":"Resource records.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordListResponse"}}}},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}},"post":{"tags":["Records"],"summary":"Create a resource record","description":"Attendance may be recorded by a member or administrator. Creating other resource types requires a gym administrator.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"parameters":[{"$ref":"#/components/parameters/Resource"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordCreateRequest"}}}},"responses":{"201":{"description":"Record created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"409":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}},"/api/records/{resource}/{id}":{"patch":{"tags":["Records"],"summary":"Update a resource record","description":"Available to gym administrators for members, training, diets, fees, payments, offers, and equipment.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"parameters":[{"$ref":"#/components/parameters/Resource"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordUpdateRequest"}}}},"responses":{"200":{"description":"Record updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"409":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}},"delete":{"tags":["Records"],"summary":"Delete a resource record","description":"Available to gym administrators for attendance, training, diets, fees, offers, and equipment.","security":[{"bearerAuth":[]},{"sessionCookie":[]}],"parameters":[{"$ref":"#/components/parameters/Resource"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Record deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"},"401":{"$ref":"#/components/responses/ApiError"},"403":{"$ref":"#/components/responses/ApiError"},"404":{"$ref":"#/components/responses/ApiError"},"500":{"$ref":"#/components/responses/ApiError"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Use the accessToken returned by POST /api/auth/login with client=mobile."},"sessionCookie":{"type":"apiKey","in":"cookie","name":"clieto_fit_session","description":"HTTP-only session cookie created by a web sign-in."}},"parameters":{"Resource":{"name":"resource","in":"path","required":true,"schema":{"type":"string","enum":["members","training","diets","attendance","fees","payments","offers","equipment"]}}},"responses":{"ApiError":{"description":"The request failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}},"schemas":{"ApiError":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"details":{"type":"array","items":{"type":"object","required":["path","message"],"properties":{"path":{"type":"string"},"message":{"type":"string"}}}}}},"OkResponse":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean","enum":[true]}}},"LoginRequest":{"type":"object","required":["email","password","portal"],"properties":{"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","minLength":1,"maxLength":128},"portal":{"type":"string","enum":["SUPER_ADMIN","ADMIN","USER"]},"client":{"type":"string","enum":["web","mobile"],"default":"web"}}},"LoginUser":{"type":"object","required":["id","name","email","role"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["SUPER_ADMIN","ADMIN","USER"]}}},"LoginResponse":{"oneOf":[{"type":"object","required":["user","redirectTo"],"properties":{"user":{"$ref":"#/components/schemas/LoginUser"},"redirectTo":{"type":"string","example":"/dashboard"}}},{"type":"object","required":["user","accessToken","tokenType","expiresAt"],"properties":{"user":{"$ref":"#/components/schemas/LoginUser"},"accessToken":{"type":"string"},"tokenType":{"type":"string","enum":["Bearer"]},"expiresAt":{"type":"string","format":"date-time"}}}]},"Principal":{"type":"object","required":["id","email","name","role","gymId","gymName","gymTimezone","feeId"],"properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"role":{"type":"string","enum":["SUPER_ADMIN","ADMIN","USER"]},"gymId":{"type":"string","nullable":true},"gymName":{"type":"string","nullable":true},"gymTimezone":{"type":"string","nullable":true},"feeId":{"type":"string","nullable":true}}},"AccountUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":100},"currentPassword":{"type":"string","minLength":1,"maxLength":128},"newPassword":{"type":"string","minLength":12,"maxLength":128}},"anyOf":[{"required":["name"]},{"required":["newPassword","currentPassword"]}]},"Gym":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"timezone":{"type":"string"},"logoUrl":{"type":"string","nullable":true},"status":{"type":"string","enum":["ACTIVE","SUSPENDED"]}}},"GymUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":100},"timezone":{"type":"string","minLength":1,"maxLength":80}},"anyOf":[{"required":["name"]},{"required":["timezone"]}]},"BrandingResponse":{"type":"object","required":["logoUrl"],"properties":{"logoUrl":{"type":"string"},"warning":{"type":"string"}}},"PortalResponse":{"type":"object","required":["user","metrics"],"properties":{"user":{"$ref":"#/components/schemas/Principal"},"gym":{"$ref":"#/components/schemas/Gym"},"metrics":{"type":"object","additionalProperties":true}}},"PlatformResponse":{"type":"object","required":["gyms","accounts","settings","audits"],"properties":{"gyms":{"type":"array","items":{"type":"object","additionalProperties":true}},"accounts":{"type":"array","items":{"type":"object","additionalProperties":true}},"settings":{"type":"array","items":{"type":"object","additionalProperties":true}},"audits":{"type":"array","items":{"type":"object","additionalProperties":true}}}},"PlatformCreateRequest":{"oneOf":[{"type":"object","required":["action","name","slug","timezone"],"properties":{"action":{"type":"string","enum":["create-gym"]},"name":{"type":"string","minLength":2,"maxLength":100},"slug":{"type":"string","pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$","maxLength":60},"timezone":{"type":"string","minLength":1,"maxLength":80}}},{"type":"object","required":["action","name","email","password","role","gymId"],"properties":{"action":{"type":"string","enum":["create-account"]},"name":{"type":"string","minLength":2,"maxLength":100},"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","minLength":12,"maxLength":128},"role":{"type":"string","enum":["ADMIN","USER"]},"gymId":{"type":"string","description":"Gym CUID."}}},{"type":"object","required":["action","key","value"],"properties":{"action":{"type":"string","enum":["set-setting"]},"key":{"type":"string","enum":["platform_name","support_email","maintenance_mode"]},"value":{"type":"string","description":"Setting value. maintenance_mode accepts only true or false."}}}]},"PlatformUpdateRequest":{"oneOf":[{"type":"object","required":["target","id"],"properties":{"target":{"type":"string","enum":["gym"]},"id":{"type":"string","description":"Gym CUID."},"name":{"type":"string","minLength":2,"maxLength":100},"timezone":{"type":"string","minLength":1,"maxLength":80},"status":{"type":"string","enum":["ACTIVE","SUSPENDED"]}},"anyOf":[{"required":["name"]},{"required":["timezone"]},{"required":["status"]}]},{"type":"object","required":["target","id"],"properties":{"target":{"type":"string","enum":["account"]},"id":{"type":"string","description":"Account CUID."},"status":{"type":"string","enum":["ACTIVE","SUSPENDED"]},"role":{"type":"string","enum":["ADMIN","USER"]}},"anyOf":[{"required":["status"]},{"required":["role"]}]}]},"PlatformCreateResponse":{"type":"object","additionalProperties":true,"description":"Contains either the created gym or account."},"PlatformSettingResponse":{"type":"object","required":["setting"],"properties":{"setting":{"type":"object","additionalProperties":true}}},"PlatformUpdateResponse":{"type":"object","description":"Contains the updated gym or account.","properties":{"gym":{"type":"object","additionalProperties":true},"account":{"type":"object","additionalProperties":true}}},"Record":{"type":"object","additionalProperties":true},"RecordListResponse":{"type":"object","required":["records"],"properties":{"records":{"type":"array","items":{"$ref":"#/components/schemas/Record"}}}},"RecordResponse":{"type":"object","required":["record"],"properties":{"record":{"$ref":"#/components/schemas/Record"}}},"RecordCreateRequest":{"anyOf":[{"type":"object","required":["name","email","password"],"properties":{"name":{"type":"string","minLength":2,"maxLength":100},"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","minLength":12,"maxLength":128},"feeId":{"type":"string","nullable":true,"description":"Fee structure CUID."}}},{"type":"object","required":["title","details","memberId"],"properties":{"title":{"type":"string","minLength":2,"maxLength":120},"details":{"type":"string","minLength":1,"maxLength":10000},"memberId":{"type":"string","description":"Member CUID."}}},{"type":"object","properties":{"memberId":{"type":"string","description":"Member CUID."}},"additionalProperties":false},{"type":"object","required":["name","amountCents"],"properties":{"name":{"type":"string","minLength":2,"maxLength":100},"amountCents":{"type":"integer","minimum":1,"maximum":100000000},"description":{"type":"string","maxLength":2000,"default":""}}},{"type":"object","required":["memberId","billingMonth","amountCents","status"],"properties":{"memberId":{"type":"string","description":"Member CUID."},"billingMonth":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"amountCents":{"type":"integer","minimum":0,"maximum":100000000},"status":{"type":"string","enum":["PAID","PARTIAL","OVERDUE","REFUNDED"]},"dueAt":{"type":"string","format":"date-time","nullable":true}}},{"type":"object","required":["title"],"properties":{"title":{"type":"string","minLength":2,"maxLength":120},"description":{"type":"string","maxLength":4000,"default":""},"enabled":{"type":"boolean","default":false},"startsAt":{"type":"string","format":"date-time","nullable":true},"endsAt":{"type":"string","format":"date-time","nullable":true}}},{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":2,"maxLength":120},"description":{"type":"string","maxLength":2000,"default":""}}}],"description":"Body depends on resource. Attendance accepts memberId; training and diets use title/details/memberId; members use name/email/password/feeId; fees use name/amountCents/description; payments use memberId/billingMonth/amountCents/status/dueAt; offers use title/description/enabled/startsAt/endsAt; equipment uses name/description."},"RecordUpdateRequest":{"anyOf":[{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":100},"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","minLength":12,"maxLength":128},"feeId":{"type":"string","nullable":true},"status":{"type":"string","enum":["ACTIVE","SUSPENDED"]}},"minProperties":1},{"type":"object","properties":{"title":{"type":"string","minLength":2,"maxLength":120},"details":{"type":"string","minLength":1,"maxLength":10000},"memberId":{"type":"string"}},"minProperties":1},{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":100},"amountCents":{"type":"integer","minimum":1,"maximum":100000000},"description":{"type":"string","maxLength":2000},"active":{"type":"boolean"}},"minProperties":1},{"type":"object","properties":{"amountCents":{"type":"integer","minimum":0,"maximum":100000000},"status":{"type":"string","enum":["PAID","PARTIAL","OVERDUE","REFUNDED"]},"dueAt":{"type":"string","format":"date-time","nullable":true}},"minProperties":1},{"type":"object","properties":{"title":{"type":"string","minLength":2,"maxLength":120},"description":{"type":"string","maxLength":4000},"enabled":{"type":"boolean"},"startsAt":{"type":"string","format":"date-time","nullable":true},"endsAt":{"type":"string","format":"date-time","nullable":true}},"minProperties":1},{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"description":{"type":"string","maxLength":2000}},"minProperties":1}],"description":"Body depends on resource. Only gym administrators can update records."}}}}