Skip to content

Publish to WordPress

Use the following endpoint to publish a blog post via the API. If you have multiple WordPress sites integrated, provide the credentials for the specific site you want to publish to.

The API supports all WordPress REST API parameters including post scheduling, custom slugs, featured media, categories, tags, custom meta fields, and more. All optional parameters are documented in the examples below.

POST /api/v1/public/integrations/wordpress/publish

Include your API key in the Authorization header:

Terminal window
Authorization: Bearer YOUR_API_KEY
// Example: Publish a new blog post to WordPress with advanced options
const postData = {
credentials: {
websiteUrl: "https://myblog.example.com",
username: "wp_api_user",
password: "wp_api_application_password" // WordPress Application Password
},
content: {
title: "My Awesome Blog Post via API",
content: "<h1>Hello World</h1><p>This post was published using the API.</p>",
status: "publish", // Options: 'publish', 'draft', 'pending', 'private', 'future'
excerpt: "A brief description of this amazing post",
slug: "awesome-blog-post-api",
author: 1, // Author ID
featured_media: 123, // Featured image ID
comment_status: "open", // 'open' or 'closed'
ping_status: "open", // 'open' or 'closed'
format: "standard", // 'standard', 'aside', 'chat', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio'
sticky: false,
categories: [1, 2], // Array of category IDs
tags: [5, 6, 7], // Array of tag IDs
meta: {
custom_field: "Custom value",
seo_description: "SEO meta description"
}
}
};
// Endpoint: {API_ENDPOINTS.INTEGRATIONS.WORDPRESS.PUBLISH}
fetch('https://api.blogz.ai/api/v1/public/integrations/wordpress/publish', {
method: 'POST', // Use POST to create a new post
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify(postData) // Send credentials and content
})
.then(response => {
// Expecting JSON like { success: true, postUrl: "...", postId: "..." }
return response.json();
})
.then(data => console.log('Post published successfully:', data))
.catch(error => console.error('Error publishing to WordPress:', error));