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

# Delete Data App

> Permanently delete a Data App and all its associated resources.

Permanently delete a Data App from your organization. This action removes the Data App along with all associated embed configurations and API tokens.

<Danger>
  **Destructive Operation:** This action is irreversible. Deleting a Data App will:

  * Remove all embed configurations associated with this Data App
  * Invalidate all API tokens for this Data App
  * Break any embedded dashboards using this Data App's tokens

  Make sure you have updated your applications before deletion.
</Danger>

<Warning>
  **Authentication Requirement:** This endpoint requires a **service token** (not a data app API key). Service tokens have elevated permissions to manage Data Apps across your organization.
</Warning>

## Endpoint Formats

<Tabs>
  <Tab title="New Endpoint (Recommended)">
    ```
    DELETE https://api.usedatabrain.com/api/v2/data-app?name={name}
    ```

    **Use this endpoint** for all new integrations. This is the recommended endpoint format.
  </Tab>

  <Tab title="Legacy Endpoint (Deprecated Soon)">
    ```
    DELETE https://api.usedatabrain.com/api/v2/dataApp?name={name}
    ```

    This endpoint still works but will be deprecated. Please migrate to the new endpoint format.
  </Tab>
</Tabs>

## Authentication

This endpoint requires a service token in the Authorization header. Service tokens differ from data app API keys and provide organization-level permissions.

To access your service token:

1. In **Settings** page, navigate to the **Service Tokens** section.
2. Click the **"Generate Token"** button to create a new service token if you don't have one already.

Use this token as the Bearer value in your Authorization header.

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Use your service token (not data app API key).

  ```
  Authorization: Bearer service_token_xyz...
  ```
</ParamField>

## Query Parameters

<ParamField query="name" type="string" required>
  The name of the Data App to delete. This must exactly match the Data App name.

  <Expandable title="Finding Data App names">
    * Use the [List Data Apps](/developer-docs/helpers/api-reference/list-data-apps) API to get all Data App names
    * Check your Databrain dashboard for Data App configurations
    * The name is case-sensitive
  </Expandable>
</ParamField>

## Response

<ResponseField name="name" type="string">
  The name of the deleted Data App for confirmation.
</ResponseField>

<ResponseField name="error" type="object">
  Error object returned only when the request fails. Not included in successful responses.

  <Expandable title="error properties">
    <ResponseField name="code" type="string">
      Error code identifying the type of error.
    </ResponseField>

    <ResponseField name="message" type="string">
      Human-readable error message describing what went wrong.
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

<Panel>
  <RequestExample>
    ```bash cURL theme={"dark"}
    curl --request DELETE \
      --url 'https://api.usedatabrain.com/api/v2/data-app?name=Customer%20Portal%20Analytics' \
      --header 'Authorization: Bearer service_token_xyz...'
    ```

    ```javascript Node.js icon="fa-brands fa-node-js" theme={"dark"}
    const dataAppName = 'Customer Portal Analytics';
    const response = await fetch(`https://api.usedatabrain.com/api/v2/data-app?name=${encodeURIComponent(dataAppName)}`, {
      method: 'DELETE',
      headers: {
        'Authorization': 'Bearer service_token_xyz...'
      }
    });

    const data = await response.json();
    console.log('Deleted Data App:', data.name);
    ```

    ```python Python icon="fa-brands fa-python" theme={"dark"}
    import requests
    from urllib.parse import quote

    url = "https://api.usedatabrain.com/api/v2/data-app"
    headers = {
        "Authorization": "Bearer service_token_xyz..."
    }
    params = {
        "name": "Customer Portal Analytics"
    }

    response = requests.delete(url, headers=headers, params=params)
    data = response.json()
    print(f"Deleted Data App: {data['name']}")
    ```

    ```java Java icon="fa-brands fa-java" theme={"dark"}
    import java.net.http.HttpClient;
    import java.net.http.HttpRequest;
    import java.net.http.HttpResponse;
    import java.net.URI;
    import java.net.URLEncoder;
    import java.nio.charset.StandardCharsets;

    public class DeleteDataApp {
        public static void main(String[] args) throws Exception {
            HttpClient client = HttpClient.newHttpClient();
            
            String name = URLEncoder.encode("Customer Portal Analytics", StandardCharsets.UTF_8);
            String url = String.format(
                "https://api.usedatabrain.com/api/v2/data-app?name=%s",
                name
            );
            
            HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer service_token_xyz...")
                .DELETE()
                .build();
                
            HttpResponse<String> response = client.send(request, 
                HttpResponse.BodyHandlers.ofString());
                
            System.out.println("Response: " + response.body());
        }
    }
    ```

    ```go Go icon="fa-brands fa-golang" theme={"dark"}
    package main

    import (
        "encoding/json"
        "fmt"
        "net/http"
        "net/url"
    )

    type DeleteDataAppResponse struct {
        Name  string      `json:"name"`
        Error interface{} `json:"error"`
    }

    func main() {
        baseURL := "https://api.usedatabrain.com/api/v2/data-app"
        params := url.Values{}
        params.Add("name", "Customer Portal Analytics")
        
        fullURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())
        
        req, _ := http.NewRequest("DELETE", fullURL, nil)
        req.Header.Set("Authorization", "Bearer service_token_xyz...")
        
        client := &http.Client{}
        resp, err := client.Do(req)
        if err != nil {
            panic(err)
        }
        defer resp.Body.Close()
        
        var result DeleteDataAppResponse
        json.NewDecoder(resp.Body).Decode(&result)
        
        fmt.Printf("Deleted Data App: %s\n", result.Name)
    }
    ```

    ```php PHP icon="fa-brands fa-php" theme={"dark"}
    <?php
    $params = http_build_query([
        'name' => 'Customer Portal Analytics'
    ]);

    $url = 'https://api.usedatabrain.com/api/v2/data-app?' . $params;

    $options = [
        'http' => [
            'header' => 'Authorization: Bearer service_token_xyz...',
            'method' => 'DELETE'
        ]
    ];

    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    $response = json_decode($result, true);

    echo "Deleted Data App: " . $response['name'];
    ?>
    ```

    ```ruby Ruby icon="fa-solid fa-gem" theme={"dark"}
    require 'net/http'
    require 'json'

    uri = URI('https://api.usedatabrain.com/api/v2/data-app')
    params = { name: 'Customer Portal Analytics' }
    uri.query = URI.encode_www_form(params)

    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true

    request = Net::HTTP::Delete.new(uri)
    request['Authorization'] = 'Bearer service_token_xyz...'

    response = http.request(request)
    result = JSON.parse(response.body)

    puts "Deleted Data App: #{result['name']}"
    ```
  </RequestExample>

  <ResponseExample>
    ```json 200 - Success theme={"dark"}
    {
      "name": "Customer Portal Analytics"
    }
    ```

    ```json 400 - Invalid Request Body theme={"dark"}
    {
      "error": {
        "code": "INVALID_REQUEST_BODY",
        "message": "\"name\" is required"
      }
    }
    ```

    ```json 400 - Data App Not Found theme={"dark"}
    {
      "error": {
        "code": "DATA_APP_NOT_FOUND",
        "message": "Data app not found"
      }
    }
    ```

    ```json 400 - Invalid Service Token theme={"dark"}
    {
      "error": {
        "code": "AUTHENTICATION_ERROR",
        "message": "Invalid Service Token"
      }
    }
    ```

    ```json 500 - Internal Server Error theme={"dark"}
    {
      "error": {
        "code": "INTERNAL_SERVER_ERROR",
        "message": "Data app not found"
      }
    }
    ```
  </ResponseExample>
</Panel>

## HTTP Status Code Summary

| Status Code | Description                                       |
| ----------- | ------------------------------------------------- |
| `200`       | **OK** - Data App deleted successfully            |
| `400`       | **Bad Request** - Invalid request parameters      |
| `500`       | **Internal Server Error** - Server error occurred |

## Possible Errors

| Error Code              | HTTP Status | Description                        |
| ----------------------- | ----------- | ---------------------------------- |
| `INVALID_REQUEST_BODY`  | 400         | Missing or invalid name parameter  |
| `DATA_APP_NOT_FOUND`    | 400         | Data App with given name not found |
| `AUTHENTICATION_ERROR`  | 400         | Invalid or missing service token   |
| `INTERNAL_SERVER_ERROR` | 500         | Server error                       |

## Quick Start Guide

<Steps>
  <Step title="Verify the Data App exists">
    Before deleting, confirm the Data App exists using the [List Data Apps](/developer-docs/helpers/api-reference/list-data-apps) API:

    ```bash theme={"dark"}
    curl --request GET \
      --url 'https://api.usedatabrain.com/api/v2/data-app' \
      --header 'Authorization: Bearer service_token_xyz...'
    ```
  </Step>

  <Step title="Update your applications">
    Before deletion, update your applications to remove any references to this Data App's API tokens and embed configurations.
  </Step>

  <Step title="Delete the Data App">
    Make a DELETE request with the Data App name:

    ```bash theme={"dark"}
    curl --request DELETE \
      --url 'https://api.usedatabrain.com/api/v2/data-app?name=My%20Data%20App' \
      --header 'Authorization: Bearer service_token_xyz...'
    ```
  </Step>

  <Step title="Verify deletion">
    Confirm the Data App was deleted by listing Data Apps again:

    ```bash theme={"dark"}
    curl --request GET \
      --url 'https://api.usedatabrain.com/api/v2/data-app' \
      --header 'Authorization: Bearer service_token_xyz...'
    ```
  </Step>
</Steps>

## Best Practices

<CardGroup cols={2}>
  <Card title="Verify Before Delete" icon="shield-check">
    Always verify the Data App exists and check its embeds before deletion
  </Card>

  <Card title="Update Applications First" icon="code">
    Update your applications to remove Data App references before deletion
  </Card>

  <Card title="Handle Errors" icon="exclamation-triangle">
    Implement proper error handling for failed deletions
  </Card>

  <Card title="Monitor Impact" icon="chart-line">
    Monitor for any broken embedded dashboards after deletion
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Create Data App" icon="plus" href="/developer-docs/helpers/api-reference/create-data-app">
    Create new Data Apps to replace deleted ones
  </Card>

  <Card title="List Data Apps" icon="list" href="/developer-docs/helpers/api-reference/list-data-apps">
    View all remaining Data Apps
  </Card>

  <Card title="Create API Token" icon="key" href="/developer-docs/helpers/api-reference/create-api-token">
    Generate API tokens for your Data Apps
  </Card>

  <Card title="List Embeds" icon="code" href="/developer-docs/helpers/api-reference/list-embed">
    View embed configurations for your Data Apps
  </Card>
</CardGroup>
