New contact and invoice process

I need help with the process for creating an invoice for a new contact.

We need to generate invoices via requests on our website. From the looks of it this would require separate POST requests but could anyone help with how to check if a contact already exists if you don’t have the contact ID? How do I do the following?

  1. Collect Contact info, check if exists, if yes get ID, if no create new contact
  2. Create invoice for contact