{
  "name": "Auth",
  "description": "Authentication endpoints - Register, Login, OTP verification, Password management",
  "item": [
    {
      "name": "Register",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "if (pm.response.code === 201 || pm.response.code === 200) {",
              "    const response = pm.response.json();",
              "    if (response.data && response.data.user) {",
              "        pm.environment.set('userId', response.data.user._id || response.data.user.id);",
              "    }",
              "}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{testEmail}}\",\n  \"password\": \"{{testPassword}}\",\n  \"fullName\": \"Test User\",\n  \"userType\": \"User\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/signUp",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "signUp"]
        },
        "description": "Register a new user account. Sends OTP to email for verification."
      },
      "response": [
        {
          "name": "201 - Success",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"test@example.com\",\n  \"password\": \"Test@123\",\n  \"fullName\": \"Test User\",\n  \"userType\": \"User\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/signUp",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "signUp"]
            }
          },
          "status": "Created",
          "code": 201,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": true,\n  \"message\": \"User registered successfully. Please verify your email.\",\n  \"data\": {\n    \"user\": {\n      \"_id\": \"507f1f77bcf86cd799439011\",\n      \"email\": \"test@example.com\",\n      \"fullName\": \"Test User\",\n      \"userType\": \"User\",\n      \"isVerified\": false\n    }\n  },\n  \"statusCode\": 201\n}"
        },
        {
          "name": "400 - User Already Exists",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"existing@example.com\",\n  \"password\": \"Test@123\",\n  \"fullName\": \"Test User\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/signUp",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "signUp"]
            }
          },
          "status": "Bad Request",
          "code": 400,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": false,\n  \"message\": \"User with this email already exists\",\n  \"statusCode\": 400\n}"
        },
        {
          "name": "422 - Validation Error",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"invalid-email\",\n  \"password\": \"123\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/signUp",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "signUp"]
            }
          },
          "status": "Unprocessable Entity",
          "code": 422,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": false,\n  \"message\": \"Validation failed\",\n  \"errors\": [\n    {\n      \"field\": \"email\",\n      \"message\": \"Invalid email format\"\n    },\n    {\n      \"field\": \"password\",\n      \"message\": \"Password must be at least 6 characters\"\n    }\n  ],\n  \"statusCode\": 422\n}"
        },
        {
          "name": "500 - Server Error",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"test@example.com\",\n  \"password\": \"Test@123\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/signUp",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "signUp"]
            }
          },
          "status": "Internal Server Error",
          "code": 500,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": false,\n  \"message\": \"Internal Server Error\",\n  \"statusCode\": 500\n}"
        }
      ]
    },
    {
      "name": "Verify OTP",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "if (pm.response.code === 200) {",
              "    const response = pm.response.json();",
              "    if (response.data && response.data.token) {",
              "        pm.environment.set('accessToken', response.data.token);",
              "    }",
              "    if (response.data && response.data.user) {",
              "        pm.environment.set('userId', response.data.user._id || response.data.user.id);",
              "    }",
              "}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{testEmail}}\",\n  \"otp\": \"123456\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/verify",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "verify"]
        },
        "description": "Verify email with OTP code sent during registration"
      },
      "response": [
        {
          "name": "200 - Success",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"test@example.com\",\n  \"otp\": \"123456\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/verify",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "verify"]
            }
          },
          "status": "OK",
          "code": 200,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": true,\n  \"message\": \"Email verified successfully\",\n  \"data\": {\n    \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\",\n    \"user\": {\n      \"_id\": \"507f1f77bcf86cd799439011\",\n      \"email\": \"test@example.com\",\n      \"isVerified\": true\n    }\n  },\n  \"statusCode\": 200\n}"
        },
        {
          "name": "400 - Invalid OTP",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"test@example.com\",\n  \"otp\": \"000000\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/verify",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "verify"]
            }
          },
          "status": "Bad Request",
          "code": 400,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": false,\n  \"message\": \"Invalid or expired OTP\",\n  \"statusCode\": 400\n}"
        }
      ]
    },
    {
      "name": "Login",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "if (pm.response.code === 200) {",
              "    const response = pm.response.json();",
              "    if (response.data && response.data.token) {",
              "        pm.environment.set('accessToken', response.data.token);",
              "    }",
              "    if (response.data && response.data.refreshToken) {",
              "        pm.environment.set('refreshToken', response.data.refreshToken);",
              "    }",
              "    if (response.data && response.data.user) {",
              "        pm.environment.set('userId', response.data.user._id || response.data.user.id);",
              "    }",
              "}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{testEmail}}\",\n  \"password\": \"{{testPassword}}\",\n  \"deviceId\": \"test-device-123\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/login",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "login"]
        },
        "description": "Login with email and password. Returns access token and refresh token."
      },
      "response": [
        {
          "name": "200 - Success",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"test@example.com\",\n  \"password\": \"Test@123\",\n  \"deviceId\": \"device-123\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/login",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "login"]
            }
          },
          "status": "OK",
          "code": 200,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": true,\n  \"message\": \"Login successful\",\n  \"data\": {\n    \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\",\n    \"refreshToken\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\",\n    \"user\": {\n      \"_id\": \"507f1f77bcf86cd799439011\",\n      \"email\": \"test@example.com\",\n      \"fullName\": \"Test User\",\n      \"userType\": \"User\"\n    }\n  },\n  \"statusCode\": 200\n}"
        },
        {
          "name": "401 - Invalid Credentials",
          "originalRequest": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"test@example.com\",\n  \"password\": \"wrongpassword\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/auth/login",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "login"]
            }
          },
          "status": "Unauthorized",
          "code": 401,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "cookie": [],
          "body": "{\n  \"success\": false,\n  \"message\": \"Invalid email or password\",\n  \"statusCode\": 401\n}"
        }
      ]
    },
    {
      "name": "Social Login",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "if (pm.response.code === 200) {",
              "    const response = pm.response.json();",
              "    if (response.data && response.data.token) {",
              "        pm.environment.set('accessToken', response.data.token);",
              "    }",
              "    if (response.data && response.data.user) {",
              "        pm.environment.set('userId', response.data.user._id || response.data.user.id);",
              "    }",
              "}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"provider\": \"google\",\n  \"accessToken\": \"google-access-token\",\n  \"email\": \"test@example.com\",\n  \"fullName\": \"Test User\",\n  \"deviceId\": \"test-device-123\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/social/login",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "social", "login"]
        },
        "description": "Login or register using social providers (Google, Facebook, Apple)"
      },
      "response": []
    },
    {
      "name": "Resend OTP",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{testEmail}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/resend-otp",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "resend-otp"]
        },
        "description": "Resend OTP verification code to email"
      },
      "response": []
    },
    {
      "name": "Forgot Password",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{testEmail}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/forget-password",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "forget-password"]
        },
        "description": "Request password reset OTP"
      },
      "response": []
    },
    {
      "name": "Reset Password",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{testEmail}}\",\n  \"otp\": \"123456\",\n  \"newPassword\": \"NewPassword@123\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/reset-password",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "reset-password"]
        },
        "description": "Reset password using OTP"
      },
      "response": []
    },
    {
      "name": "Change Password",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{accessToken}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"currentPassword\": \"{{testPassword}}\",\n  \"newPassword\": \"NewPassword@123\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/change-password",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "change-password"]
        },
        "description": "Change password for authenticated user"
      },
      "response": []
    },
    {
      "name": "Refresh Token",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "if (pm.response.code === 200) {",
              "    const response = pm.response.json();",
              "    if (response.data && response.data.token) {",
              "        pm.environment.set('accessToken', response.data.token);",
              "    }",
              "}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{accessToken}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"refreshToken\": \"{{refreshToken}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/refresh",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "refresh"]
        },
        "description": "Refresh access token using refresh token"
      },
      "response": []
    },
    {
      "name": "Logout",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{accessToken}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"deviceId\": \"test-device-123\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/auth/logout",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "logout"]
        },
        "description": "Logout and invalidate tokens"
      },
      "response": []
    },
    {
      "name": "Delete Account",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{accessToken}}",
              "type": "string"
            }
          ]
        },
        "method": "DELETE",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/auth/delete-account",
          "host": ["{{baseUrl}}"],
          "path": ["auth", "delete-account"]
        },
        "description": "Permanently delete user account"
      },
      "response": []
    }
  ]
}
