You’ve got to use the GET targeting_criteria/locations endpoint and get the country’s targeting_value. For example, for the US:
$ twurl -H ads-api.twitter.com "/2/targeting_criteria/locations?q=usa&location_type=COUNTRIES"
{
"data": [
{
"name": "United States",
"country_code": "US",
"location_type": "COUNTRIES",
"targeting_value": "96683cc9126741d1",
"targeting_type": "LOCATION"
},
{
"name": "United States Minor Outlying Islands",
"country_code": "UM",
"location_type": "COUNTRIES",
"targeting_value": "08fbcf4cbc4bc5b9",
"targeting_type": "LOCATION"
}
],
"request": {
"params": {
"location_type": "COUNTRIES",
"q": "usa"
}
},
"next_cursor": null
}
In this case, you’d use country=96683cc9126741d1 in the stats request:
$ twurl -X POST -H ads-api.twitter.com "/2/stats/jobs/accounts/18ce54d4x5t?start_time=2017-07-28&end_time=2017-08-28&entity=LINE_ITEM&entity_ids=5tddn&granularity=TOTAL&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER&segmentation_type=CITIES&country=96683cc9126741d1"
Hope this helps. Thanks!