Discourse REST API: create topics and posts programmatically
domain: discourse.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
Generate an API key from the target Discourse instance's admin panel (Admin > API), scoped either globally or to a specific user, per docs.discourse.org.
Send the key via the Api-Key and Api-Username headers — never as a URL query parameter, since Discourse's own docs warn query-string keys can leak via logs/traffic.
Create a new topic (with its first post) via POST /posts.json, supplying title, raw (Markdown body), and category (category id).
Create a reply in an existing topic using the same /posts.json endpoint but supplying topic_id instead of title/category.
Handle standard Discourse validation and rate limits (minimum post length, new-user posting limits) since API-created content is subject to the same site rules as UI-created content.
Known gotchas
Content created via API still obeys the acting api_username's trust level and site limits — a low-trust user can get silently throttled.
title/category are only used for new topics; when replying, supply topic_id and Discourse ignores those fields.
Required fields and validation can vary slightly by Discourse version/installed plugins — check the target instance's own /admin/api settings before building.
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?