Network details not returned on API droplet creation

March 10, 2019 272 views
API Networking Ubuntu 18.04

Hello,

When creating a new droplet using the API, the response does not contain the network details of the newly created droplet (like the public and private IP adresses). In the response JSON, I have the following element :

"networks":{"v4":[],"v6":[]}

As you can see the "v4" and the "v6" arrays are empty. Is there an option I need to pass in the request to get these details or am I just supposed to make an additional request to get the newly created droplet's details (by passing the droplet ID that is returned from the create droplet request).

Thanks for your help.

1 Answer

Your last instinct is correct... You need to make an additional request to get the newly created droplet's details (by passing the droplet ID that is returned from the create droplet request).

When you make a command to create a droplet the API needs to give you an immediate response, but actually provisioning of the Droplet (including associating i with IP addresses) might take up to 55 seconds.

The create command will always return an id, and then you can poll the /v2/droplets/$DROPLET_ID endpoint for the provisioned IP info. https://developers.digitalocean.com/documentation/v2/#retrieve-an-existing-droplet-by-id

Have another answer? Share your knowledge.