# share_dive_data
> Share the data for a Dive with the people who can open it
Share the data for a [Dive](/docs/key-tasks/dives) as widely as the Dive itself. Shares the databases you own that the Dive uses with the Dive's viewers, so they can see its data.

## Description

The `share_dive_data` tool makes a Dive's underlying data readable by the people who can open the Dive. When a Dive queries databases that you own but haven't shared, its viewers can't see its data. This tool shares those databases and updates the Dive to read the shares.

Sharing the data doesn't share the Dive itself. Viewers also need `read` access to the Dive, which you can give with [`grant_access`](/sql-reference/mcp/flights/grant-access) or in the [Share dialog](/key-tasks/dives/#choose-who-can-open-a-dive).

The tool:

1. Verifies you own the Dive.
2. Finds the databases the Dive queries.
3. Works out whom to share with: the `grantees` you pass, or otherwise whoever the Dive is shared with. If the Dive isn't shared with anyone and you pass no `grantees`, the tool fails without creating anything, and the assistant asks you whom to share the data with.
4. Shares each database:
   - **With users and roles:** a restricted share, granted to each of them. If you already own a restricted share of the database, the tool grants on it instead of creating another. It also grants them read access to restricted shares you own that the Dive already reads.
   - **With your organization:** an organization share. If the organization is one of the grantees, everyone already has access, so the share isn't restricted.
5. Updates the Dive to read the shares.

Granting only adds access. The tool never revokes a share's existing grants or changes its access. When it reuses a share that reaches more people than the Dive does, the response says so. It doesn't change a restricted share to an organization share, because changing a share's access deletes its grants.

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 |
| `grantees` | array | No | Whom to share the data with, as 1 to 100 objects with a `type` of `user`, `role`, or `organization` and, for a user or role, its `name`. Defaults to whoever the Dive is shared with |

## 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
      "access": string,          // The share's access: RESTRICTED, ORGANIZATION, or UNRESTRICTED
      "visibility": string,      // The share's visibility
      "update": string,          // Whether the share updates automatically or manually
      "previousGrantees": [],    // Users and roles only: who the share was granted to before this call
      "grantedThisCall": [],     // Users and roles only: users and roles this call granted read access
      "currentGrantees": []      // Users and roles only: who the share is granted to after this call
    }
  ],
  "audience": {                  // Whom the data was shared with; left out when there was nothing to share or grant
    "from": string,              // "grantees" (passed in) or "dive" (the Dive's viewers)
    "grantees": [{ "type": string, "name": string }]  // For the organization: [{ "type": "organization" }], with no name
  },
  "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 with the people who can open it:**

```text
Share the data for my revenue Dive with the people who can open it
```

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

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

**Share a Dive's data with a role:**

```text
Share the data for my revenue Dive with the finance role
```

```json
{
  "diveId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "grantees": [{ "type": "role", "name": "finance" }]
}
```

**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"
}
```


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fsql-reference%2Fmcp%2Fdives%2Fshare-dive-data%2F&page_title=share_dive_data&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
