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

# Upsert scheduled delivery as code

> Upsert a scheduled delivery from code representation



## OpenAPI

````yaml https://raw.githubusercontent.com/lightdash/lightdash/refs/heads/main/packages/backend/src/generated/swagger.json post /api/v1/projects/{projectUuid}/scheduledDeliveries/{slug}/code
openapi: 3.0.0
info:
  title: Lightdash API
  version: 0.3368.0
  description: >
    Open API documentation for all public Lightdash API endpoints. #
    Authentication Before you get started, you might need to create a Personal
    Access Token to authenticate via the API. You can create a token by
    following this guide: https://docs.lightdash.com/references/personal_tokens
  license:
    name: MIT
  contact:
    name: Lightdash Support
    email: support@lightdash.com
    url: https://docs.lightdash.com/help-and-contact/contact/contact_info/
servers:
  - url: /
security: []
tags:
  - name: My Account
    description: These routes allow users to manage their own user account.
  - name: Organizations
    description: >-
      Each user is a member of a single organization. These routes allow users
      to manage their organization. Most actions are only available to admin
      users.
  - name: Projects
    description: >-
      Projects belong to a single organization. These routes allow users to
      manage their projects, browse content, and execute queries. Users inside
      an organization might have access to a project from an organization-level
      role or they might be granted access to a project directly.
  - name: Spaces
    description: >-
      Spaces allow you to organize charts and dashboards within a project. They
      also allow granular access to content by allowing you to create private
      spaces, which are only accessible to the creator and admins.
  - name: Roles & Permissions
    description: >-
      These routes allow users to manage roles and permissions for their
      organization.
    externalDocs:
      url: https://docs.lightdash.com/references/roles
  - name: Query
    description: >-
      These routes allow users to execute and manage queries against their data
      warehouse. This includes metric queries, SQL queries, and retrieving query
      results.
paths:
  /api/v1/projects/{projectUuid}/scheduledDeliveries/{slug}/code:
    post:
      tags:
        - Projects
      summary: Upsert scheduled delivery as code
      description: Upsert a scheduled delivery from code representation
      operationId: upsertScheduledDeliveryAsCode
      parameters:
        - in: path
          name: projectUuid
          required: true
          schema:
            type: string
        - in: path
          name: slug
          required: true
          schema:
            type: string
        - in: query
          name: force
          required: false
          schema:
            default: false
            type: boolean
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScheduledDeliveryAsCode'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiScheduledDeliveryAsCodeUpsertResponse'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorPayload'
      security: []
components:
  schemas:
    ScheduledDeliveryAsCode:
      anyOf:
        - $ref: '#/components/schemas/ChartScheduledDeliveryAsCode'
        - $ref: '#/components/schemas/DashboardScheduledDeliveryAsCode'
    ApiScheduledDeliveryAsCodeUpsertResponse:
      properties:
        results:
          properties:
            action:
              anyOf:
                - $ref: '#/components/schemas/PromotionAction.CREATE'
                - $ref: '#/components/schemas/PromotionAction.UPDATE'
                - $ref: '#/components/schemas/PromotionAction.NO_CHANGES'
          required:
            - action
          type: object
        status:
          type: string
          enum:
            - ok
          nullable: false
      required:
        - results
        - status
      type: object
    ApiErrorPayload:
      properties:
        error:
          properties:
            data:
              $ref: '#/components/schemas/AnyType'
              description: Optional data containing details of the error
            message:
              type: string
              description: A friendly message summarising the error
            name:
              type: string
              description: Unique name for the type of error
            statusCode:
              type: number
              format: integer
              description: HTTP status code
          required:
            - name
            - statusCode
          type: object
        status:
          type: string
          enum:
            - error
          nullable: false
      required:
        - error
        - status
      type: object
      description: |-
        The Error object is returned from the api any time there is an error.
        The message contains
    ChartScheduledDeliveryAsCode:
      allOf:
        - $ref: '#/components/schemas/ScheduledDeliveryFormatAsCode'
        - $ref: '#/components/schemas/ScheduledDeliveryAsCodeBase'
        - properties:
            selectedTabs:
              type: number
              enum:
                - null
              nullable: true
            customViewportWidth:
              type: number
              enum:
                - null
              nullable: true
            parameters:
              allOf:
                - $ref: '#/components/schemas/ParametersValuesMap'
              nullable: true
            filters:
              allOf:
                - $ref: '#/components/schemas/FiltersInput'
              nullable: true
            resource:
              properties:
                slug:
                  type: string
                type:
                  type: string
                  enum:
                    - chart
                  nullable: false
              required:
                - slug
                - type
              type: object
          required:
            - selectedTabs
            - customViewportWidth
            - parameters
            - filters
            - resource
          type: object
    DashboardScheduledDeliveryAsCode:
      allOf:
        - $ref: '#/components/schemas/ScheduledDeliveryFormatAsCode'
        - $ref: '#/components/schemas/ScheduledDeliveryAsCodeBase'
        - properties:
            selectedTabs:
              items:
                type: string
              type: array
              nullable: true
              description: Portable dashboard-tab slugs, resolved to UUIDs on upload.
            customViewportWidth:
              type: number
              format: double
              nullable: true
            parameters:
              allOf:
                - $ref: '#/components/schemas/ParametersValuesMap'
              nullable: true
            filters:
              items:
                $ref: '#/components/schemas/Omit_DashboardFilterRule.id_'
              type: array
              nullable: true
            resource:
              properties:
                slug:
                  type: string
                type:
                  type: string
                  enum:
                    - dashboard
                  nullable: false
              required:
                - slug
                - type
              type: object
          required:
            - selectedTabs
            - customViewportWidth
            - parameters
            - filters
            - resource
          type: object
    PromotionAction.CREATE:
      enum:
        - create
      type: string
    PromotionAction.UPDATE:
      enum:
        - update
      type: string
    PromotionAction.NO_CHANGES:
      enum:
        - no changes
      type: string
    AnyType:
      description: |-
        This AnyType is an alias for any
        The goal is to make it easier to identify any type in the codebase
        without having to eslint-disable all the time
        These are only used on legacy `any` types, don't use it for new types.
        This is added on a separate file to avoid circular dependencies.
    ScheduledDeliveryFormatAsCode:
      anyOf:
        - properties:
            options:
              $ref: '#/components/schemas/SchedulerCsvOptions'
            format:
              anyOf:
                - $ref: '#/components/schemas/SchedulerFormat.CSV'
                - $ref: '#/components/schemas/SchedulerFormat.XLSX'
          required:
            - options
            - format
          type: object
        - properties:
            options:
              $ref: '#/components/schemas/SchedulerImageOptions'
            format:
              $ref: '#/components/schemas/SchedulerFormat.IMAGE'
          required:
            - options
            - format
          type: object
        - properties:
            options:
              $ref: '#/components/schemas/SchedulerPdfOptions'
            format:
              $ref: '#/components/schemas/SchedulerFormat.PDF'
          required:
            - options
            - format
          type: object
    ScheduledDeliveryAsCodeBase:
      properties:
        downloadedAt:
          type: string
          format: date-time
        targets:
          items:
            $ref: '#/components/schemas/ScheduledDeliveryTargetAsCode'
          type: array
        includeLinks:
          type: boolean
        enabled:
          type: boolean
        timezone:
          type: string
          nullable: true
        cron:
          type: string
        message:
          type: string
          nullable: true
        name:
          type: string
        slug:
          type: string
        version:
          type: number
          format: double
        contentType:
          $ref: '#/components/schemas/ContentAsCodeType.SCHEDULED_DELIVERY'
      required:
        - targets
        - includeLinks
        - enabled
        - timezone
        - cron
        - message
        - name
        - slug
        - version
        - contentType
      type: object
    ParametersValuesMap:
      $ref: '#/components/schemas/Record_string.ParameterValue_'
    FiltersInput:
      properties:
        tableCalculations:
          $ref: '#/components/schemas/FilterGroupInput'
        metrics:
          $ref: '#/components/schemas/FilterGroupInput'
        dimensions:
          $ref: '#/components/schemas/FilterGroupInput'
      type: object
    Omit_DashboardFilterRule.id_:
      $ref: >-
        #/components/schemas/Pick_DashboardFilterRule.Exclude_keyofDashboardFilterRule.id__
      description: Construct a type with the properties of T except for those in type K.
    SchedulerCsvOptions:
      properties:
        xlsxFileLayout:
          type: string
          enum:
            - zip
            - workbook
        exportPivotedData:
          type: boolean
        asAttachment:
          type: boolean
        limit:
          anyOf:
            - type: number
              format: double
            - type: string
              enum:
                - table
                - all
        formatted:
          type: boolean
      required:
        - limit
        - formatted
      type: object
    SchedulerFormat.CSV:
      enum:
        - csv
      type: string
    SchedulerFormat.XLSX:
      enum:
        - xlsx
      type: string
    SchedulerImageOptions:
      properties:
        withPdf:
          type: boolean
      type: object
    SchedulerFormat.IMAGE:
      enum:
        - image
      type: string
    SchedulerPdfOptions:
      $ref: '#/components/schemas/Record_string.never_'
    SchedulerFormat.PDF:
      enum:
        - pdf
      type: string
    ScheduledDeliveryTargetAsCode:
      anyOf:
        - properties:
            recipient:
              type: string
            type:
              type: string
              enum:
                - email
              nullable: false
          required:
            - recipient
            - type
          type: object
        - properties:
            channel:
              type: string
            type:
              type: string
              enum:
                - slack
              nullable: false
          required:
            - channel
            - type
          type: object
    ContentAsCodeType.SCHEDULED_DELIVERY:
      enum:
        - scheduled_delivery
      type: string
    Record_string.ParameterValue_:
      properties: {}
      additionalProperties:
        $ref: '#/components/schemas/ParameterValue'
      type: object
      description: Construct a type with a set of properties K of type T
    FilterGroupInput:
      anyOf:
        - $ref: '#/components/schemas/OrFilterGroupInput'
        - $ref: '#/components/schemas/AndFilterGroupInput'
    Pick_DashboardFilterRule.Exclude_keyofDashboardFilterRule.id__:
      properties:
        label:
          type: string
        target:
          $ref: '#/components/schemas/DashboardFieldTarget'
          description: Target field for the filter
        settings:
          description: Additional settings for date/time filters
        disabled:
          type: boolean
          description: Whether this filter is disabled
        required:
          type: boolean
          description: Whether this filter is required
        caseSensitive:
          type: boolean
          description: >-
            Overrides the field/explore case-sensitivity for this rule only.

            Used by internal features like autocomplete search that must always

            match case-insensitively regardless of the field's configured
            setting.
        operator:
          $ref: '#/components/schemas/FilterOperator'
          description: Filter operator
        values:
          items: {}
          type: array
          description: Values to filter by
        includeNull:
          type: boolean
          description: >-
            For the `equals` operator on string fields, also match rows where
            the

            field is null (compiles to `field IN (...) OR field IS NULL`). Lets
            users

            combine null with selected values in a single "is" rule.
        tileTargets:
          $ref: '#/components/schemas/Record_string.DashboardTileTarget_'
        singleValue:
          type: boolean
        requiredGroupId:
          type: string
          description: >-
            Dashboard filters sharing a requiredGroupId form an "any-one
            required"

            group: the dashboard is locked until at least one member has a
            value.
        lockedTabUuids:
          items:
            type: string
          type: array
          description: >-
            Tab UUIDs where this filter is locked. When the active tab is in
            this

            list, viewers see the filter but cannot change it, and URL / embed

            filter overrides targeting the same field are ignored on that tab.

            Empty or omitted means the filter is not locked anywhere.
      required:
        - target
        - operator
      type: object
      description: From T, pick a set of properties whose keys are in the union K
    Record_string.never_:
      properties: {}
      type: object
      description: Construct a type with a set of properties K of type T
    ParameterValue:
      anyOf:
        - type: string
        - type: number
          format: double
        - items:
            type: string
          type: array
        - items:
            type: number
            format: double
          type: array
    OrFilterGroupInput:
      properties:
        or:
          items:
            $ref: '#/components/schemas/FilterGroupItemInput'
          type: array
        id:
          type: string
      required:
        - or
      type: object
    AndFilterGroupInput:
      properties:
        and:
          items:
            $ref: '#/components/schemas/FilterGroupItemInput'
          type: array
        id:
          type: string
      required:
        - and
      type: object
    DashboardFieldTarget:
      properties:
        fallbackType:
          $ref: '#/components/schemas/DimensionType'
        isSqlColumn:
          type: boolean
        tableName:
          type: string
        fieldId:
          type: string
      required:
        - tableName
        - fieldId
      type: object
    FilterOperator:
      enum:
        - isNull
        - notNull
        - equals
        - notEquals
        - startsWith
        - endsWith
        - include
        - doesNotInclude
        - lessThan
        - lessThanOrEqual
        - greaterThan
        - greaterThanOrEqual
        - inThePast
        - notInThePast
        - inTheNext
        - inTheCurrent
        - notInTheCurrent
        - inBetween
        - notInBetween
        - inPeriodToDate
      type: string
    Record_string.DashboardTileTarget_:
      properties: {}
      additionalProperties:
        $ref: '#/components/schemas/DashboardTileTarget'
      type: object
      description: Construct a type with a set of properties K of type T
    FilterGroupItemInput:
      anyOf:
        - $ref: '#/components/schemas/FilterGroupInput'
        - $ref: '#/components/schemas/FilterRuleInput'
    DimensionType:
      enum:
        - string
        - number
        - timestamp
        - date
        - boolean
      type: string
    DashboardTileTarget:
      anyOf:
        - $ref: '#/components/schemas/DashboardFieldTarget'
        - type: boolean
          enum:
            - false
    FilterRuleInput:
      allOf:
        - $ref: '#/components/schemas/Omit_FilterRule.id_'
        - properties:
            id:
              type: string
          type: object
      description: >-
        Permissive filter types for chart-as-code uploads where `id` may be
        omitted.

        Filter IDs are auto-generated during upsert if absent.

        After normalization these become the strict runtime types (FilterGroup,
        Filters).
    Omit_FilterRule.id_:
      $ref: '#/components/schemas/Pick_FilterRule.Exclude_keyofFilterRule.id__'
      description: Construct a type with the properties of T except for those in type K.
    Pick_FilterRule.Exclude_keyofFilterRule.id__:
      properties:
        target:
          $ref: '#/components/schemas/FieldTarget'
          description: Target field for the filter
        settings:
          description: Additional settings for date/time filters
        disabled:
          type: boolean
          description: Whether this filter is disabled
        required:
          type: boolean
          description: Whether this filter is required
        caseSensitive:
          type: boolean
          description: >-
            Overrides the field/explore case-sensitivity for this rule only.

            Used by internal features like autocomplete search that must always

            match case-insensitively regardless of the field's configured
            setting.
        operator:
          $ref: '#/components/schemas/FilterOperator'
          description: Filter operator
        values:
          items: {}
          type: array
          description: Values to filter by
        includeNull:
          type: boolean
          description: >-
            For the `equals` operator on string fields, also match rows where
            the

            field is null (compiles to `field IN (...) OR field IS NULL`). Lets
            users

            combine null with selected values in a single "is" rule.
      required:
        - target
        - operator
      type: object
      description: From T, pick a set of properties whose keys are in the union K
    FieldTarget:
      properties:
        fieldId:
          type: string
          description: Field ID to filter on
      required:
        - fieldId
      type: object

````