Skip to content

Create Blog

Use the following endpoint to create a new blog post via the API.

Ensure you send the parameters nested under a blogParams key in the JSON body.

POST /api/v1/public/create-blog

Include your API key in the Authorization header:

Terminal window
Authorization: Bearer YOUR_API_KEY
const blogParams = {
topicKeywords: ["AI", "content creation", "API"],
language: { name: "English", value: "en" },
toneStyle: { name: "Informal", value: "Informal", customValue: "" },
contentStructure: { name: "Listicles", value: "Listicles", customValue: "" },
callToAction: { name: "Learn More", value: "Learn more about our services.", customValue: "" },
targetAudience: { name: "Tech enthusiasts", value: "Tech enthusiasts", customValue: "" },
blogLength: { name: "Medium", value: "Medium", customValue: "" }, // Required: "Short", "Medium", or "Long"
category: "ai-tools", // Optional
hyperlinks: ["https://www.blogz.ai", "https://www.openai.com"], // Optional - Example hyperlinks
baseUrlForLinkedBlog: "https://www.mywebsite.com", // Optional
metaData: {
customKey: "customValue"
}, // Optional: Custom metadata
externalOpenAiApiKey: "your-openai-api-key" // Optional: Use your own OpenAI API key
};
// Endpoint: {API_ENDPOINTS.BLOGS.CREATE}
fetch('https://api.blogz.ai/api/v1/public/create-blog', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ blogParams }) // IMPORTANT: Nest parameters under 'blogParams' key
})
.then(response => response.json() // Expecting JSON data for a successful POST)
.then(data => console.log('Blog created:', data))
.catch(error => console.error('Error creating blog:', error));