Skip to main content
POST
/
blogs
Create Blog
curl --request POST \
  --url https://api.stru.ai/blogs \
  --header 'Content-Type: application/json' \
  --data '{
  "title": "<string>",
  "content": "<string>",
  "author": "<string>",
  "description": "<string>",
  "tags": [
    {}
  ],
  "thumbnail": "<string>",
  "slug": "<string>",
  "published": true
}'
{
  "422": {},
  "500": {},
  "id": "<string>",
  "title": "<string>",
  "content": "<string>",
  "author": {},
  "description": {},
  "tags": [
    {}
  ],
  "thumbnail": {},
  "slug": "<string>",
  "published": true,
  "created_at": "<string>",
  "updated_at": "<string>"
}

Overview

Create a new blog post with title, content, and optional metadata. The API automatically generates slugs and descriptions if not provided.
Auto-generation: Leave slug and description empty for automatic generation from title and content.

Request Body

title
string
required
Blog post title (1-500 characters)
"title": "Getting Started with SAP2000 API"
content
string
required
Full blog content in markdown format (minimum 1 character)
"content": "# Introduction\n\nThis tutorial covers..."
author
string
Author name (optional)
"author": "Jane Smith"
description
string
Short description or excerpt (optional, auto-generated from content if not provided)
"description": "A comprehensive guide to SAP2000 automation"
tags
array
Array of tag strings for categorization (optional)
"tags": ["sap2000", "api", "automation"]
thumbnail
string
Thumbnail image URL (optional)
"thumbnail": "https://example.com/sap2000-thumb.jpg"
slug
string
Custom URL-friendly slug (optional, auto-generated from title if not provided)
"slug": "custom-sap2000-guide"
published
boolean
default:"true"
Publication status (optional, defaults to true)
"published": false

Response

Returns the created blog post object with auto-generated fields.
id
string
Unique blog post UUID (auto-generated)
title
string
Blog post title
content
string
Full markdown content
author
string | null
Author name
description
string | null
Short description (auto-generated if not provided)
tags
array
Array of tag strings
thumbnail
string | null
Thumbnail image URL
slug
string
URL-friendly slug (auto-generated if not provided)
published
boolean
Publication status
created_at
string
ISO 8601 creation timestamp (auto-generated)
updated_at
string
ISO 8601 last update timestamp (auto-generated)

Example Requests

# Create with only required fields
curl -X POST https://api.stru.ai/blogs \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Test Blog Post",
    "content": "# Hello World\n\nThis is my first blog post."
  }'

Example Response

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "title": "Getting Started with SAP2000 API",
  "content": "# Introduction\n\nThis tutorial covers...",
  "author": "Jane Smith",
  "description": "A comprehensive guide to SAP2000 automation",
  "tags": ["sap2000", "api", "automation"],
  "thumbnail": "https://example.com/sap2000-thumb.jpg",
  "slug": "getting-started-with-sap2000-api",
  "published": true,
  "created_at": "2025-10-11T10:30:00.000000",
  "updated_at": "2025-10-11T10:30:00.000000"
}
Status Code: 201 Created

Error Responses

422
Validation Error
Request validation failed - missing required fields or invalid data
{
  "detail": [
    {
      "loc": ["body", "title"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
500
Internal Server Error
Server error occurred
{
  "detail": "Failed to create blog: [error message]"
}

Auto-generation Features

If no slug is provided, it’s automatically generated from the title.Rules:
  • Converted to lowercase
  • Spaces replaced with hyphens
  • Special characters removed
  • Ensured to be unique (number appended if duplicate)
Examples:
"Getting Started with SAP2000" → "getting-started-with-sap2000"
"My Blog!" → "my-blog"
"My Blog" (duplicate) → "my-blog-2"
If no description is provided, it’s extracted from content.Rules:
  • First 200 characters of content
  • Markdown syntax stripped
  • Truncated at word boundary
Example:
Content: "# Introduction\n\nThis is a comprehensive guide..."
→ Description: "This is a comprehensive guide..."
created_at and updated_at are automatically set to current UTC time.Format: ISO 8601
"2025-10-11T10:30:00.000000"
A unique UUID v4 is automatically generated for the id field.Format:
"a1b2c3d4-e5f6-7890-abcd-ef1234567890"

Best Practices

Use auto-generation - Let the API generate slugs and descriptions unless you need custom values for SEO.
Draft before publishing - Create posts with published: false to draft content before making it live.
Validate before sending - Check title length (≤500 chars) and content presence client-side.
Tag consistently - Use consistent tag names (case-sensitive) across posts for better filtering.
Custom slugs for SEO: Override auto-generated slugs with SEO-optimized versions like best-etabs-tutorial-2025.
Slug uniqueness: If your custom slug already exists, a number will be appended automatically (my-slug-2).