'Why do I get 403 error only on certain apis on SendGrid Api v3?

I am experiencing a strange problem on using SendGrid APIs. Basically, there are certain API calls that I can perform, and some other returns a 403 error.

I can send single emails :

$email = new \SendGrid\Mail\Mail(); 
    $email->setFrom("[email protected]", "NAMEFROM");
    $email->setSubject("Sending with SendGrid is Fun");
    $email->addTo("[email protected]", "NAMEFROM");
    $email->addContent("text/plain", "and easy to do anywhere, even with PHP");
    $email->addContent(
        "text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
    );
    $sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
    try {
        $response = $sendgrid->send($email);
        print $response->statusCode() . "\n";
        print_r($response->headers());
        print $response->body() . "\n";
    } catch (Exception $e) {
        echo 'Caught exception: '. $e->getMessage() ."\n";
    }

But I am not able to send massive emails as campaigns:

$request_body = json_decode('{
        "id": <DATA HIDDEN>,
        "title": "May Newsletter",
        "subject": "New Products for Summer!",
        "sender_id": <DATA HIDDEN>,
        "list_ids": [
            "<DATA HIDDEN>"
        ],
        "html_content": "<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>",
        "plain_content": "Check out our summer line!",
    }');
    $sg = new SendGrid(config('services.extra.SENDGRID_API_KEY')); 
    $response = $sg->client->campaigns()->post($request_body);

This call returns 403, "message":"access forbidden". Without any other indication.

Even the API Calls that follow :

https://api.sendgrid.com/v3/senders/<data hidden>
https://api.sendgrid.com/v3/senders

return 403.

I have a free plan and a verified email address (the "from address"). All the tokens I have generated have the "full" permission set.

I haven't read anything about the accessibility of an API regarding the price plan (free/paid) in the docs, but still, I wonder if anybody knows anything.

Any help is appreciated.



Solution 1:[1]

The Email API and Marketing Campaigns are two different products (see the two different tabs on the pricing page). You can use both within one account, you just need to activate both products. I think you need to go to your account settings and activate the Marketing Campaigns product and then your API requests will succeed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 philnash