---
title: "Rotate one webhook"
description: "Re-mints the webhook token. The one-time URL is returned here and nowhere else."
url: https://docs.spinrun.ai/api/agents/rotate-webhook
markdown_url: https://docs.spinrun.ai/api/agents/rotate-webhook.md
---

# Rotate one webhook

Re-mints the webhook token. The one-time URL is returned here and nowhere else.

## POST /api/build/agents/{ref}/rotate-webhook

Rotate one webhook

Re-mints the webhook token. The one-time URL is returned here and nowhere else.

Operation id: `rotateWebhook`

### Parameters

| Name | In | Required | Type | Description |
|---|---|---|---|---|
| ref | path | yes | string | Agent or workflow id or slug. |

### Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "trigger_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    }
  },
  "required": [
    "trigger_id"
  ],
  "description": "Rotate one webhook trigger."
}
```

### Responses

| Status | Description |
|---|---|
| 200 | The new secret's prefix and the one-time URL. |
| 400 | Malformed JSON, a document that fails validation, or a field that contradicts the URL. |
| 401 | No or invalid token. The `WWW-Authenticate` header names the authorization server. |
| 403 | The grant has no Build authorization. |
| 404 | No such agent, workflow or run visible to this token. |
| 409 | Refused by the document's state: an archived agent, a taken slug, or a workflow slug change. |

#### 200 · `application/json`

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "trigger_id": {
          "type": "string"
        },
        "secret_prefix": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "trigger_id",
        "secret_prefix",
        "url"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "data"
  ],
  "additionalProperties": false
}
```

#### 400 · `application/json`

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
```

#### 401 · `application/json`

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
```

#### 403 · `application/json`

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
```

#### 404 · `application/json`

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
```

#### 409 · `application/json`

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
```
