Unavailable action with Floating IPs API

I’m using the v2 API to assign Floating IPs to different droplets. It’s working great in Postman, however i’m having some issues getting it to work in PHP with CURL. I’m not sure quite where i’m going wrong, any pointers would be greatly appreciated!


 [id] => not_found
 [message] => The specified action type is not available


     * Change where a Floating IP Points
     * @param string $floatingIp
     * @param int $dropletId
     * @return array
    public function assignFloatingIp($floatingIp, $dropletId)
        $data = array (
            'type' => 'assign',
            'droplet_id' => $dropletId

        $response = $this->makeQuery(''. $floatingIp .'/actions', 'POST', $data);

        if (!array_key_exists('action', $response)) {
            echo ucfirst($this->response['id']) . "<br>" . $this->response['message'];

        return $response;

    * Make query
    * @param string $url
    * @param string $method
    * @param array $data
    * @return array
    private function makeQuery($url, $method = 'GET', $data = null)
        try {
            $headers = array('Authorization: Bearer '.$this->token);

            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);

            if ($data) {
                $data = json_encode($data);

                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                        'Content-Length: ' . strlen($data)

            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

            //Data are stored in $data
            $response = json_decode(curl_exec($curl), true);

            return $response;
        } catch (Exception $e) {
            return $e->getMessage();

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Eddie Zaneski
DigitalOcean Employee
DigitalOcean Employee badge
March 20, 2018
Accepted Answer

Looks like your request payload is correct from

I’ve always had trouble making requests using native curl. Perhaps give something like Guzzle a shot just to confirm the request is correct and work back from some examples? I always reference how Twilio does it

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.