How do I find domain record_id using api v2

July 5, 2015 956 views
API DNS Debian

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":"","priority":null,"port":null,"weight":null}' ""

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?

2 Answers

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

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

Have another answer? Share your knowledge.