Create invitations to organization / send email not working

Hi there!

I am trying to send an invitation email for an organization to a user via the management API. I have followed the docs but unfortunately it does not work at all… What am I doing wrong?

My custom resolver looks like this:

export const sendOrganisationInvites = async ( token, orgId, invitee, inviter ) => {

  const body = {
    "inviter": {
    "name": inviter
  },
    "invitee": {
      "email": invitee.email
    },
    "client_id": process.env.CLIENT_ID,
    "app_metadata": invitee.app_metadata,
    "ttl_sec": 0,
    "send_invitation_email": true
  }
  
  const res = await fetch(`${process.env.AUTH0_DOMAIN}/api/v2/organizations/${orgId}/invitations`,
      {
        method: 'POST',
        headers: {
          'content-type': 'application/json',
          'authorization': `${token.token_type} ${token.access_token}`,
          'cache-control': 'no-cache'
        },
        body: JSON.stringify(body)
      });
    
    if ( res.error ) {
      return res.message;
    }

    return res.json();
}

I have checked if the parameters token, orgId, invitee and inviter contain the right information (they do). When I execute this resolver I get a really weird response and obviously no email to invitee.email.

Return from res.json(): {"size":0,"timeout":0}

Can someone help? This is driving me crazy :crazy_face: