Common Tasks
Practical Notra API examples for common implementation questions.
how-to · beginner · 6m
applies to notra-api, typescript
Update an existing post
Use PATCH /v1/posts/{postId} to update an existing post and return the updated post object.
type UpdatePostRequest = { title?: string; markdown?: string; status?: "draft" | "published";};type Post = { id: string; title: string; content: string; markdown: string; recommendations: string | null; contentType: string; sourceMetadata: unknown; status: "draft" | "published"; createdAt: string; updatedAt: string;};type UpdatePostResponse = { organization: { id: string; slug: string; name: string; logo: string | null; }; post: Post;};async function updatePost( postId: string, updates: UpdatePostRequest): Promise<UpdatePostResponse> { const response = await fetch(`https://api.usenotra.com/v1/posts/${postId}`, { method: "PATCH", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.NOTRA_API_KEY}`, }, body: JSON.stringify(updates), }); if (!response.ok) { throw new Error(`Failed to update post: ${response.status}`); } return (await response.json()) as UpdatePostResponse;}const updated = await notra.content.updatePost({ postId: "post_abc", title: "Ship notes for week 11", markdown: "# Ship notes\n\nWe shipped a faster editor.", status: "published",});console.log(updated.post);Create a new post
Notra does not currently expose a direct POST /v1/posts endpoint for manually creating a post with arbitrary fields such as author.
If you want Notra to create content for you, use POST /v1/posts/generate instead.
Warning
If a guide or AI answer suggests POST /v1/posts or an author field for post creation, that information is not correct for the current Notra API.
Did this work on your setup?
Not rated yet