AP for international students

I’m an international student and I don’t know how the AP works, I know that you take a course and then make a test, it gives you credit for college (I think you must ask the grade to be sent to the colleges you want). But I don’t know where they take those test??? Do they take them online or is there any branch office in other countries?

No. You take them in a brick-and-mortar building, typically a school.

Refer to the College Board’s info below:
https://apcentral.collegeboard.org/start-grow-ap/international/administer-exam