According to the college board "The AP designation may only be applied to courses offered at or above the ninth-grade level that have received authorization through the annual AP Course Audit process. The AP label cannot be affixed to courses and transcripts earlier than ninth grade. There is one exception to this policy: AP world language and culture courses. These courses focus on linguistic proficiency and cultural competency, so in rare situations these courses can be successfully offered earlier than ninth grade among students who can already speak, read, and write the language with fluency. In summary, the AP Course Audit will only renew or authorize courses that are offered exclusively in grades 9–12, with the exception of AP world language and culture courses." https://apcentral.collegeboard.org/courses/ap-course-audit/faqs/classes-in-middle-school-ap

This policy is also emphasized in the college board document linked below.
https://secure-media.collegeboard.org/apc/Appropriate-Grade-Levels-for-AP-Courses.pdf

It appears that schools are not allowed to designate a course that isn't a language course as AP if it is offered at the middle school level, I assume this also applies to a middle school student allowed to take a course offered only at the high school level. I wonder how talent search organizations get around this for accelerated students. Presumably there are some gifted students that are ready to take AP Calculus BC course in middle school, I wonder if such students can only be offered the AP exam.