FYI no commitment is made to that by YouTube.
The API merely defines it as a "string" with no further commitment as to length, format or characters [1]
As for the "how?" there is an unsubstantiated answer based on reverse-engineering posted on SO[2]
[1] https://developers.google.com/youtube/v3/docs/videos#id [2] https://webapps.stackexchange.com/a/101153