Posts - Create API

Create a new Post.

Method POST

Body

{
    "title": "Sample Post Title",
    "body": "This is a sample post body.",
    "category_id": 1,
    "tag_ids": [
        1,
        2,
        3
    ]
}

How to Use

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

Response

{
    "data": {
        "id": 1,
        "title": "Sample Post Title",
        "content": "ESample Post Description.",
        "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."
            }
        ],
        "created_at": "2024-11-09T19:58:46+00:00",
        "updated_at": "2024-11-09T19:58:46+00:00"
    }
}

Try Now

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

Test with Open API

View Open API

Previous
Users API

Our Proudly Sponsors 🎉

© 2025 Simple CRUD API. All rights reserved.