Named Sources

With Named Sources you can make sure that your applications communicate with CARTO without exposing SQL queries in the code or through the network requests.

Using Named Sources in your application does not change the overall architecture, which will remain very efficient, lightweight and modern — in most cases, it won't require additional backend services.

How does a Named Source work

Named Sources work by using a very simple principle:

  1. Store a SQL query in CARTO as a Named Source.

  2. Use your new Named Source in a CARTO for Developers application by simply referencing its name instead of a SQL Query, in any function or endpoint that accepts a sqlQuery parameter.

const data = vectorQuerySource({
  ...config,
  sqlQuery: 'named_source_1', // your named source
});

Creating a Named Source

To create a new Named Source, go to Developers > Named Sources and click on "Create New". For each Named Source, you'll need to define:

  • Name: this will be the reference you will be using in your application's code.

  • SQL statement: the SQL query that will be used when this Named Source is referenced. Please note that all SQL functionalities are supported, including query parameters.

Click on "Save Changes" and your Named Source will be ready to be used.

Managing Named Sources

Named Sources can be edited or deleted at any time. To manage them, simply click the three-dot menu next to each Named Source.

Named Sources API

You can programmatically manage and deploy Named Sources using the Named Sources API. You can also programmatically assign Named Sources to the grants in API Access Tokens using the Tokens API. For more information, check the CARTO API Reference.

Last updated

Was this helpful?