Yes there are a couple of standards (albeit some liberties on the definition of standard) that have emerged:

  1. JSON API - JSON API covers creating and updating resources as well, not just responses.
  2. JSend - Simple and probably what you are already doing.
  3. OData JSON Protocol - Very complicated.
  4. HAL - Like OData but aiming to be HATEOAS like.

There are also JSON API description formats:

  • Swagger
    • JSON Schema (used by swagger but you could use it stand alone)
  • WADL in JSON
  • RAML
  • HAL because HATEOAS in theory is self describing.
Answer from Adam Gent on Stack Overflow
🌐
Stack Overflow
stackoverflow.blog › 2020 › 03 › 02 › best-practices-for-rest-api-design
Best practices for REST API design - Stack Overflow
To make sure that when our REST API app responds with JSON that clients interpret it as such, we should set Content-Type in the response header to application/json after the request is made.
🌐
GitHub
gist.github.com › igorjs › 407ffc3126f6ef2a6fe8f918a0673b59
REST API response format based on some of the best practices · GitHub
REST API response format based on some of the best practices · https://api.example.com/v1/items · https://example.com/api/v1/items · 1- GET - Get single item - HTTP Response Code: 200 · HTTP/1.1 200 Content-Type: application/json { "id": 10, "name": "shirt", "color": "red", "price": "$23" } 2- GET - Get item list - HTTP Response Code: 200 ·
🌐
Speakeasy
speakeasy.com › api-design › responses
Responses Best Practices in REST API Design | Speakeasy
This guide covers essential patterns and best practices for API responses. An API response is primarily made up of a status code, headers, and a response body, so let’s look at each of those parts in turn. Just like requests allow API consumers to add HTTP headers to act as metadata for the request, APIs and other network components can add headers to a response. HTTP/2 200 OK Content-Type: application/json Cache-Control: public, max-age=18000 RateLimit: "default";r=50;t=30 { "title": "something" }
🌐
Medium
medium.com › @bojanmajed › standard-json-api-response-format-c6c1aabcaa6d
Standard JSON API response format | by MaJeD BoJaN | Medium
March 31, 2020 - So i decided to explain what the standard we are following in our company, we are writing API’s in rails framework and returning response as JSON to front-end applications · There are 2 kind of responses in each API request which are Success response and Error response i will explain briefly some of our API’s responses how it looks · The main response structure have 4 keys which are 1) error_code code to indicate if there was an error 2) Success always returning true or false if the response is success will returning true otherwise will get false 3) Message it’s better to return the response message from back-end 4) data which is the main key and will have the data that should be displayed
🌐
Apidog
apidog.com › blog › json-api-responses
Mastering API Responses: The Definitive Guide to JSON Formatting
July 21, 2025 - Body: Contains the actual data payload, formatted as a JSON object or array. For example, a successful response from an API might look like this: Apidog emphasizes clear documentation and structured responses to ensure efficient data exchange and error handling. When structuring JSON API responses, adhering to best practices is crucial for ensuring that the data is easily consumable and maintainable.
🌐
Medium
medium.com › @sunitparekh › guidelines-on-json-responses-for-restful-services-1ba7c0c015d
Guidelines on JSON responses for RESTful services | by Sunit Parekh | Medium
April 3, 2018 - Next-Page response header tells client that I have more data (next page) available. And such headers can be really useful for loading next pages on scroll. However, when I look at API like elasticsearch I get convinced that Option 2 is also right. Choose one for the project and follow it. Now it’s time to get inside the JSON fields.
Top answer
1 of 7
58

A few potential reasons why you may wish to do this are:

  1. the fact that some HTTP clients treat anything other than 2xx as an "exception" to be thrown, which can hide differences between transport errors (like no connection, invalid firewall, invalid endpoint/URL, etc.) and actual API errors (bad API key, request validation rules, etc.), which could both end up being thrown as errors, which leads to extra work in determining which it was and extracting the actual API error text

  2. responses that aren't accurately / completely represented by normal status code, or even multi action requests, where you have >1 API action in a single HTTP request and each one may succeed or fail individually, in which case either a 2xx or 4xx would not be accurate

I personally prefer to inspect the JSON for errors instead of hoping that the language I'm using will easily differentiate between different kinds of errors. Java and C# for example would allow me to do multiple different catches of specific exceptions on a single try, but in JavaScript where anything can be an error and each try only allows a single catch, it's messier to separate transport errors from API errors

2 of 7
111

Many people take HTTP status code as “successful communication with the server”.

Now if a customer wants to buy a US$200 item and has only US$100 in their account, the JSON response will be “failure, insufficient funds”. But as far as HTTP is concerned, everything went just fine: It delivered a purchase order, and successfully returned back to the caller that the purchase failed.

So you get a status 200. You would get something in the 400 range if there was actually some communication failure. In that case you have no idea if there is money in the account or not. We didn’t get that far.

Note there are situations where we don’t even get an HTTP status: if the server is down, or if HTTPS negotiation fails, your application didn’t even manage to reach the server.

Find elsewhere
Top answer
1 of 3
6

I noticed you've used the tag REST, so I assume you are thinking about a RESTful API implementation and have some knowledge about RESTful API design.

If you need some best practices, a couple of them I think are useful. here and here.

Looking at your examples, I would prefer the second option, the reasons are:

  1. IsError can be determined by the HTTP response, e.g. 400, 500, 200, 201, so it's redundant.
  2. Status and Message are also redundant when the response is successful but could be useful in an error state, like in ASP.NET, you can use the ProblemDetails response (you can customize the way you want).
{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "Unable to create a new user due to missing name",
    "status": 400,
    "traceId": "00-0aa7d64ad154a1e1853c413a0def982d-195d3558c90f7876-00"
}
  1. version is an interesting one. Usually, it can be included in the request header or URL. If the API cannot handle the version requested, then it should return an error in the problem details.

Thus, I prefer the second option and send a problem details response when there is an error.

2 of 3
1

An open source CRM with more than 18K start on github uses Laravel-default api resource Project Link Code Example link

Pay attention to status codes Reference

This one is super important. If there's one thing you need to remember from this article, this is probably it:

The worst thing your API could do is return an error response with a 200 OK status code.

It's simply bad semantics. Instead, return a meaningful status code that correctly describes the type of error.

Still, you might wonder, "But I'm sending error details in the response body as you recommended, so what's wrong with that?"

Let me tell you a story.

I once had to use an API that returned 200 OK for every response and indicated whether the request had succeeded via a status field:

{
  "status": "success",
  "data": {}
}

So even though the status was 200 OK, I could not be absolutely sure it didn't fail to process my request.

This kind of design is a real no-no because it breaks the trust between the API and their users. You come to fear that the API could be lying to you.

All of this is extremely un-RESTful. What should you do instead?

Make use of the status code and only use the response body to provide error details.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "error": "Expected at least two items in list."
}
🌐
JSON:API
jsonapi.org
JSON:API — A specification for building APIs in JSON
Here’s an example response from a blog that implements JSON:API: { "links": { "self": "http://example.com/articles", "next": "http://example.com/articles?page[offset]=2", "last": "http://example.com/articles?page[offset]=10" }, "data": [{ "type": "articles", "id": "1", "attributes": { "title": "JSON:API paints my bikeshed!"
🌐
Microsoft Learn
learn.microsoft.com › en-us › azure › architecture › best-practices › api-design
Web API Design Best Practices - Azure Architecture Center | Microsoft Learn
In the HTTP protocol, resource representation formats are specified by using media types, also called MIME types. For nonbinary data, most web APIs support JSON (media type = application/json) and possibly XML (media type = application/xml). The Content-Type header in a request or response specifies the resource representation format.
🌐
Reddit
reddit.com › r/flutterdev › rest api response format: which approach would you suggest?
r/FlutterDev on Reddit: REST API Response Format: Which approach would you suggest?
June 11, 2023 -

Hi guys, I'm working on Spring Boot project, also this question can be ask for any backend app. I'm trying to figure out which REST API Response format is better. I have done some research but still, I need the opinion from the community. Which approach would you suggest in terms of best practice, code quality, maintainability and readability?P/s: If you guys have other suggestion, would love to read that.

Option 1:

// Success request with data
{ 
    code: "000", 
    msg: "Successfully logged-in", 
    data: { 
            token: { accessToken: "..." }, 
            user: { id: "1", name: "John" }
    }
}

// Success request with validation
{ 
    code: "001", 
    msg: "Validation error", 
    data: { 
        validation: { 
            name: "The name field is required", 
            email: "The email has been taken"
        }
    } 
}

Option 2:

// Success request with data
{ 
    code: "000", 
    msg: "Successfully logged-in", 
    data: { 
            token: { accessToken: "..." },
            user: { id: "1", name: "John" }
    },
    error: null
}

// Success request with validation 
{
    code: "001", 
    msg: "Validation error", 
    data: null, 
    error: { 
        validation: {
            name: "The name field is required", 
            email: "The email has been taken" 
        } 
    } 
}
🌐
Medium
medium.com › @sukhadamorgaonkar28 › rest-api-best-practices-239f4d0bd6f5
REST API Best Practices. REST API(also known as RESTful API)… | by Sukhadamorgaonkar | Medium
November 6, 2023 - REST APIs should accept JSON for request payload and also send responses to JSON. Specify in your API documentation that JSON is the expected format for both request payloads and responses.
🌐
Hevo
hevodata.com › home › learn › best practice
REST API Best Practices and Standards in 2026 | Hevo
January 9, 2026 - To ensure that clients interpret our REST API app’s responses as JSON, we should set the Content-Type in the response header to application/json once the request is made. Many server-side app frameworks configure the response header automatically.
🌐
LogRocket
blog.logrocket.com › home › 10 best practices for rest api design
10 best practices for REST API design - LogRocket Blog
June 4, 2024 - To make sure that the REST API is using the JSON format, always set the Content-Type in the response header to application/JSON.
🌐
Stack Overflow
stackoverflow.com › questions › 44705592 › best-practice-for-json-response-to-restful-api-call
rest - Best practice for JSON response to Restful API call? - Stack Overflow
One approach I've seen proposes that any Restful call return a JSON response that includes both meta data and result data, like the representation shown below: // response to a GET that returns an array of elements { "status": "success", "count": 2, "type": "LoadServingEntity", "results":[ { "lseId": 2756, "name":"Georgia Power Co", "code":"7140", "websiteHome":"http://www.georgiapower.com/" }, { "lseId":1, "name":"City of Augusta", "code":"1000", "websiteHome":null }] } // an response that reports an API error { "status":"error", "count":2, "type":"Error", "results":[{ "code":"NotNull", "message":"An appKey must be supplied", "objectName":"requestSignature", "propertyName":"appKey" }, { "code":"NotNull", "message":"An appId must be supplied", "objectName":"requestSignature", "propertyName":"appId" }] }
🌐
Vinay Sahni
vinaysahni.com › best-practices-for-a-pragmatic-restful-api
Best Practices for Designing a Pragmatic RESTful API | Vinay Sahni
If this parameter is present, the API should switch to a full envelope mode where it always responds with a 200 HTTP status code and passes the real status code in the JSON payload. Any additional HTTP headers that would have been passed alongside the response should be mapped to JSON fields, like so:
🌐
LinkedIn
linkedin.com › pulse › what-should-api-response-structure-atiqur-rahman
What should be the API response structure?
May 9, 2023 - class BaseController extends Controller { public function sendResponse($result, $message, $code=200): JsonResponse { $response = [ 'success' => true, 'data' => $result, 'message' => $message, ]; return response()->json($response, 200); } public function sendError($error, $errorMessages = [], $code = 404): JsonResponse { $response = [ 'success' => false, 'message' => $error, ]; if(!empty($errorMessages)){ $response['data'] = $errorMessages; } return response()->json($response, $code); } }
🌐
Reddit
reddit.com › r/node › standardized formats for json responses and requests.
r/node on Reddit: Standardized formats for JSON responses and requests.
June 16, 2023 -

I'm working on an Express API, and I was curious what the current consensus is on JSON formats for API requests and responses? I've been using Google's JSON style guide, which I've enjoyed. Do you all have preferences? Are there pitfalls to watch out for?

🌐
Josip Miskovic
josipmisko.com › posts › rest-api-best-practices
12 REST API Best Practices to follow in 2023 ✔️
January 30, 2023 - Include the "Content-Type" header set to "application/json" in all requests and responses when sending JSON data. Use JSON even when communicating error messages. Don't just return plain text or HTML.