Add repo to team does not work

I have created trough API a repository nd a team, while trying to add the repo with write permission to one of the teams I get “not found” message. Any ideas?

Organization is also the owner of the repo.

curl -X POST
-H “Accept: application/vnd.github.v3+json”
-H “authorization: Bearer $PERSONAL_API_TOKEN”
-d ‘{“permission” : “write”}’