sendgrid error "403 access forbidden" when trying to create sub user

Viewed 36

I get 403 access forbidden error:

 $apiKey= env('API_KEY_FOR_SENDGRID');
        $sg = new \SendGrid($apiKey);

         // Create Subuser #
         
         $request_body = json_decode('{
            "email": "subuser_email",
            "ips": [
                "1.1.1.1",
                "2.2.2.2"                ],
            "password": "password",
            "username": "subuser_username"
          }');
          
          try {
              $response = $sg->client->subusers()->post($request_body);
              dd($response);
             
          } catch (Exception $e) {
              echo 'Caught exception: ',  $e->getMessage(), "\n";
          }

I have configured every single permission to 'Full Access' of api key But i got the same error {"errors":[{"field":null,"message":"access forbidden"}]}.
My question: what i do error is removed and sub user is created?

0 Answers
Related