Posts - Update API

Update the specified Post.

Method PUT

Parameters

Name Details Type Required
id The ID of the Post. integer Yes

Body

{
    "title": "string",
    "body": "string",
    "category_id": 1,
    "tag_ids": [
        1,
        2,
        3
    ]
}

How to Use

fetch('https://simplecrudapi.com/api/posts/1', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    'title': 'Updated Post Title',
    'content': 'Updated content of the post',
    'category_id': 1,
    'tag_ids': [2, 3]
  })
})
	.then(response => response.json())
	.then(json => console.log(json))
	.catch(error => console.error('Error updating data:', error));

Response

{
    "data": {
        "id": 1,
        "title": "Updated Post Title",
        "content": "Updated content of the post",
        "category": {
            "id": 1,
            "name": "Education",
            "description": "Resources and information for lifelong learning"
        },
        "tags": [
            {
                "id": 2,
                "name": "Innovation",
                "description": "Minus vel qui et aut."
            },
            {
                "id": 3,
                "name": "Wellness",
                "description": "Minus vel qui et aut."
            }
        ],
        "category_id": 2,
        "created_at": "2024-11-09T12:34:56Z",
        "updated_at": "2024-11-09T13:00:00Z"
    }
}

Try Now

fetch('https://simplecrudapi.com/api/posts/1', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    'title': 'Updated Post Title',
    'content': 'Updated content of the post',
    'category_id': 1,
    'tag_ids': [2, 3]
  })
})
	.then(response => response.json())
	.then(json => console.log(json))
	.catch(error => console.error('Error updating data:', error));

Test with Open API

View Open API

Previous
Users API

Our Proudly Sponsors 🎉

© 2025 Simple CRUD API. All rights reserved.