POST /wp-json/content-api/v1/post/
Creates a new post or page in WordPress.
Authentication
This endpoint requires a Bearer token in the Authorization header. To authenticate:
- Go to Content API > Settings in your WordPress admin panel.
- Set a secure token in the “Token” field and save it.
- Include the token in your request header as follows:
Authorization: Bearer <your-token-here>
Replace <your-token-here> with the token you configured.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| title | string | The title of the post | Yes |
| content | string | The content of the post (HTML allowed) | Yes |
| featured_image | string | URL of the featured image | No |
| images | array | Array of image URLs to embed in content | No |
| categories | array | Array of category names (ignored for pages) | Yes (for posts) |
| tags | array | Array of tag names | No |
| yoast | object | Yoast SEO metadata (title, description, social settings) | No |
| post_type | string | Type of post (default: “post”) | No |
Example Request
{
"title": "My New Post",
"content": "My content",
"featured_image": "https://www.example.com/image.jpg",
"images": ["https://www.example.com/image1.jpg"],
"categories": ["News"],
"tags": ["update"],
"yoast": {
"title": "Custom SEO Title",
"description": "SEO Description",
"premium": {
"social_appearance": {
"title": "FB Title",
"description": "FB Description",
"image": "https://example.com/fb-image.jpg"
},
"x": {
"title": "Twitter Title",
"description": "Twitter Description",
"image": "https://example.com/twitter-image.jpg"
}
}
},
"post_type": "post"
}
Example Response
{
"success": true,
"post_id": 123
}
Possible Errors
| Code | Message | Description | HTTP Status |
|---|---|---|---|
| not_authorized | Not Authorized | The provided Bearer token is invalid or does not match the configured token. | 401 |
| data_missing | Missing parameters: [field1, field2, …] | One or more required fields (title, content, post_type, categories, tags, yoast) are missing in the request. Categories are not required for pages. | 400 |
| post_creation_failed | Failed to create post | An error occurred while inserting the post into the database. | 500 |
| media_upload_failed | [Error message from WordPress] | Failed to upload the featured image or content images to the media library (e.g., invalid URL, server error). | 500 |
| category_creation_failed | [Error message from WordPress] | Failed to create one or more categories specified in the request. | 500 |