POST /posts Bearer

Create 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

Request Body

Body Parameters

title required
string

Title of the post

body required
string

Content of the post. Supports plain text or markdown.

userId required
integer

ID of the user creating the post

Response

Returns the created post object with the assigned ID.

id integer

The auto-generated unique identifier for the new post

title string

The title provided in the request

body string

The content provided in the request

userId integer

The user ID provided in the request

Error Responses

StatusDescription
400Invalid request body - missing required fields
401Unauthorized - missing or invalid Bearer token
Terminal window
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"
}
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