The auto-generated unique identifier for the new post
POST
/posts BearerCreate Post
Create a new blog post with title, body, and author details via authenticated POST request to the posts endpoint
Overview
Creates a new blog post. Requires authentication.
Authorization
Note
This endpoint requires a Bearer token for authentication.
Request Body
Body Parameters
title requiredTitle of the post
body requiredContent of the post. Supports plain text or markdown.
userId requiredID of the user creating the post
Response
Returns the created post object with the assigned ID.
id integertitle stringThe title provided in the request
body stringThe content provided in the request
userId integerThe user ID provided in the request
Error Responses
| Status | Description |
|---|---|
400 | Invalid request body - missing required fields |
401 | Unauthorized - missing or invalid Bearer token |
curl -X POST "https://jsonplaceholder.typicode.com/posts" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ -d '{ "title": "My First Blog Post", "body": "This is the content of my first blog post.", "userId": 1 }'const response = await fetch("https://jsonplaceholder.typicode.com/posts", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer <token>" }, body: JSON.stringify({ title: "My First Blog Post", body: "This is the content of my first blog post.", userId: 1 })});
const data = await response.json();console.log(data);import requests
response = requests.post( "https://jsonplaceholder.typicode.com/posts", headers={"Authorization": "Bearer <token>"}, json={ "title": "My First Blog Post", "body": "This is the content of my first blog post.", "userId": 1 })print(response.json()){ "id": 101, "title": "My First Blog Post", "body": "This is the content of my first blog post.", "userId": 1}{ "error": "Missing required field: title"}Was this page helpful?
Request
curl -X POST "https://jsonplaceholder.typicode.com/posts" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>"const response = await fetch("https://jsonplaceholder.typicode.com/posts", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer <token>"
},
});
const data = await response.json();
console.log(data);import requests
response = requests.post(
"https://jsonplaceholder.typicode.com/posts",
headers={'Content-Type':'application/json','Authorization':'Bearer <token>'},
)
print(response.json())package main
import (
"fmt"
"net/http"
"io"
)
func main() {
req, _ := http.NewRequest("POST", "https://jsonplaceholder.typicode.com/posts", nil)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer <token>")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}Response
Send a request to see the response
Authorization
Headers
Body
Response