# Meditation Admin — API reference Two base URLs (see `lib/config.ts`): - **approagency** (account login): `https://api.approagency.ir/api` - **meditation** (everything else): `https://meditation.approagency.ir/api` - `package_name`: `com.approagency.meditation` ## Auth flow (two steps) 1. `POST {approagency}/auth/login` — multipart: `auth` (email or mobile), `password`, `package_name` → `{ token }` (the "approo" token). 2. `POST {meditation}/auth/login-with-approo-v2?token=&package_name=...` — multipart: `token`, `package_name` → `{ token }` (the meditation bearer token used for all calls below). All meditation calls send `Authorization: Bearer ` and `Accept: application/json`. ## Endpoints (path is after the meditation base `/api`) ### Media (verified against MediaController) - GET `/media` — list (returns `categories[]`, nested `image`). query: `categories`, `subcategories`, `durations`, `search` - GET `/media/filters`, `/media/:id` - POST `/media` — multipart: title, caption, type(audio|video), `category_ids[]`, `subcategory_ids[]`, `image_id` or `image`(file), file(mp3/wav/mp4/mov) **or** `external_url`, duration, is_premium, visibility, tags[] - POST `/media/:id` — update (same multipart fields). Playable URL is in **`external_url`**; thumbnail in nested **`image.url`**. - GET `/media/popular`, `/media/recently-played`, `/media/saved` - POST `/media/:id/play`, `/media/:id/save`, `/media/:id/note`, `/media/:id/feedback` (stars, content) - Categories: GET `/categories`, POST `/categories` (multipart: name, description, `icon`(image file)), PUT `/categories/:id` (file → POST + `_method=PUT`), DELETE `/categories/:id`. Icon path in `icon`. - Sub-categories: GET/POST `/sub-categories` (category_id, name, description), PUT/DELETE `/sub-categories/:id` (json: category_id, name, description) ### Track (music) - Categories: GET `/music-categories/:id`, POST `/music-categories`, PUT/DELETE `/music-categories/:id` (name, description, order, image_id, is_active) - Sub-categories: GET `/music-subcategories`, POST `/music-subcategories`, PUT/DELETE `/music-subcategories/:id` - Music: GET `/music` (list, `{data:[]}`), GET `/music/:id`, POST `/music` (multipart: title, artist, file, type(public|private), `image_id` or `image`(file), playlist_id, duration), PUT/DELETE `/music/:id`. PUT with a file → POST + `_method=PUT`. Audio URL in `url`, cover in `image_url`. - POST `/music/update-order`, GET `/music/playlist/:id`, POST `/music/:musicId/add-to-playlist`, DELETE `/music/:musicId/remove-from-playlist` - Playlists: GET `/music-playlists/:id?`, POST `/music-playlists`, PUT/DELETE `/music-playlists/:id` (name, description, category_ids[], subcategory_ids[]) ### Insight timer - Timer options: GET `/timer/options` - Presets: GET/POST `/timer-presets`, GET/PUT/DELETE `/timer-presets/:id` (name, duration_seconds, start/end/interval_bell_id, interval_seconds, interval_repeat, background_sound_id, background_image_id, volume) - Bell sounds: GET/POST `/bell-sounds`, GET `/bell-sounds/:id`, POST `/bell-sounds/:id` (update), DELETE `/bell-sounds/:id` (multipart: name, order, is_active, sound, image) - Background sounds: GET/POST `/background-sounds`, GET `/background-sounds/:id`, POST `/background-sounds/:id`, DELETE `/background-sounds/:id` ### Settings / scenes - GET/POST `/scenes`, POST `/scenes/:id` (update), DELETE `/scenes/:id` (multipart: name, order, is_active, image, video, sound) - GET `/scene-settings`, PUT `/scene-settings` (active_scene_id, scene_volume, background_play_seconds, video_enabled) ### Slider - GET `/slider`, POST `/slider` (multipart: title, description, action[path], action[type], url), PUT/DELETE `/slider/:id` ### Images - GET `/images/all`, GET `/images/public`, POST `/images` (multipart: image, title, type, description), PUT/DELETE `/images/:id` ### Questions - GET `/questions?tag=&category=`, GET `/questions/:id`, POST `/questions`, PUT/DELETE `/questions/:id` (title, category, tags[]) ### Survey questions - GET `/survey-questions/:id`, POST `/survey-questions`, PUT/DELETE `/survey-questions/:id` (question, description, type, order, is_active, options[].label) - POST `/survey-questions/:id/answer` (option_ids[]) - GET `/admin/survey-questions/:id`, GET `/admin/survey-questions/:id/analytics` - GET `/survey-questions/suggested-media` ### Breathing exercise - GET `/breathing-templates`, POST `/breathing-templates`, PUT/DELETE `/breathing-templates/:id` (name, inhale, exhale, breath_hold, duration, description, image_id) - GET `/user-templates`, GET `/breathing-sessions`, POST `/breathing-complete?template_id=&duration=` ### Mood - GET `/moods`, GET `/moods/history`, POST `/moods/today` (mood_id) ### Worry box - GET `/worries`, POST `/worries` (title, note), PUT/DELETE `/worries/:id`, PATCH `/worries/:id/toggle` ### Comments / Likes / Saves / Ratings (by type+id, e.g. type=media|music|playlist) - Comments: GET/POST `/comments/:type/:id` (content); PUT/DELETE `/comments/:type/:id/:commentId` - Likes: POST `/likes/toggle`, `/likes/like` (type, id), GET `/likes/my-liked?type=` - Saves: POST `/saves/toggle`, `/saves/save`, `/saves/unsave`, `/saves/check` (type, id), GET `/saves/my-saved?type=` - Ratings: GET/POST/DELETE `/ratings/:type/:id` (stars), GET `/ratings/:type/:id/user` ### Chat topics (موضوعات پیشنهادی گفتگو با مشاور) - GET `/chat-topics`, GET `/chat-topics/:id`, POST `/chat-topics`, PUT/DELETE `/chat-topics/:id` (json: title, description, order, is_active) ### Misc - GET `/leader-board` - GET `/profile` - POST `/zarinpal/gateway` (description, product_id, platform)