Skip to main content
If you call the API with fetch, these types are a good starting point.
// Multiple posts
const listResponse = await fetch(
  "https://api.usenotra.com/v1/YOUR_ORGANIZATION_ID/posts/",
  {
    headers: { Authorization: `Bearer ${process.env.NOTRA_API_KEY}` },
  }
);
const listData: NotraPostListResponse = await listResponse.json();

// Single post
const postResponse = await fetch(
  "https://api.usenotra.com/v1/YOUR_ORGANIZATION_ID/posts/YOUR_POST_ID",
  {
    headers: { Authorization: `Bearer ${process.env.NOTRA_API_KEY}` },
  }
);
const postData: NotraPostResponse = await postResponse.json();

Type Definitions

You can copy these types into your project:
export type Post = {
  id: string;
  title: string;
  content: string; // HTML string
  markdown: string;
  contentType: "changelog";
  createdAt: string;
  updatedAt: string;
};

export type Pagination = {
  limit: number;
  currentPage: number;
  nextPage: number | null;
  previousPage: number | null;
  totalItems: number;
  totalPages: number;
};

export type NotraPostListResponse = {
  posts: Post[];
  pagination: Pagination;
};

export type NotraPostResponse = {
  post: Post;
};
Copy these type definitions into a types/notra.ts file in your project.

Zod Schemas

For runtime validation, you can use these Zod schemas:
import { z } from "zod";

export const PostSchema = z.object({
  id: z.string(),
  title: z.string(),
  content: z.string(), // HTML string
  markdown: z.string(),
  contentType: z.literal("changelog"),
  createdAt: z.string().datetime(),
  updatedAt: z.string().datetime(),
});

export const PaginationSchema = z.object({
  limit: z.number(),
  currentPage: z.number(),
  nextPage: z.number().nullable(),
  previousPage: z.number().nullable(),
  totalItems: z.number(),
  totalPages: z.number(),
});

export const PostListResponseSchema = z.object({
  posts: z.array(PostSchema),
  pagination: PaginationSchema,
});

export const PostResponseSchema = z.object({
  post: PostSchema,
});