201

Created

2xx Success The request succeeded and led to the creation of a resource

Code Examples

Here are examples of how to test HTTP 201 responses in different programming languages:

Select options below to see how to use advanced features in your code:

Request:
curl https://free.mockerapi.com/201
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}
Request:
fetch('https://free.mockerapi.com/201')
  .then(response => {
    console.log('Status:', response.status); // 201
    return response.json();
  })
  .then(data => {
    console.log('Success:', data);
  })
  .catch(error => {
    console.error('Error:', error);
  });
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}
Request:
import requests

response = requests.get('https://free.mockerapi.com/201')

print(f'Status Code: {response.status_code}')  # 201
print(f'Response: {response.json()}')
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}
Request:
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}
Request:
require 'net/http'
require 'json'

uri = URI('https://free.mockerapi.com/201')
response = Net::HTTP.get_response(uri)

puts "Status Code: #{response.code}"  # 201
puts "Response: #{JSON.parse(response.body)}"
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}
Request:
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    resp, err := http.Get("https://free.mockerapi.com/201")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Printf("Status Code: %d\n", resp.StatusCode)  // 201

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }

    fmt.Printf("Response: %s\n", body)
}
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}
Request:
import java.net.http.*;
import java.net.URI;

public class HttpStatusTest {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://free.mockerapi.com/201"))
            .GET()
            .build();

        HttpResponse response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println("Status Code: " + response.statusCode());  // 201
        System.out.println("Response: " + response.body());
    }
}
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}
Request:
const https = require('https');

https.get('https://free.mockerapi.com/201', (res) => {
  console.log('Status Code:', res.statusCode);  // 201

  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    console.log('Response:', JSON.parse(data));
  });
}).on('error', (err) => {
  console.error('Error:', err.message);
});
Response Body:
{
  "success": true,
  "status": 201,
  "statusText": "Created - Request succeeded and led to the creation of a resource",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/201",
    "fullUrl": "https://free.mockerapi.com/201"
  }
}

What is HTTP 201 Created?

HTTP 201 Created indicates that the request has been fulfilled and resulted in one or more new resources being created. This status code is typically sent in response to POST requests or some PUT requests that create new resources.

  • Location Header: The response should include a Location header with the URI of the newly created resource
  • POST Requests: Most commonly used when creating resources via POST
  • Resource State: The resource has been successfully created and is available
  • Response Body: May contain a representation of the newly created resource

When Does This Happen?

A 201 Created response is returned when a new resource has been successfully created. This is more specific than 200 OK and communicates the exact outcome. You'll see this status code when:

  • Creating a new user account via a registration endpoint
  • Submitting a form that creates a new database record
  • Uploading a new file or document to a server
  • Creating a new item in a RESTful API (e.g., POST /api/products)
  • Any operation that results in a new resource being stored on the server

Try It Live

Click the button below to make a live request and see the 201 Created response

Common Use Cases

โœ… Resource Creation Testing

Test how your application handles successful resource creation and processes the newly created resource data.

๐Ÿ”„ POST Request Testing

Mock successful POST responses in tests without needing to actually create resources in a database.

๐ŸŽจ Frontend Development

Develop and test UI flows for creating new items before the backend creation logic is implemented.

๐Ÿ“ API Documentation

Provide working examples of resource creation endpoints in API documentation.

๐Ÿงช Integration Testing

Simulate resource creation scenarios in integration tests without side effects.

๐Ÿ” Status Code Validation

Verify that your application correctly distinguishes between 200 OK and 201 Created responses.

Related Success Status Codes