Accurate determination of colonoscopy indication is required for managing clinical programs and performing research; however, existing algorithms that use available electronic databases (eg, diagnostic and procedure codes) have yielded limited accuracy. To develop and validate an algorithm for classifying colonoscopy indication that uses comprehensive electronic medical data sources. We developed an algorithm for classifying colonoscopy indication by using commonly available electronic diagnostic, pathology, cancer, and laboratory test databases and validated its performance characteristics in comparison with a comprehensive review of patient medical records. We also evaluated the influence of each data source on the algorithm’s performance characteristics. Kaiser Permanente Northern California healthcare system. A total of 300 patients who underwent colonoscopy between 2007 and 2010. Colonoscopy. Algorithm’s sensitivity, specificity, and positive predictive value (PPV) for classifying screening, surveillance, and diagnostic colonoscopies. The reference standard was the indication assigned after comprehensive medical record review. For screening indications, the algorithm’s sensitivity was 88.5% (95% confidence interval [CI], 80.4%-91.7%), specificity was 91.7% (95% CI, 87.0%-95.1%), and PPV was 83.3% (95% CI, 74.7%-90.0%). For surveillance indications, the algorithm’s sensitivity was 93.4% (95% CI, 86.2%-97.5%), specificity was 92.8% (95% CI, 88.4%-95.9%), and PPV was 85.0% (95% CI, 76.5%-91.4%). The algorithm’s sensitivity, specificity, and PPV for diagnostic indications were 81.4% (95% CI, 73.0%-88.1%), 96.8% (95% CI, 93.2%-98.8%), and 93.9% (95% CI, 87.2%-97.7%), respectively. Validation was confined to a single healthcare system. An algorithm that uses commonly available modern electronic medical data sources yielded a high sensitivity, specificity, and PPV for classifying screening, surveillance, and diagnostic colonoscopy indications. This algorithm had greater accuracy than the indication listed on the colonoscopy report.