Here it is—after three days of effort, it's finally done. I hope this helps someone!
def set_app_price_to_zero(app_id, price_point_id, territory_id="USA"):
# Sets the app's price to $0 for the USA territory.
# Param:
# app_id (str): The app's ID.
# price_point_id (str): The price point ID for $0.
# territory_id (str): The territory ID, default is "USA".
try:
token = jwt_manager.get_token() # Replace with your JWT token generation method
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
url = "https://api.appstoreconnect.apple.com/v1/appPriceSchedules"
payload = {
"data": {
"type": "appPriceSchedules",
"relationships": {
"app": {
"data": {
"type": "apps",
"id": app_id
}
},
"baseTerritory": {
"data": {
"type": "territories",
"id": territory_id
}
},
"manualPrices": {
"data": [
{
"id": "manualPrice-0",
"type": "appPrices"
}
]
}
}
},
"included": [
{
"id": "manualPrice-0",
"type": "appPrices",
"attributes": {
"startDate": None,
"endDate": None
},
"relationships": {
"appPricePoint": {
"data": {
"type": "appPricePoints",
"id": price_point_id
}
}
}
}
]
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 201:
print("App price set to $0 successfully!")
else:
print(f"Failed to set app price: {response.status_code}")
print(response.json())
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
# App ID and Price Point ID for $0
app_id = "**********" # Replace with your app's ID
price_point_id = "eyJzIjoiNjczNjcxNzkzOCIsInQiOiJVU0EiLCJwIjoiMTAwMDAifQ" # $0 price point ID
# Set the price to $0
set_app_price_to_zero(app_id, price_point_id)