# Rotate share

URL: https://docs.hanzo.ai/docs/openapi/share/post-share-rotate

> Replaces the credential of a tunnel account and ends every environment enabled with it, shares and all, so a credential handed out before — to a member who has left, or to anyone who read it — opens nothing from now on.

`POST /v1/share/rotate`

> [Share →](https://docs.hanzo.ai/docs/openapi/share) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/share/rotate` |
| **Method**    | `POST`                                 |
| **Operation** | `post_share_rotate`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Replaces the credential of a tunnel account and ends every
environment enabled with it, shares and all, so a credential handed out before
— to a member who has left, or to anyone who read it — opens nothing from now
on. The account is kept: enable hands its holder the new credential.

In a customer's org the account is the org's, which its members share, and an
admin of the org or a SuperAdmin rotates it. In a held org each person's
account is their own, and they rotate it — every account they hold, the one
an API key of theirs was handed before included, so none stays live. An admin
of the org or a SuperAdmin then rotates the org's own account, which no call
there hands out, whether or not they hold an account of their own; when that
one cannot be rotated, `pending` says so and their own are rotated still.

An account never provisioned has nothing to rotate and counts 0. 503 when the
deployment has no share controller configured; 502 when that controller is
unreachable, or holds the caller's account under a credential this deployment
does not derive — out of a rotation's reach, so it is refused rather than
reported done.

## Request

The document declares no body for `POST /v1/share/rotate`. The handler is typed in cloud but its shape is not yet emitted, so the fields are not listed here — ask MCP's `describe` for `post_share_rotate`, which answers from the running route.

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | share.rotated   | ok      |
| `default` | problem-details | refused |

`200` body — 2 fields.

| Field     | In   | Type            | Always | Description                                                                            |
| --------- | ---- | --------------- | ------ | -------------------------------------------------------------------------------------- |
| `ended`   | body | integer (int64) | —      | Ended is how many environments the rotated accounts had enabled.                       |
| `pending` | body | string          | —      | Pending says what this call could not rotate, and is empty when it rotated everything. |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo share rotate
```

**SDK**

**.ts**

```ts
import { Configuration, ShareApi } from 'hanzoai';

const api = new ShareApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postShareRotate();
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import ShareApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = ShareApi(client).post_share_rotate()
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.ShareAPI.PostShareRotate(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, share_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = share_api::post_share_rotate(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.ShareApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new ShareApi(client).postShareRotate();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/share/rotate \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **share** through the `share` tool, which names its 3 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_shares"
         }
       }
     }'
```

---

[Share API](https://docs.hanzo.ai/docs/openapi/share) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
