{
	"info": {
		"_postman_id": "18abdf2d-715d-44d9-9c11-ab58911ed322",
		"name": "DocScanner Backend",
		"description": "Postman collection for the WriteScan CodeIgniter backend. Authenticate with the mobile OTP flow first — the `Verify OTP` call returns the session cookie that must accompany all subsequent requests.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "33019973",
		"_collection_link": "https://hello123-6238.postman.co/workspace/doc_scanner~b8c653b2-2c89-482b-92b8-8edde4e7bed1/collection/33019973-18abdf2d-715d-44d9-9c11-ab58911ed322?action=share&source=collection_link&creator=33019973"
	},
	"item": [
		{
			"name": "Config",
			"item": [
				{
					"name": "Get Runtime Config",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/config",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"config"
							]
						},
						"description": "Fetches dynamic configuration such as the Gemini model, API key, scan page limit, and maximum upload size."
					},
					"response": []
				}
			]
		},
		{
			"name": "Folders",
			"item": [
				{
					"name": "List Folders",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/folders",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"folders"
							]
						},
						"description": "Returns every folder owned by the logged-in user."
					},
					"response": []
				},
				{
					"name": "Create Folder",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Invoices\",\n  \"color\": \"#4C6FFF\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/folders",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"folders"
							]
						},
						"description": "Creates a new folder. The color field is optional; defaults to `#4C6FFF`."
					},
					"response": []
				},
				{
					"name": "Update Folder",
					"request": {
						"method": "PATCH",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Updated Name\",\n  \"color\": \"#2F8D46\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/folders/{{folderId}}",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"folders",
								"{{folderId}}"
							]
						},
						"description": "Updates an existing folder. Include only the fields that need to change."
					},
					"response": []
				},
				{
					"name": "Delete Folder",
					"request": {
						"method": "DELETE",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/folders/{{folderId}}",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"folders",
								"{{folderId}}"
							]
						},
						"description": "Permanently removes the folder. Any documents pointing at the folder will have their `folder_id` cleared."
					},
					"response": []
				}
			]
		},
		{
			"name": "Documents",
			"item": [
				{
					"name": "List Documents",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/documents",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"documents"
							]
						},
						"description": "Returns active documents for the user. Optional query param `updated_after=2024-06-01 00:00:00` performs incremental sync."
					},
					"response": []
				},
				{
					"name": "Get Document",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/documents/{{documentId}}",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"documents",
								"{{documentId}}"
							]
						},
						"description": "Fetches metadata for a single document, including the absolute file URL on the server."
					},
					"response": []
				},
				{
					"name": "Upload Document",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "formdata",
							"formdata": [
								{
									"key": "name",
									"value": "Quarterly Report",
									"type": "text"
								},
								{
									"key": "type",
									"value": "pdf",
									"description": "Document type label (pdf, image, csv, etc.). Defaults to pdf.",
									"type": "text"
								},
								{
									"key": "folder_id",
									"value": "{{folderId}}",
									"description": "Optional folder assignment.",
									"type": "text"
								},
								{
									"key": "gemini_text",
									"value": "Extracted text preview …",
									"description": "Optional Gemini transcription or summary.",
									"type": "text"
								},
								{
									"key": "file",
									"value": "",
									"description": "Attach the PDF or image to upload.",
									"type": "file"
								}
							]
						},
						"url": {
							"raw": "{{baseUrl}}/documents",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"documents"
							]
						},
						"description": "Uploads a new scan. The response returns the stored metadata and the public file URL."
					},
					"response": []
				},
				{
					"name": "Update Document",
					"request": {
						"method": "PATCH",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Renamed document\",\n  \"folder_id\": \"{{folderId}}\",\n  \"gemini_text\": \"Updated Gemini output\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/documents/{{documentId}}",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"documents",
								"{{documentId}}"
							]
						},
						"description": "Renames a document, reassigns folders, or updates Gemini text."
					},
					"response": []
				},
				{
					"name": "Archive Document",
					"request": {
						"method": "DELETE",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/documents/{{documentId}}",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"documents",
								"{{documentId}}"
							]
						},
						"description": "Marks the document as archived (soft delete)."
					},
					"response": []
				}
			]
		},
		{
			"name": "Bots",
			"item": [
				{
					"name": "Bot Messages",
					"item": [
						{
							"name": "List Messages",
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json"
									}
								],
								"url": {
									"raw": "{{baseUrl}}/bots/{{botId}}/messages",
									"host": [
										"{{baseUrl}}"
									],
									"path": [
										"bots",
										"{{botId}}",
										"messages"
									]
								},
								"description": "Retrieves the chat history for a given bot."
							},
							"response": []
						},
						{
							"name": "Send Message",
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Accept",
										"value": "application/json"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n  \"message\": \"What are the key action items?\"\n}"
								},
								"url": {
									"raw": "{{baseUrl}}/bots/{{botId}}/messages",
									"host": [
										"{{baseUrl}}"
									],
									"path": [
										"bots",
										"{{botId}}",
										"messages"
									]
								},
								"description": "Sends a user prompt to the bot. The response contains both the stored user message and the AI reply."
							},
							"response": []
						}
					]
				},
				{
					"name": "List Bots",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/bots",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"bots"
							]
						},
						"description": "Returns all active AI bots tied to the user along with document summaries."
					},
					"response": []
				},
				{
					"name": "Show Bot",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/bots/{{botId}}",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"bots",
								"{{botId}}"
							]
						},
						"description": "Fetches a single bot with its linked document metadata."
					},
					"response": []
				},
				{
					"name": "Create Bot",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"My Analysis Bot\",\n  \"document_id\": \"{{documentId}}\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/bots",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"bots"
							]
						},
						"description": "Creates a bot that chats using the supplied document. `name` is optional; defaults to the document name."
					},
					"response": []
				},
				{
					"name": "Delete Bot",
					"request": {
						"method": "DELETE",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/bots/{{botId}}",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"bots",
								"{{botId}}"
							]
						},
						"description": "Soft deletes the bot and removes its stored messages."
					},
					"response": []
				}
			]
		},
		{
			"name": "General Chat",
			"item": [
				{
					"name": "List Messages",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "{{baseUrl}}/general-chat",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"general-chat"
							]
						},
						"description": "Returns the saved general chat thread for the current user."
					},
					"response": []
				},
				{
					"name": "Create Message",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Accept",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"role\": \"user\",\n  \"type\": \"text\",\n  \"content\": \"Hello from Postman\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/general-chat",
							"host": [
								"{{baseUrl}}"
							],
							"path": [
								"general-chat"
							]
						},
						"description": "Persists a new message in the general-purpose chat log. `role` must be `user` or `assistant`; `type` is `text` or `image`."
					},
					"response": []
				}
			]
		}
	],
	"variable": [
		{
			"key": "baseUrl",
			"value": "http://localhost:8888/codeigniter-backend/public/api"
		},
		{
			"key": "mobile",
			"value": "94771234567"
		},
		{
			"key": "referenceNo",
			"value": ""
		},
		{
			"key": "otpCode",
			"value": ""
		},
		{
			"key": "folderId",
			"value": ""
		},
		{
			"key": "documentId",
			"value": ""
		},
		{
			"key": "botId",
			"value": ""
		}
	]
}