> For the complete documentation index, see [llms.txt](https://docs.carto.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.carto.com/carto-for-developers/reference/carto-api/named-sources-api.md).

# 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](https://docs.carto.com/carto-user-manual/developers/named-sources.md) 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 |

{% hint style="info" %}
These endpoints need an **OAuth Access Token**. See [Authorization](https://docs.carto.com/carto-for-developers/reference/carto-api.md#authorization).
{% endhint %}

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

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/named-sources" method="post" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/named-sources" method="get" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/named-sources/{name}" method="get" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/named-sources/{name}" method="patch" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/named-sources/{name}" method="delete" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.carto.com/carto-for-developers/reference/carto-api/named-sources-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
