Report this

What is the reason for this report?

How do I find domain record_id using api v2

Posted on July 5, 2015

Hi, I am using the following api v2 command to create a new A record for users when they register:

curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer **KEY**' -d '{"type":"A","name":"**NAME**","data":"46.101.35.92","priority":null,"port":null,"weight":null}' "https://api.digitalocean.com/v2/domains/mydomain.com/records"

If the user decides to delete their account, I need the A record to be removed as well, but this requires me to provide the record id. how do I find the record id of a record using the api?



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!

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.

Part of the response for the record creation process is the record ID. I would suggest storing this ID so you can easily send it to the delete endpoint when you need to.

This is a far more efficient way than to list all domain records for your domain, and then filter through them by type/name/data to find the ID you need, and then send the delete request.

This is a possible method to achieve what you want, but it’s slower and unnecessary if the ID is saved during the creation process. This method is perhaps good for a fallback in case there is some sort of error using your saved record ID.

See ‘RESPONSE BODY’ on the right: /documentation/v2/#create-a-new-domain-record

Hi, I will find a way to store the outputted id along with the username. Thank you for your response :)

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.