Where do short codes come from?

There is a central registry that was created by the US mobile carriers to administer short codes. Twilio will lease a short code on your behalf from this registry.