> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usenotra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Common Tasks

> Practical Notra API examples for common implementation questions.

## Update an existing post

Use `PATCH /v1/posts/{postId}` to update an existing post and return the updated post object.

<CodeGroup>
  ```typescript fetch theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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;
  }
  ```

  ```typescript SDK theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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);
  ```
</CodeGroup>

## 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.
</Warning>
