When using the upcoming invoice endpoint, the response represents an invoice that doesn't exist yet, and does not have an id.
Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer’s discount.
The openapi spec for Invoice here, however, does not mark id as nullable: true. Which means that code generators will not make it optional, and could fail while parsing.