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

# Rotate webhook endpoint secret

> Gives the endpoint a new signing `secret` and returns it once.

POST`https://api.maple.inc/v1/webhook_endpoints/{endpointId}/rotate_secret`API key

The old secret keeps signing deliveries for `expires_in` seconds (default 24 hours, at most 7 days), so each delivery carries two `v1` signatures until `previous_secret_expires`; `expires_in: 0` stops the old secret at once. Rotating again during that time stops the oldest secret at once. Needs the read scope of every event type the endpoint holds, as an update does; if its `enabled_events` change while the rotation runs, it answers 409 `webhook_endpoint_changed` and rotates nothing.

Rotate webhook endpoint secret

```sh
curl "$MAPLE_BASE/webhook_endpoints/dws_123/rotate_secret" \
  -H "Authorization: Bearer $MAPLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expires_in":0}'
```

```python
import os
import requests


r = requests.post(
    f"{os.environ['MAPLE_BASE']}/webhook_endpoints/dws_123/rotate_secret",
    headers={"Authorization": f"Bearer {os.environ['MAPLE_KEY']}"},
    json={
        "expires_in": 0,
    },
    timeout=30,
)
r.raise_for_status()
print(r.json())
```

```js
const res = await fetch(`${process.env.MAPLE_BASE}/webhook_endpoints/dws_123/rotate_secret`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MAPLE_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "expires_in": 0
  }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(await res.json());
```

```json
{
  "object": "webhook_endpoint",
  "id": "string",
  "livemode": true,
  "url": "https://example.com/webhooks/maple",
  "api_version": "string",
  "enabled_events": [
    "order.submitted"
  ],
  "status": "enabled",
  "created": 1,
  "updated": 1,
  "secret": "string",
  "previous_secret_expires": 1
}
```

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_request",
    "message": "string",
    "doc_url": "string",
    "feedback": "string"
  }
}
```

## Authorization

Send your API key as `Authorization: Bearer <key>`: `mpk_test_…` for test mode, `mpk_live_…` for live mode. Both use `https://api.maple.inc/v1`. See [Authentication](https://docs.maple.inc/developer-api/concepts/authentication.md). The samples read the key from `MAPLE_KEY` and the base URL from `MAPLE_BASE`, as set up in the [Quickstart](https://docs.maple.inc/developer-api/quickstart.md).

## Parameters

- `endpointId` string path required

- `Idempotency-Key` string header

  Your unique key for this request, such as a UUID. A retry with the same key and the same body within 24 hours returns the first response, with `Idempotent-Replayed: true`, and does not run again. See <https://docs.maple.inc/developer-api/concepts/idempotency> Up to 255 characters.

- `Maple-Version` string header

  The API version your code expects. A version Maple does not serve answers 400 `invalid_request` with `param` `Maple-Version`. See <https://docs.maple.inc/developer-api/concepts/versioning> Always `2026-11-27`.

## Request body

`application/json`.

**Option 1**

- `expires_in` integer or null

## Responses

### 200 OK

A webhook endpoint as its rotate call returns it, with its new signing `secret` and `previous_secret_expires`.

- `object` string required

  Always `webhook_endpoint`.

- `id` string required

- `livemode` boolean required

  True for an endpoint in the live environment; false for test mode.

- `url` string required

  The HTTPS URL Maple sends events to.

- `api_version` string required

  The API version this endpoint’s events are rendered in, a date (`YYYY-MM-DD`). Fixed when the endpoint is created.

- `enabled_events` string\[] required

  The event types Maple sends to `url`.

- `status` string required

  One of `enabled`, `disabled`.

- `created` integer required

- `updated` integer required

- `secret` string required

  The new HMAC-SHA256 signing secret (`mwhsec_…`). Only this response carries it: store it now.

- `previous_secret_expires` integer or null required

  Unix timestamp in seconds when the old secret stops signing deliveries. Until then, each delivery carries a `v1` signature for each secret. Null when the old secret stopped at once.

### Errors

- `400` Bad request Invalid request (`invalid_request_error`), or `idempotency_error` for `idempotency_key_mismatch`

- `401` Unauthorized Missing or invalid credential (`authentication_error`)

- `403` Forbidden Not allowed (`permission_error`)

- `404` Not found Not found (`invalid_request_error`)

- `409` Conflict Conflicts with current state (`invalid_request_error`), or `idempotency_error` for `idempotency_key_in_use`

- `415` Unsupported Content-Type (`invalid_request_error`)

- `429` Too many requests Rate limit reached (`rate_limit_error`)

- `500` Server error Maple could not complete the request (`api_error`)

Every error body is one `error` object: branch on its `type` and `code`; `message` is for people, `param` names the field at fault, and `doc_url` links the code on [Errors](https://docs.maple.inc/developer-api/concepts/errors.md).

A `429` also sends `Retry-After`: Seconds to wait before retrying; also returned as error.retry\_after in the body.
