The best practice is to return 200 OK so the endpoint still works, but include a custom header like Warning to inform clients about deprecation. Returning 404 or 410 would break clients immediately, and 500 is for server errors.
The 'Deprecation' header is used to notify clients that the endpoint is planned to be removed later, giving them time to migrate. It does not block access or relate to authentication or response format.
def get_user(request): response = get_user_data() response.headers['Deprecation'] = 'true' return response
The 'Deprecation' header expects a date or a URL indicating when the API will be removed or more info. Using 'true' is not a valid value, so clients may ignore it.
The correct method is setHeader and the header value must be a string. Option C uses the correct syntax and quotes.
Using Deprecation and Sunset headers along with documentation gives clients time to migrate while keeping the API functional. Abrupt removal or errors cause client failures.