Skip to main content

Content-Location

ResponseActive

Content-Location gives a URL for the specific representation returned in the response body. When a server performs content negotiation and returns JSON (not HTML), Content-Location: /api/users/42.json tells clients the direct URL for that exact representation. Distinct from Location (which is used for redirects and resource creation).

Content-Location: <url>

Description

Content-Location is used when the URL requested via content negotiation or POST differs from the URL of the returned representation. For example, POST /api/users returns 201 Created with Location: /api/users/42 (the resource URL) and Content-Location: /api/users/42 (the exact representation). Clients can cache the response keyed to Content-Location. Distinct from the Location header which indicates a redirect target or newly created resource.

Examples

Created resource
http
HTTP/1.1 201 Created
Location: /api/users/42
Content-Location: /api/users/42
Content-Type: application/json
Content negotiation
http
HTTP/1.1 200 OK
Content-Location: /api/report.csv
Content-Type: text/csv

Related

Specification

RFC 9110Content-Location specification →