Types from a real payload
Writing types for an API response by hand is slow and drifts from reality. Paste a real response and every nested object becomes a named interface, arrays get the type of their items, and you choose the root name and interfaces or type aliases.
How the shapes are inferred
When an array holds several objects, their fields are merged: a field missing from some items is marked optional (?), a field that is null somewhere becomes a union such as string | null. The more varied the sample, the more accurate the types; review fields that were always null, typed as null only.