apirestpaypal

How to resolve Paypal API "SENDER_RESTRICTED" error


I'm making a payout request with the PayPal REST API.

await axios.post('https://api-m.paypal.com/v1/payments/payouts', {
    sender_batch_header: {
    sender_batch_id: Math.random().toString(36).substring(2, 15),
    email_subject: "You have a payment!",
    email_message: message
    },
    items: [{
    recipient_type: "EMAIL",
    amount: {
        currency: "USD",
        value: (Math.round(amount * 100) / 100).toFixed(2)
    },
        note: "Thanks for your business!",
        receiver: email,
        sender_item_id: Math.random().toString(36).substring(2, 15)
    }]
    }, {
    headers: {
    "Authorization": `Basic ${Buffer.from(key.client_id + ":" + key.client_secret).toString('base64')}`,
    "Content-Type": "application/json"
    }
});

This request consistently returns a 403 SENDER_RESTRICTED error. Response Data:

{
    name: 'SENDER_RESTRICTED',
    message: 'Authorization error occurred.',
    debug_id: 'ede691decdb68',
    information_link: 'https://developer.paypal.com/docs/api/payments.payouts-batch/#errors',
     links: []
}

The PayPal REST API documentation doesn't tell me what the error means. Since it throws a different error if I try to use random credentials it seems that the credentials I am using are already correct.


Solution

  • I solved this by double-checking the Credentials I was using. I was using the wrong app credentials - specifically the developer credentials. It seems like a simple enough fix, but I couldn't find info about this anywhere in their documentation.

    Check the PayPal developer dashboard and check to see if you are using the app with Payout permissions enabled - then use that app's credentials to make the request.