---
sidebar_position: 14
title: share_dive_data
description: Share the data for a Dive with your organization
feature_stage: preview
---

Share the data for a [Dive](/docs/key-tasks/ai-and-motherduck/dives) with your organization. Creates org-scoped shares for owned databases used in the Dive, so others in the organization can view it.

## Description

The `share_dive_data` tool makes a Dive's underlying data accessible to your organization. When a Dive queries databases that you own but haven't shared, other users in your organization won't be able to view the Dive. This tool creates shares for those databases and updates the Dive to reference the shared versions.

The tool:

1. Verifies you own the Dive
2. Analyzes the Dive's SQL queries to find referenced databases
3. Creates org-scoped shares for any databases that aren't already shared
4. Updates the Dive to use the shared database references

Use this after [`save_dive`](../save-dive) or [`update_dive`](../update-dive) when you want your team to be able to view a Dive that queries your private databases.

## Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `diveId` | string | Yes | The unique identifier (UUID) of the Dive to share data for |

## Output Schema

```json
{
  "success": boolean,
  "dive": {                      // Dive info (on success)
    "id": string,                // Dive identifier
    "title": string,             // Dive title
    "version": number            // New version number after update
  },
  "shares": [                    // Shares created (on success)
    {
      "database": string,        // Database name
      "shareName": string,       // Share name
      "shareUrl": string,        // Share URL for the database
      "created": boolean         // Whether the share was newly created
    }
  ],
  "requiredDatabases": [         // All databases referenced by the Dive
    {
      "type": string,            // "share" or "database"
      "path": string,            // Share URL or database path
      "alias": string            // Database alias name
    }
  ],
  "url": string,                 // URL to view the Dive (on success)
  "message": string,             // Status message (on success)
  "warnings": string[],          // Warnings from analysis or sharing (if any)
  "error": string                // Error message (on failure)
}
```

## Example Usage

**Share a Dive's data after saving:**

```text
Share the data for my revenue Dive with the rest of my team
```

The AI assistant will call the tool with the Dive's ID:

```json
{
  "diveId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

**Respond to a sharing prompt after save:**

After calling [`save_dive`](../save-dive), the tool may suggest sharing unshared databases. The AI assistant will call `share_dive_data` to make the data accessible:

```json
{
  "diveId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

## Success Response Example

```json
{
  "success": true,
  "dive": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "title": "Monthly Revenue Trends",
    "version": 4
  },
  "shares": [
    {
      "database": "analytics",
      "shareName": "analytics",
      "shareUrl": "md:_share/analytics/a1b2c3d4-...",
      "created": true
    }
  ],
  "requiredDatabases": [
    {
      "type": "share",
      "path": "md:_share/analytics/a1b2c3d4-...",
      "alias": "analytics"
    }
  ],
  "url": "https://app.motherduck.com/dives/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "message": "Created 1 share(s). Dive updated with share URLs."
}
```

## Nothing to Share Response Example

When all referenced databases are already shared:

```json
{
  "success": true,
  "message": "All referenced databases are already shared. No action needed.",
  "shares": [],
  "requiredDatabases": [
    {
      "type": "share",
      "path": "md:_share/analytics/a1b2c3d4-...",
      "alias": "analytics"
    }
  ],
  "dive": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "version": 3
  }
}
```

## Error Response Example

```json
{
  "success": false,
  "error": "You don't own this dive or it doesn't exist"
}
```
