The Leading Current Definition
The U.S. Census Bureau in the United States Department of Commerce defines race as follows, in definitions often used in other areas of the law and in research studies:
What is race?
The Census Bureau defines race as a person’s self-identification with
one or more social groups. An individual can report as White, Black or
African American, Asian, American Indian and Alaska Native, Native
Hawaiian and Other Pacific Islander, or some other race. Survey
respondents may report multiple races.
What is ethnicity?
Ethnicity determines whether a person is of Hispanic origin or not.
For this reason, ethnicity is broken out in two categories, Hispanic
or Latino and Not Hispanic or Latino. Hispanics may report as any
race.

Thus, ultimately the question is how you sincerely self-identify, but guidance is provided regarding what is meant by each term, which is framed in terms of "origins" from various large geographic regions of the world.
The Definitions Have Changed Over Time
The definitions of race and ethnicity, and the terms used, by the U.S. Census, have changed somewhat with almost each new decennial census.
Practical Reality
In reality, our culture and society is such that most people have a self-identify that corresponds to the predominant place of their remote genetic ancestors, and very few people who have remote genetic ancestors who are predominantly only from one place will self-identify otherwise, because it is not what is socially expected.
Edge Cases
But, there are plenty of edge cases and ambiguous cases.
For example, famous golfer Tiger Woods has deep genetic ancestry from Africa, Southeast Asia and Europe in large proportions.
Empirical Reality
One of the leading scholarly works that shows the empirical relationship between racial and ethnic self-identification and deep regional genetic ancestry is a 2014 article in the American Journal of Human Genetics that used data from the consumer genetic self-testing firm 23andMe.
African Americans
Historical "one drop rule" notwithstanding, empirically, in the United States, people who are at least 75% European in deep genetic ancestry, whose remaining ancestry is African, usually identifies as "white". But, people whose remote genetic ancestors are, for example, 38% traceable to Africa and 62% traceable to Europe, tend to identify as black or African-American, even though they are mostly European in genetic ancestry. In theory, the vast majority of people who identify as African-American in the U.S. have, on average, about 75% deep genetic African ancestry with most of the rest of their ancestry being Northern European ancestry, and could legitimately in a formal reading of the "origins" idea, identify as of more than one race. But, few people actually identify as more than one race unless they have parents of different races or at least grandparents with different racial identities.
The African American designation, like most of the formal categories, also includes a multitude of subgroups. Descendants of U.S. slaves make up most African-Americans in the United States, but the category also usually includes recent immigrants from sub-Saharan Africa and Afro-Caribbean immigrants from sub-Saharan Africa.
The Intersection Of Race and Hispanic Origins
Many ambiguous cases regarding race arise among people who identify as Hispanic, in part, because socially accepted and bureaucratic understandings in race are different in the U.S. than in Latin America.
Most Hispanic identifying people in the U.S. would identify their race in Latin America as "mestizo", which usually means people with both European ancestry and a large component of pre-Columbian indigenous Central and South American ancestry. But, that isn't an option on census bureau forms, so many Hispanic people mark "Other" as their race, while many mark "white", some mark "black" (even in cases where they have little African ancestry), and a few mark Native American (even though this would be a logical choice for someone who self-identifies as "mestizo").
Hispanic people in the U.S. and people in Latin America identifying as "white" tend to have less European ancestry than people who are not Hispanic in the U.S. who identify as "white." Hispanic people in the U.S. and people in Latin America identifying as "black" tend to have less African ancestry than people who are not Hispanic in the U.S. who identify as "black."
Due to this muddle, many statistical and research studies distinguish between non-Hispanic whites and non-Hispanic blacks while lumping all Hispanic identifying people in one category regardless of their self-identified racial identity.
Native American
People in the U.S. tend to identify as "Native American" without including other races at a fairly low percentage of deep genetic ancestry that is pre-Columbian indigenous American (many people who have 15% Native American ancestry, for example, would identify as exclusively Native American), and usually tend to do so only if their Native American ancestors are from North of the U.S.-Mexico border, even though indigenous Americas from the territory of the Continental U.S. and indigenous Americans from Latin America, are genetically very similar.
Many recognized Indian Tribes in the United States have blood quantum rules for membership that require members to have a certain proportion of ancestors who were members of the tribe, which is a genealogical test, rather than a genetic one, because Indian Tribes, like countries, can make someone a member via naturalization or adoption in addition to by birth.
But, one does not have to be affiliated with a specific Indian Tribe to be legitimately considered Native American under the law. And, a large share of people who do not physically appear to be Native American but claim a Native American ancestor many generations earlier as part of family lore, like Presidential candidate Elizabeth Warren and like many African Americans in the U.S., actually do have a distant Native American ancestor.
Asian-American
Asian American is one of the most heterogeneous U.S. racial categories. People who have origins in India, Southeast Asia, East Asia and Central Asia, who look very different from each other physically and have very different cultures, are currently lumped in one presumptive group. Historically, the U.S. distinguished between "Hindus" (meaning "South Asian" rather than as a religious identifier), and East Asians such as people from China and Japan, although it no longer does so.
This also illustrates the complication that while race is mostly a function of social and ethic background, genetic ancestry usually influences one's self-identification.
For example, in the U.S., someone adopted into a white family as a baby from China (there are probably hundreds of thousands of such people, at least, in the United States) usually self-identifies as Asian-American, despite having zero linguistic and first hand cultural connection to anyplace in China or Asia.
Why Self-Identification?
The self-identification rule is the powerful blunt instrument by which the edge cases are resolved in a basically unreviewable manner. As a result, the U.S. is not plunged into the arcane debates of racial identity that prevailed in the 19th century in U.S. Courts.
Blatant attempts to defy social convention by claiming a self-identification different from the one that would be ascribed socially to a person in what are not edge cases, are sometimes resolved on the grounds that the judge or jury, as the case may be, does not believe that the person's expression of self-identification in court is sincere based upon circumstantial evidence.
An example of the issues that judges and scholars sought to avoid with the self-identification rule is famous case Plessy v. Ferguson, 163 U.S. 537 (1896), in the U.S. which established that "separate but equal" satisfied the equality requirements of the 14th Amendment to the United States, started out as a test case, but turned in part into a racial classification case when it turns into a criminal prosecution, over whether the mixed race plaintiff in the case (who could "pass" as white and would probably identify as "white" in the U.S. today), was black or was white.
Homer Plessy, a free man who was seven-eighths white and one-eighth of
African descent, agreed to participate in a test case to challenge a
Louisiana law known as the Separate Car Act. This law required that
railroads provide separate cars and other accommodations for whites
and African-Americans. The Comite des Citoyens (Committee of Citizens)
was a group of New Orleans residents from a variety of ethnic
backgrounds that sought to repeal this law. They asked Plessy, who was
technically African-American under Louisiana law, to sit in a
whites-only car. He bought a first-class ticket and boarded the
whites-only car of the East Louisiana Railroad in a train for
Covington.
The railroad cooperated in the test case because it viewed the law as
imposing unnecessary additional costs through the purchase of more
railroad cars. It knew about the intention to challenge the law, and
the Committee of Citizens also enlisted a private detective to detain
Plessy on the train so that he could be charged under the Separate Car
Act. When Plessy was told to vacate the whites-only car and sit in the
African-American car, he refused and was arrested by the detective.
The train was stopped so that he could be removed, and a trial
proceeded.
Plessy's lawyers argued that the Separate Car Act violated the
Thirteenth and Fourteenth Amendments. Their theory failed, and the
judge found that Louisiana could enforce this law insofar as it
affected railroads within its boundaries. Plessy was convicted and
fined.
The self-identification rule has been popular with judges and scholars, in part, out of a desire to avoid returning to having courts decide those issues, which in light of contemporary American sensibilities seems unseemly.
There is also a sense that accuracy in classification isn't an important feature of a definition of race, because for many purposes, such as the purposes of discrimination laws in the U.S., the beliefs and intent and motives of the person discriminating are what matter legally, not some absolute Platonic truth regarding the person's genetic makeup or culture.