using gmail api to filter out emails from some format

I am trying out gmail api and having hard time with filters. I want to exclude some emails, something like filtering out emails sent to “myname@mycompany.com”, having no luck finding anything in gmail api docs.

I am using nodejs client and constructing query like this.

    const result = await gmail.users.messages.list({
      auth: oauth2Client,
      userId: "me",
      q: `in:sent after:2021/09/01`
    })

does gmail api have something like not:myname@mycompany.com or something like exclude:myname@mycompany.com or is this not possible at all?

Answer

Could you append -keyword at query

const result = await gmail.users.messages.list({
      auth: oauth2Client,
      userId: "me",
      q: `in:sent after:2021/09/01 -myname@mycompany.com`
    });