Firing cURL/API call on record creation/save?

I want to use the Twilio LookUp API to give me some data about Lead/Contact Phone numbers when the record is created.

Record created (or new number added) → API Call to Lookup Phone Number → Update “Phone Type (Mobile/Landline)” field

You can use docevents for this. When doctype is created , updated or submitted some events are called on which you can call your API. So inside the doctype class for which you are creating the records for you can add on_update function and right the API calling logic in that. For ex if the doctype is called Contact. So inside Contact Doctype Folder in, Contact.py you can write something like this.

class Contact(Document):

	def on_update(self):
	# Logic for calling twilio api