Create a post
curl --request POST \
--url https://jsonplaceholder.typicode.com/posts \
--header 'Content-Type: application/json' \
--data '
{
"userId": 123,
"title": "<string>",
"body": "<string>"
}
'import requests
url = "https://jsonplaceholder.typicode.com/posts"
payload = {
"userId": 123,
"title": "<string>",
"body": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({userId: 123, title: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://jsonplaceholder.typicode.com/posts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://jsonplaceholder.typicode.com/posts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'userId' => 123,
'title' => '<string>',
'body' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://jsonplaceholder.typicode.com/posts"
payload := strings.NewReader("{\n \"userId\": 123,\n \"title\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://jsonplaceholder.typicode.com/posts")
.header("Content-Type", "application/json")
.body("{\n \"userId\": 123,\n \"title\": \"<string>\",\n \"body\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://jsonplaceholder.typicode.com/posts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"userId\": 123,\n \"title\": \"<string>\",\n \"body\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"userId": 123,
"id": 123,
"title": "<string>",
"body": "<string>"
}Endpoint examples
Create Post
Creates a new post (JSONPlaceholder fakes creation and returns an object with an id).
POST
/
posts
Create a post
curl --request POST \
--url https://jsonplaceholder.typicode.com/posts \
--header 'Content-Type: application/json' \
--data '
{
"userId": 123,
"title": "<string>",
"body": "<string>"
}
'import requests
url = "https://jsonplaceholder.typicode.com/posts"
payload = {
"userId": 123,
"title": "<string>",
"body": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({userId: 123, title: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://jsonplaceholder.typicode.com/posts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://jsonplaceholder.typicode.com/posts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'userId' => 123,
'title' => '<string>',
'body' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://jsonplaceholder.typicode.com/posts"
payload := strings.NewReader("{\n \"userId\": 123,\n \"title\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://jsonplaceholder.typicode.com/posts")
.header("Content-Type", "application/json")
.body("{\n \"userId\": 123,\n \"title\": \"<string>\",\n \"body\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://jsonplaceholder.typicode.com/posts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"userId\": 123,\n \"title\": \"<string>\",\n \"body\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"userId": 123,
"id": 123,
"title": "<string>",
"body": "<string>"
}Overview
Response notes
- Creates a new post. JSONPlaceholder fakes creation and responds with a new id.
- Great for demonstrating request bodies, validation, and response handling without needing a backend.
- userId (number, required): The author id.
- title (string, required): Title for the post.
- body (string, required): The content.
- name: Create a post
method: POST
path: /posts
headers:
Content-Type: application/json
body:
json:
userId: 1
title: "Hello Mintlify"
body: "This is a demo post created from the API playground."
- Status 201: Returns the post object with a generated id.
- JSONPlaceholder does not persist data; subsequent GETs won’t include this post.
- Use this alongside GET /posts to illustrate the difference between mocked creation and read-only data.