{
	"info": {
		"_postman_id": "bsb-api-collection-v1",
		"name": "Bank Statement Boss API",
		"description": "Complete API collection for Bank Statement Boss - Upload and process bank statement PDFs to extract transaction data.\n\n**Setup:**\n1. Set the `api_key` variable in the collection variables\n2. Set the `base_url` if using a different environment\n3. Run the requests in order",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"variable": [
		{
			"key": "base_url",
			"value": "https://bankstatementboss.com/api/v1",
			"type": "string"
		},
		{
			"key": "api_key",
			"value": "YOUR_API_KEY_HERE",
			"type": "string"
		},
		{
			"key": "document_id",
			"value": "",
			"type": "string"
		}
	],
	"item": [
		{
			"name": "1. Verify API Key",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{base_url}}/verify",
					"host": ["{{base_url}}"],
					"path": ["verify"]
				},
				"description": "Verify that your API key is valid and check account status. This endpoint does not consume credits."
			},
			"response": []
		},
		{
			"name": "2. Upload PDF",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"// Save document ID for later requests",
							"if (pm.response.code === 200) {",
							"    var jsonData = pm.response.json();",
							"    if (jsonData.success && jsonData.data.documentId) {",
							"        pm.collectionVariables.set('document_id', jsonData.data.documentId);",
							"        console.log('Document ID saved: ' + jsonData.data.documentId);",
							"    }",
							"}"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "file",
							"type": "file",
							"src": []
						}
					]
				},
				"url": {
					"raw": "{{base_url}}/upload",
					"host": ["{{base_url}}"],
					"path": ["upload"]
				},
				"description": "Upload a PDF bank statement. Select a PDF file in the request body. The document ID will be automatically saved for subsequent requests."
			},
			"response": []
		},
		{
			"name": "3. Process Document (CSV)",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"documentId\": \"{{document_id}}\",\n  \"outputFormat\": \"csv\"\n}"
				},
				"url": {
					"raw": "{{base_url}}/process",
					"host": ["{{base_url}}"],
					"path": ["process"]
				},
				"description": "Start processing the uploaded document. Output format: csv, quickbooks, xero, sage, or json. Credits are deducted based on page count."
			},
			"response": []
		},
		{
			"name": "3. Process Document (JSON)",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"documentId\": \"{{document_id}}\",\n  \"outputFormat\": \"json\"\n}"
				},
				"url": {
					"raw": "{{base_url}}/process",
					"host": ["{{base_url}}"],
					"path": ["process"]
				},
				"description": "Start processing the uploaded document with JSON output format."
			},
			"response": []
		},
		{
			"name": "3. Process Document (QuickBooks)",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"documentId\": \"{{document_id}}\",\n  \"outputFormat\": \"quickbooks\"\n}"
				},
				"url": {
					"raw": "{{base_url}}/process",
					"host": ["{{base_url}}"],
					"path": ["process"]
				},
				"description": "Start processing the uploaded document with QuickBooks CSV output format."
			},
			"response": []
		},
		{
			"name": "4. Check Status",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{base_url}}/status/{{document_id}}",
					"host": ["{{base_url}}"],
					"path": ["status", "{{document_id}}"]
				},
				"description": "Check the processing status of a document. Poll this endpoint every 5-10 seconds until status is 'completed'. The downloadUrl will be available when processing is complete."
			},
			"response": []
		},
		{
			"name": "5. Download Results",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{base_url}}/download/{{document_id}}",
					"host": ["{{base_url}}"],
					"path": ["download", "{{document_id}}"]
				},
				"description": "Download the processed transaction data. The format depends on the outputFormat specified during processing."
			},
			"response": []
		},
		{
			"name": "Check Credits",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "X-Api-Key",
						"value": "{{api_key}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{base_url}}/credits",
					"host": ["{{base_url}}"],
					"path": ["credits"]
				},
				"description": "Check your account's remaining credits and plan information."
			},
			"response": []
		}
	]
}
