> 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

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](/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](/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
