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!
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 :)
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.