I have a simple web page where I show my CartoDB map and a dataset. I want to know if there is any way to insert new rows into my CartoDB dataset from code, so external users can add points to the map by clicking on it.


You can do this by using CartoDB in combination with the Leaflet Draw plugin. You can check all the information in this blogpost.

Basically, with the plugin people will be able to draw geometries on top of your map. You'll need to save these geometries in your database, and you can do this, as the example shows, by adding a security definer to your table so that you can perform write actions on it without being authenticated.

CartoDB also lists some libraries for the SQL API that you can use from your backend in order to insert the data.

  • Useful answer. So you can do updates, but not inserts, directly with SQL API. – John Powell Apr 28 '15 at 13:45
  • 1
    You can do both updates and inserts (and deletes, and selects...) from the SQL API, both those calls need to be authenticated. – iriberri Apr 28 '15 at 16:15
  • That seems exactly what I was looking for! Thank you, I'll be looking at it the next days! – mrvinent May 5 '15 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.