{
	"info": {
		"_postman_id": "split-bill-api-collection",
		"name": "Split Bill App API",
		"description": "API collection for Split Bill App Backend Service",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"variable": [
		{
			"key": "base_url",
			"value": "http://localhost:3000/api",
			"type": "string"
		},
		{
			"key": "token",
			"value": "",
			"type": "string"
		}
	],
	"item": [
		{
			"name": "Auth",
			"item": [
				{
					"name": "1. Register",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"phone_number\": \"+6281234567890\",\n    \"password\": \"secret123\",\n    \"name\": \"John Doe\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/auth/register",
							"host": ["{{base_url}}"],
							"path": ["auth", "register"]
						},
						"description": "Create a new user account.\n\nRequired fields:\n- phone_number (string): User's phone number (unique)\n- password (string): Password (min 6 characters)\n- name (string): User's display name"
					},
					"response": []
				},
				{
					"name": "2. Login",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = pm.response.json();",
									"if (jsonData.data && jsonData.data.token) {",
									"    pm.collectionVariables.set(\"token\", jsonData.data.token);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"phone_number\": \"+6281234567890\",\n    \"password\": \"secret123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/auth/login",
							"host": ["{{base_url}}"],
							"path": ["auth", "login"]
						},
						"description": "Authenticate user and receive JWT token.\n\nRequired fields:\n- phone_number (string): User's phone number\n- password (string): User's password\n\nNote: Token is automatically saved to collection variable on successful login."
					},
					"response": []
				},
				{
					"name": "3. Reset Password",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"phone_number\": \"+6281234567890\",\n    \"new_password\": \"newpassword123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/auth/reset-password",
							"host": ["{{base_url}}"],
							"path": ["auth", "reset-password"]
						},
						"description": "Reset user password after successful OTP verification on frontend.\n\nNote: OTP request and verification is handled entirely on the frontend using Firebase Authentication. Call this endpoint only after the user has successfully verified their OTP via Firebase.\n\nRequired fields:\n- phone_number (string): User's phone number\n- new_password (string): New password (min 6 characters)"
					},
					"response": []
				}
			]
		},
		{
			"name": "User",
			"item": [
				{
					"name": "4. Get Profile",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/user/profile",
							"host": ["{{base_url}}"],
							"path": ["user", "profile"]
						},
						"description": "Get current user's profile information.\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "5. Search Users",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/user/search?q=john",
							"host": ["{{base_url}}"],
							"path": ["user", "search"],
							"query": [
								{
									"key": "q",
									"value": "john",
									"description": "Search query (min 2 characters) - searches by phone number or name"
								}
							]
						},
						"description": "Search for registered users by phone number or name.\n\nUseful for adding participants when creating a bill.\n\nQuery Parameters:\n- q (string): Search query (min 2 characters)\n\nNotes:\n- Searches both phone number and name fields\n- Returns maximum 20 results\n- Current user is excluded from results\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "6. Edit Profile",
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"name\": \"John Updated\",\n    \"img_url\": \"https://example.com/new-photo.jpg\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/user/profile",
							"host": ["{{base_url}}"],
							"path": ["user", "profile"]
						},
						"description": "Update user profile information.\n\nOptional fields:\n- name (string): New display name\n- img_url (string): Profile image URL\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "7. Change Password",
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"old_password\": \"secret123\",\n    \"new_password\": \"newsecret456\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/user/change-password",
							"host": ["{{base_url}}"],
							"path": ["user", "change-password"]
						},
						"description": "Change user's password.\n\nRequired fields:\n- old_password (string): Current password\n- new_password (string): New password (min 6 characters)\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "8. Change Default Currency",
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"currency\": \"USD\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/user/currency",
							"host": ["{{base_url}}"],
							"path": ["user", "currency"]
						},
						"description": "Update user's default currency.\n\nRequired fields:\n- currency (string): Currency code - 'IDR' or 'USD'\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "9. Toggle Theme",
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"theme\": \"dark\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/user/theme",
							"host": ["{{base_url}}"],
							"path": ["user", "theme"]
						},
						"description": "Switch between dark and light mode.\n\nRequired fields:\n- theme (string): 'dark' or 'light'\n\nRequires authentication."
					},
					"response": []
				}
			]
		},
		{
			"name": "Bills",
			"item": [
				{
					"name": "10. Create Bill",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"title\": \"Lunch at Restaurant ABC\",\n    \"tax_percent\": 10,\n    \"service_percent\": 5,\n    \"currency\": \"IDR\",\n    \"participants\": [\n        { \"user_id\": 1 },\n        { \"user_id\": 2 },\n        { \"guest_name\": \"Guest User\" }\n    ],\n    \"items\": [\n        {\n            \"name\": \"Nasi Goreng\",\n            \"price\": 35000,\n            \"quantity\": 1,\n            \"discount\": 0,\n            \"assignments\": [\n                { \"participant_id\": 0, \"share_percent\": 100 }\n            ]\n        },\n        {\n            \"name\": \"Mie Ayam\",\n            \"price\": 25000,\n            \"quantity\": 2,\n            \"discount\": 5000,\n            \"assignments\": [\n                { \"participant_id\": 1, \"share_percent\": 50 },\n                { \"participant_id\": 2, \"share_percent\": 50 }\n            ]\n        },\n        {\n            \"name\": \"Es Teh\",\n            \"price\": 10000,\n            \"quantity\": 3,\n            \"discount\": 0,\n            \"assignments\": [\n                { \"participant_id\": 0, \"share_percent\": 33.33 },\n                { \"participant_id\": 1, \"share_percent\": 33.33 },\n                { \"participant_id\": 2, \"share_percent\": 33.34 }\n            ]\n        }\n    ]\n}"
						},
						"url": {
							"raw": "{{base_url}}/bills",
							"host": ["{{base_url}}"],
							"path": ["bills"]
						},
						"description": "Create a new bill with items and participants.\n\nRequired fields:\n- title (string): Bill title\n- items (array): Array of bill items\n- participants (array): Array of participants\n\nOptional fields:\n- tax_percent (number): Tax percentage (default: 0)\n- service_percent (number): Service charge percentage (default: 0)\n- currency (string): Currency code (default: IDR)\n\nNote: participant_id in assignments refers to the index in the participants array.\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "11. Get Bill List",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/bills",
							"host": ["{{base_url}}"],
							"path": ["bills"],
							"query": [
								{
									"key": "type",
									"value": "created",
									"description": "Filter: 'created' (my bills) or 'joined' (others' bills)",
									"disabled": true
								}
							]
						},
						"description": "Get list of bills (history).\n\nOptional query parameters:\n- type (string): Filter by 'created' (bills I created) or 'joined' (bills where I'm a participant)\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "11. Get Bill List (Created)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/bills?type=created",
							"host": ["{{base_url}}"],
							"path": ["bills"],
							"query": [
								{
									"key": "type",
									"value": "created"
								}
							]
						},
						"description": "Get list of bills created by current user.\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "11. Get Bill List (Joined)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/bills?type=joined",
							"host": ["{{base_url}}"],
							"path": ["bills"],
							"query": [
								{
									"key": "type",
									"value": "joined"
								}
							]
						},
						"description": "Get list of bills where current user is a participant (created by others).\n\nRequires authentication."
					},
					"response": []
				},
				{
					"name": "12. Get Bill Detail",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/bills/1",
							"host": ["{{base_url}}"],
							"path": ["bills", "1"]
						},
						"description": "Get detailed information about a specific bill.\n\nURL Parameters:\n- billId (number): Bill ID\n\nRequires authentication. User must be owner or participant of the bill."
					},
					"response": []
				},
				{
					"name": "13. Confirm Payment",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"participant_id\": 1\n}"
						},
						"url": {
							"raw": "{{base_url}}/bills/1/confirm-payment",
							"host": ["{{base_url}}"],
							"path": ["bills", "1", "confirm-payment"]
						},
						"description": "Confirm payment for a participant in a bill.\n\nURL Parameters:\n- billId (number): Bill ID\n\nRequired fields:\n- participant_id (number): Participant ID\n\nRequires authentication. User can only confirm their own payment or bill owner can confirm any participant's payment."
					},
					"response": []
				},
				{
					"name": "14. Delete Bill",
					"request": {
						"method": "DELETE",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/bills/1",
							"host": ["{{base_url}}"],
							"path": ["bills", "1"]
						},
						"description": "Delete a bill and all its related data.\n\nURL Parameters:\n- billId (number): Bill ID\n\nOnly the bill owner (creator) can delete the bill.\n\nRequires authentication."
					},
					"response": []
				}
			]
		},
		{
			"name": "Dashboard",
			"item": [
				{
					"name": "15. Get Dashboard Summary",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/dashboard/summary",
							"host": ["{{base_url}}"],
							"path": ["dashboard", "summary"]
						},
						"description": "Get summary data for dashboard display.\n\nReturns:\n- outstanding: Current unpaid bills (amount and count)\n- monthly: Total bills for current month\n- owned_bills_monthly: Bills created by user this month\n\nRequires authentication."
					},
					"response": []
				}
			]
		},
		{
			"name": "Health",
			"item": [
				{
					"name": "Health Check",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/../health",
							"host": ["{{base_url}}"],
							"path": ["..", "health"]
						},
						"description": "Check if the server is running.\n\nNo authentication required."
					},
					"response": []
				}
			]
		}
	]
}
