Name: URLs in responses
Status: approved
Created: 2023-01-10
Updated: 2023-01-10

URLs in responses (#3102)

APIs must return a relative URL when referring to endpoints that share the current domain.

  1. Most SDKs have the concept of a base_url and can use a relative URL immediately
  2. When working with multiple deployments, some customers may point at a specific geo region. By providing relative URLs we do not need to understand which endpoint the request came to before generating absolute URLs

If referencing a resource on a different domain, the full domain must be provided.

Examples

In the example, /services/10sjf30rf3 and /metrics/10sjf30rf3 are both served from the same domain, whilst /logs is on a separate domain:

{
"id": "10sjf30rf3",
"name": "Example service",
"metrics_url": "/metrics/10sjf30rf3",
"logs_url": "https://api.example.com/vendor/1234/logs/10sjf30rf3",
}