For the complete documentation index, see llms.txt. This page is also available as Markdown.

Named Sources API

Server-side aliases for SQL queries.

A named source maps a name to a SQL query stored in CARTO. Your application references the name, so the query text never reaches the browser — useful when the SQL reveals schema details, business logic, or filters you don't want users editing.

You can also restrict a connection to named sources only, which rejects raw SQL entirely. See Named Sources in the user manual.

Endpoint
What it does

POST /v3/named-sources

Create a named source

GET /v3/named-sources

List named sources

GET /v3/named-sources/{name}

Get a named source

PATCH /v3/named-sources/{name}

Update a named source

DELETE /v3/named-sources/{name}

Delete a named source

These endpoints need an OAuth Access Token. See Authorization.

Names are lowercase letters, digits, hyphens and underscores — 3 to 51 characters, starting with a letter or digit and not ending in a hyphen or underscore.

Once created, a named source can be referenced wherever the Maps and SQL APIs accept a query, and granted in an API Access Token like any other source.

Endpoints

Create a named source

post
/v3/named-sources

Creates a named source — an alias for a SQL query that you can reference from the Maps and SQL APIs without exposing the query itself.

Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Body
namestringRequired

Lowercase alphanumerics, hyphens and underscores. Must start with a letter or digit, must not end with a hyphen or underscore, and must be 3 to 51 characters long.

Pattern: ^[a-z0-9][a-z0-9\-_]{2,50}(?<![-_])$
sourcestringRequired

The SQL query this name resolves to.

Responses
200

The named source was created.

application/json
namestringOptional
sourcestringOptional
accountIdstringOptional
userIdstringOptional
createdAtstringOptional
updatedAtstringOptional
post/v3/named-sources

List named sources

get
/v3/named-sources
Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Query parameters
searchstringOptional

Filter by name.

pageinteger · min: 1OptionalDefault: 1
pageSizeintegerOptionalDefault: 10
orderBystring · enumOptionalDefault: createdAtPossible values:
orderDirectionstring · enumOptionalDefault: DESCPossible values:
Responses
200

The named sources.

application/json
get/v3/named-sources

Get a named source

get
/v3/named-sources/{name}
Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Path parameters
namestringRequired

The name of the named source.

Example: my_named_source_1
Responses
200

The named source.

application/json
namestringOptional
sourcestringOptional
accountIdstringOptional
userIdstringOptional
createdAtstringOptional
updatedAtstringOptional
get/v3/named-sources/{name}

Update a named source

patch
/v3/named-sources/{name}

Changes the query a named source points to. The name can't change.

Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Path parameters
namestringRequired

The name of the named source.

Example: my_named_source_1
Body
sourcestringRequired
Responses
200

The updated named source.

application/json
namestringOptional
sourcestringOptional
accountIdstringOptional
userIdstringOptional
createdAtstringOptional
updatedAtstringOptional
patch/v3/named-sources/{name}

Delete a named source

delete
/v3/named-sources/{name}
Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Path parameters
namestringRequired

The name of the named source.

Example: my_named_source_1
Responses
204

The named source was deleted.

No content

delete/v3/named-sources/{name}

No content

Last updated

Was this helpful?