Adding an image to a non existing post

I am not sure this answers your question directly, but as technical trivia — WordPress actually creates a posts as soon as you open editor, with auto-draft status. This is being used precisely to have a target for things like attachments and custom field before it is actually saved by user.

So when user “saves” the post for the first times it’s not actually being created, but existing auto-draft is getting changed into draft or published post.

You might have to either replicate this logic or rebuild related functionality, which relies on it.