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

# Publishing API

## Overview

You can publish your charts to ChartSQL Cloud to share and create dashboards. ChartSQL Studio provides all of the capabilities for publishing, but you may also use the API if you are doing your own automations.

This document describes the API calls for publishing charts to ChartSQL.com

## Publisher Authentication

In order to publish charts, you need to be an approved `Publisher` for a `Package`. You will need a ChartSQL Cloud account.

If you are not the creator/owner of a Package on ChartSQL Cloud, the Package owner needs to give your user Publisher access.

### Publishing Key

From your ChartSQL Cloud account settings, go to Packages. From there you can create a new Publisher Key. A Publisher Key is a unique password that gives you API access to publish to the Package. Do not share your Publishing Key with anyone else, it is like a password, and it is tied to your ChartSQL Cloud account.

Publishing Keys are securely stored and cannot be recovered by ChartSQL support. If you forget or lose your key, you will need to create another.

#### Publishing Key Format

Typically you will not need to do this encoding yourself. The Publishing Key format is a base64 encoded string of your Publisher Key Id and its password. When you created your publishing key in the ChartSQL Cloud UI, you will have received your base64 encoded string.

toBase64("{{publisherKeyId}}:{{password}}")

The publishing key allows ChartSQL Cloud to identify the account by `publisherKeyId` and verify access by comparing the salted and hashed value of the `password`.

## Base URL

<http://api.chartsql.com/PublisherKey/\\{{publishingKey\\}}/>

## Endpoints

### Publish Chart

POST <http://api.chartsql.com/PublisherKey/\\{{publishingKey\\}}/publishDashChart.json>

#### Fields

| Name     | Required | Description                             |
| -------- | -------- | --------------------------------------- |
| sql      | yes      | The SQL content of the chart            |
| fileName | yes      | The local file system name of the chart |

### Update Chart

POST <http://api.chartsql.com/PublisherKey/\\{{publishingKey\\}}/updateDashChart.json>

#### Fields

| Name     | Required | Description                                                        |
| -------- | -------- | ------------------------------------------------------------------ |
| sql      | yes      | The SQL content of the chart                                       |
| fileName | yes      | The local file system name of the chart                            |
| dashId   | yes      | The @dash-id that uniquely identifies the already published chart. |

### Verify/Stats

POST <http://api.chartsql.com/PublisherKey/\\{{publishingKey\\}}/stats.json>

You use the /stats endpoint to verify access to the PublisherKey. If the publishing key fails, an error will be returned.
