> ## Documentation Index
> Fetch the complete documentation index at: https://basedash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a chart

> Creates a new chart on a dashboard. The chart is placed on the specified tab (or the first tab by default) at the bottom of the tab unless a layout is provided. Requires admin access to the organization.



## OpenAPI

````yaml https://charts.basedash.com/api/public/openapi post /api/public/organizations/{orgId}/charts
openapi: 3.1.0
info:
  title: Basedash Public API
  version: 0.0.0
  description: >-
    API for programmatic access to Basedash features. Use API keys for
    authentication.
  contact:
    name: Basedash Support
    url: https://basedash.com
    email: support@basedash.com
servers:
  - url: https://charts.basedash.com
    description: Production
security: []
tags:
  - name: Organizations
    description: Manage organizations
  - name: Groups
    description: Manage organization groups and memberships
  - name: Data Sources
    description: Manage database connections and data sources
  - name: MCP servers
    description: Manage MCP server data sources
  - name: Insights
    description: Manage generated insights
  - name: Automations
    description: Manage automations and automation runs
  - name: Skills
    description: Manage organization skills
  - name: Definitions
    description: Manage reusable SQL definitions
  - name: Dashboards
    description: Manage dashboards and their tabs
  - name: Charts
    description: Manage charts and their SQL queries
  - name: Chats
    description: >-
      Chat with the Basedash AI agent about your data. Start a chat by sending a
      message, then continue the conversation with follow-up messages. The
      assistant responds asynchronously: pass the `wait` query parameter to
      receive the finished response in the same request, or poll the assistant
      message (or stream its events) after an HTTP 202. Chats created through
      the API are not shown in the Basedash app.
paths:
  /api/public/organizations/{orgId}/charts:
    post:
      tags:
        - Charts
      summary: Create a chart
      description: >-
        Creates a new chart on a dashboard. The chart is placed on the specified
        tab (or the first tab by default) at the bottom of the tab unless a
        layout is provided. Requires admin access to the organization.
      parameters:
        - schema:
            type: string
            description: Organization ID
          required: true
          description: Organization ID
          name: orgId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChartInput'
      responses:
        '201':
          description: Chart created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ChartResponse'
                required:
                  - data
        '400':
          description: Bad request - Invalid JSON body or validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - Organization trial has expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - Organization not found or no admin access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded - Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    CreateChartInput:
      type: object
      properties:
        dashboardId:
          type: string
          minLength: 1
          description: ID of the dashboard to place the chart on
        dashboardTabId:
          type: string
          description: >-
            ID of the dashboard tab to place the chart on. Defaults to the first
            tab.
        layout:
          $ref: '#/components/schemas/ChartLayoutInput'
        name:
          type: string
          minLength: 1
          description: Name of the chart
        description:
          type:
            - string
            - 'null'
          description: Description of the chart
        chartType:
          $ref: '#/components/schemas/SqlChartType'
        sqlQuery:
          type: string
          description: SQL query powering the chart
        drilldownSqlQuery:
          type:
            - string
            - 'null'
          description: SQL query used for chart drill-downs
        databaseConnectionId:
          type:
            - string
            - 'null'
          description: ID of the data source the SQL query runs against
        xAxisProperty:
          type:
            - string
            - 'null'
          description: Result column used for the x-axis
        xAxisSecondaryProperty:
          type:
            - string
            - 'null'
          description: Result column used to break down the x-axis into segments
        yAxisProperty:
          type:
            - string
            - 'null'
          description: Result column used for the y-axis
        staticContent:
          type:
            - string
            - 'null'
          description: Static content for DASHBOARD_HEADER and DASHBOARD_TEXT chart types
      required:
        - dashboardId
    ChartResponse:
      type: object
      properties:
        id:
          type: string
          description: Chart ID
        createdAt:
          type: string
          format: date-time
          description: Chart creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Timestamp of the last content or placement change
        dashboardId:
          type: string
          description: ID of the dashboard the chart is on
        dashboardTabId:
          type: string
          description: ID of the dashboard tab the chart is on
        organizationId:
          type: string
          description: Organization ID
        name:
          type: string
          description: Name of the chart
        description:
          type:
            - string
            - 'null'
          description: Description of the chart
        chartType:
          $ref: '#/components/schemas/SqlChartType'
        sqlQuery:
          type: string
          description: SQL query powering the chart
        drilldownSqlQuery:
          type:
            - string
            - 'null'
          description: SQL query used for chart drill-downs
        databaseConnectionId:
          type:
            - string
            - 'null'
          description: ID of the data source the SQL query runs against
        xAxisProperty:
          type:
            - string
            - 'null'
          description: Result column used for the x-axis
        xAxisSecondaryProperty:
          type:
            - string
            - 'null'
          description: Result column used to break down the x-axis into segments
        yAxisProperty:
          type:
            - string
            - 'null'
          description: Result column used for the y-axis
        staticContent:
          type:
            - string
            - 'null'
          description: Static content for DASHBOARD_HEADER and DASHBOARD_TEXT chart types
        layout:
          $ref: '#/components/schemas/ChartLayout'
        imageUrl:
          type: string
          format: uri
          description: >-
            URL that renders this chart as a PNG image (the "Get a chart image"
            endpoint). Request it with the same API key authentication.
      required:
        - id
        - createdAt
        - updatedAt
        - dashboardId
        - dashboardTabId
        - organizationId
        - name
        - description
        - chartType
        - sqlQuery
        - drilldownSqlQuery
        - databaseConnectionId
        - xAxisProperty
        - xAxisSecondaryProperty
        - yAxisProperty
        - staticContent
        - layout
        - imageUrl
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ApiError'
      required:
        - error
    RateLimitErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/RateLimitError'
      required:
        - error
    ChartLayoutInput:
      type: object
      properties:
        x:
          type: integer
          minimum: 0
          description: Column position on the dashboard grid
        'y':
          type: integer
          minimum: 0
          description: Row position on the dashboard grid
        width:
          type: integer
          minimum: 1
          description: Width of the chart in grid units
        height:
          type: integer
          minimum: 1
          description: Height of the chart in grid units
      description: >-
        Position and size of the chart on the dashboard grid. Defaults to the
        bottom of the tab.
    SqlChartType:
      anyOf:
        - type: string
          enum:
            - TABLE
        - type: string
          enum:
            - LINE
        - type: string
          enum:
            - VERTICAL_BAR
        - type: string
          enum:
            - HORIZONTAL_BAR
        - type: string
          enum:
            - SCATTER
        - type: string
          enum:
            - FUNNEL
        - type: string
          enum:
            - NUMBER
        - type: string
          enum:
            - PROGRESS
        - type: string
          enum:
            - IMAGE
        - type: string
          enum:
            - RECORD
        - type: string
          enum:
            - TEXT
        - type: string
          enum:
            - PIE
        - type: string
          enum:
            - ACTIVITY
        - type: string
          enum:
            - MAP
        - type: string
          enum:
            - SANKEY
        - type: string
          enum:
            - DASHBOARD_HEADER
        - type: string
          enum:
            - DASHBOARD_TEXT
        - type: 'null'
      description: Type of the chart
    ChartLayout:
      type: object
      properties:
        x:
          type: integer
          minimum: 0
          description: Column position on the dashboard grid
        'y':
          type: integer
          minimum: 0
          description: Row position on the dashboard grid
        width:
          type: integer
          minimum: 1
          description: Width of the chart in grid units
        height:
          type: integer
          minimum: 1
          description: Height of the chart in grid units
      required:
        - x
        - 'y'
        - width
        - height
    ApiError:
      type: object
      properties:
        title:
          type: string
          description: Error type identifier
        detail:
          type: string
          description: Human-readable error description
      required:
        - title
        - detail
    RateLimitError:
      allOf:
        - $ref: '#/components/schemas/ApiError'
        - type: object
          properties:
            title:
              type: string
              enum:
                - RateLimitExceeded
            retryAfterMs:
              type: number
              description: Milliseconds until the rate limit window resets
          required:
            - retryAfterMs
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication using Bearer token format: `Bearer
        <basedash_api_key>`

````