---
title: "Publish a custom model to the workspace"
method: POST
path: "/gdc/projects/{projectId}/nonProduction/model/publish"
tags: ["non-production-publish-model"]
---

# Publish a custom model to the workspace

`POST /gdc/projects/{projectId}/nonProduction/model/publish`

## Request

- Base URL: `https://secure.gooddata.com`
- URL: `https://secure.gooddata.com/gdc/projects/{projectId}/nonProduction/model/publish`
- Auth: none declared

This method publishes the provided custom model (target LDM) to the project and returns the link to a polling resource that returns the project LDM after publishing.</br>
You provide the target LDM as a JSON structure in the request body.</br>
</br>
While running, this method performs the following operations:</br>
   **1.** Obtains the current model of the project (if any) </br>
   **2.** Merges the current model with the target model </br>
   **3.** Generates and executes MAQL DDL scripts to update the current model to make it equal to the merged model</br>
</br>
By default, the target LDM is published **only** if the API will not delete any data or dependencies(metrics, reports, dashboards, etc.) from the project datasets. If the API detects that publishing will delete any data or dependencies, the publishing task will fail, and the existing LDM will not change.
In this case, you can have the following options:</br>
* Review and update the target LDM so that the API does not delete any data. Then execute the API again.
* Force-publish the LDM even if that deletes some data.</br>
To do so, add the `preserveData` parameter under `publishOptions` in the request body, set it to `false`, and execute the API again.</br>
 **NOTE:** If not explicitly set to `false`, this parameter defaults to `true`.</br>
This option is not available for some update combinations (for example, if `preserveData=false` exists in all possible MAQL DDL scripts).
In case the API detects any deleted data sets or date dimensions using the dependencies(metrics, reports, dashboards, etc.), you can use `cascadeDrops` parameter under `publishOptions` in the request body and set it to `true` to delete the data sets or date dimensions and the dependencies.

## Path parameters

- `projectId` string, required

## Request body

- NonProdPublishModel
  - `publishModel` object, required
    - `publishOptions` object: Set true or false for preserveData publish option( set false if you publish with overwrite mode ). Also set true or false for cascadeDrops publish option( set true if you want to drop non-production datasets and the reports using them )
      - `preserveData` boolean, required
      - `cascadeDrops` boolean, required
    - `targetModel` ProjectModel1, required
      - `projectModel` object, required
        - `modelMetadata` ModelMetadata
          - `containCA` boolean: true if the model is generated including computed attributes
        - `datasets` PmDataset1[], nullable
          - `dataset` PmDatasetRequest, required
            - `identifier` string, required
            - `title` string, required
            - `description` string
            - `anchor` PmAttribute1
              - …
            - `attributes` PmAttribute1[]
              - …
            - `bridges` string[]
            - `facts` PmFact1[]
              - …
            - `references` string[]: IDs of referenced dataset / date dimensions
            - `summary` string, nullable
            - `production` boolean
        - `dateDimensions` PmDateDimension1[], nullable
          - `dateDimension` PmDateDimensionRequest, required
            - `name` string, required
            - `title` string, required
            - `urn` string
            - `identifier` string
            - `identifierPrefix` string
            - `bridges` string[]
            - `production` boolean

## Response `202`

Accepted - created non-production publish project model async task

- NewAsyncTask: New taskman async task used in all new API resources. It contains `links` element in plural which complies with our API rules.
  - `asyncTask` object, required
    - `links` AsyncTaskPollLink, required
      - `poll` string, uri, required: URI of the polling resource

## Other responses

- `400`: Bad Request
- `403`: Forbidden - current user does not have canManageCustomDataset permission.
- `500`: Internal Server Error

---

[API](https://skmtc.dev/gooddata/apis/gooddata-api-documentation.md) - [All operations](https://skmtc.dev/gooddata/apis/gooddata-api-documentation/llms.txt) - [OpenAPI document](https://skmtc.dev/gooddata/apis/gooddata-api-documentation/revisions/e5dc0ee6ab00?raw)
