What is a base URL and how should it be structured?

Answer

The base URL is the common prefix shared by all endpoints in an API. A well-structured base URL looks like: https://api.example.com/v1. Best practices include using a dedicated subdomain (api.example.com instead of example.com/api) to allow independent scaling and routing. Include the API version in the base URL (/v1) so clients can target a specific version. Use HTTPS always — never expose APIs on plain HTTP in production. The base URL should be stable and not change — all versioning is handled through the version segment. For SDKs, configure the base URL as an environment variable so clients can point to dev/staging/production without code changes.