> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.rasen.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.rasen.ai/_mcp/server.

# Create a webhook endpoint

POST https://api.rasen.ai/v1/webhook-endpoints
Content-Type: application/json

Registers an HTTPS endpoint and creates its signing secret. The secret appears only in this first successful response. A replay of the same Idempotency-Key and body returns the original status (201) and the same endpoint with secret null and the header Idempotent-Replayed true; the plaintext is not kept. The replayed url has any query masked as ?… (scheme, host and path kept), because the stored replay record keeps no credential; reads return the whole url. The destination guard runs before any write: a URL that is not https, or a host that does not resolve only to public addresses, is refused with 422 outbound_destination_refused and nothing is stored. A workspace has at most 10 endpoints that are not deleted. A new endpoint receives only events created after its own created_at. In a suspended workspace the answer is workspace_unavailable. Idempotency fingerprint: method, path and the canonical body.

Reference: https://docs.rasen.ai/enterprise/api-reference/webhooks/create-endpoint

## Authentication

- `Authorization` header (bearer token, required) — An organisation-owned key whose secret starts ra_org_. The Owner or an Admin of an organisation that Rasen has invited makes it in the app; no API operation makes, changes, rotates or revokes a key. On a workspace operation send the workspace ID in the Rasen-Workspace header; without it the answer is 400 invalid_request with details.field Rasen-Workspace. A workspace outside the organisation or outside the key's workspace list is 404 not_found. An organisation that is not invited gets 403 organisation_api_not_enabled.

## Request

### Headers

- `Idempotency-Key` (string, required) — Stable key per logical intent, 1–255 printable characters. Persist it before sending. Retry the same key/body after an uncertain result for 24 hours. A changed body conflicts. Beyond retention, reconcile the resource before retrying; this is not permanent deduplication. Current authorization is rechecked on replay. Evaluation order: authenticate and check current authorization; look up intent; replay its stored receipt before checking the current revision; only a new intent evaluates If-Match and executes. Fingerprint includes method, path, body and original If-Match. A changed request returns idempotency_key_reused. The server stores only a keyed (HMAC) fingerprint, and no error or response ever returns a fingerprint or hash of a request. In-flight intent returns 409 idempotency_in_progress with Retry-After; retry the same intent after reconciliation. Receipts describe that attempt, not current resource state. A replay returns the original status code and body, with the response header Idempotent-Replayed: true.
- `Rasen-Workspace` (string, required) — The ID of the workspace that this operation acts in. It must be a workspace of the key's organisation and in the key's workspace list. A missing, empty or malformed value is 400 invalid_request with details.field Rasen-Workspace; a workspace outside the organisation or the key's workspace list is the hidden 404 not_found.

### Body (application/json)

This endpoint expects a WebhookEndpointCreate.

- `url` (string, required) — An absolute https URL with a host, at most 2,048 characters. User information (user:password@) and a fragment are refused with 400 invalid_request, details.field url. A query string is allowed and sent exactly as written, so a receiver that signs its URL in the query (for example a Power Automate or Logic Apps HTTP trigger) works; every workspace member who can read the endpoint sees the whole URL. The answer of an idempotent replay is the exception: its url shows any query masked as ?… (scheme, host and path kept). A scheme other than https, or a host that does not resolve only to public addresses (private, loopback, link-local, reserved, multicast, unspecified and metadata addresses are refused, also in a mixed answer, and also a name that does not resolve), is refused with 422 outbound_destination_refused, which names no host. The same guard runs again before each attempt; redirects are never followed.
- `events` (list of enum, required) — At least one event type. A repeated value is refused (400 invalid_request, details.field events).
  - Allowed values: `call.completed`, `call.failed`, `call.analyzed`, `tool.failed`
- `description` (string, optional) — Optional label, trimmed. Blank becomes null. Control characters are refused with 400 invalid_request, details.field description.

## Response

### 201

The endpoint, with its signing secret once (null on a replay).

- `id` (string, required) — Opaque endpoint identifier (prefix wep_). Do not parse it.
- `url` (string, required)
- `description` (string, required, nullable)
- `events` (list of string, required) — Subscribed event types. Open response vocabulary.
- `state` (string, required) — enabled: receives deliveries. disabled: a person disabled it. disabled_failing: Rasen disabled it after at least 72 hours and at least 10 failed call-event attempts with no success. Both disabled states hold pending deliveries. Open response vocabulary; treat an unknown value as not enabled.
- `disabled_at` (datetime, required, nullable) — When the endpoint entered its current disabled state. Null while enabled.
- `secret_hint` (string, required) — The last 4 characters of the current signing secret. Never the secret.
- `previous_secret_expires_at` (datetime, required, nullable) — End of the rotation grace period while the previous secret is still valid; null otherwise.
- `last_success_at` (datetime, required, nullable) — Time of the last 2xx attempt.
- `last_failure_at` (datetime, required, nullable) — Time of the last failed attempt.
- `failing_since` (datetime, required, nullable) — First failed call-event attempt after the last success, creation or enable; null when the last attempt succeeded.
- `created_at` (datetime, required)
- `updated_at` (datetime, required)
- `deleted_at` (datetime, required, nullable) — Set only in the answer of deleteWebhookEndpoint and its replay. A deleted endpoint is otherwise not found.
- `revision` (string, required) — The same strong value as the ETag header. Lists carry it so a client can edit without a second read.
- `secret` (string, required, nullable) — The new signing secret, "whsec_" plus base64 of 32 random bytes. Present only in the first successful response; null on an idempotent replay. Rasen does not keep the plaintext in any receipt, log or event, so it cannot show it again.

## Errors

### 400 Bad Request Error

Invalid input or cursor. Correct the request.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 401 Unauthorized Error

Invalid, expired or revoked API key. Creator departure or membership changes do not invalidate a workspace key.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 403 Forbidden Error

Operation not allowed by current credential or workspace access.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 404 Not Found Error

Resource absent or not visible in this workspace.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 409 Conflict Error

Conflict. Not retryable: read the current state, fix the request and send a new request. The one exception is idempotency_in_progress, which carries Retry-After: wait, then resend the identical request with the same Idempotency-Key. The operation lists its codes in x-error-codes; branch on error.code and, for conflict, error.details.reason.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 413 Content Too Large Error

Body or upload exceeds its allowed limit.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 422 Unprocessable Entity Error

The request is well formed but refused, for example a destination that is not a permitted public address.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 429 Too Many Requests Error

Rate limited. Respect Retry-After and retry the same intent where permitted.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 500 Internal Server Error

Internal error. The effect may have happened. Retry the same request with the same Idempotency-Key; read the resource before creating a new intent. For an operation that takes an Idempotency-Key, a client retry with the same key is safe: the server replays the stored outcome if the first attempt took effect; if the first attempt had no effect, the retry performs the operation once. Never retry with a new key.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

### 503 Service Unavailable Error

Service unavailable. Respect Retry-After where present. For an operation that takes an Idempotency-Key, a client retry with the same key is safe: the server replays the stored outcome if the first attempt took effect; if the first attempt had no effect, the retry performs the operation once. Never retry with a new key.

- `error` (ErrorResponseError, required) — Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

## Types

### ErrorResponseError

Only code and message are required. Rasen sends details, request_id and retry on every error, but clients must parse an error that lacks them, so a typed error is never lost to a parsing failure.

- `code` (string, required) — Stable code. Branch on code (and details.reason for conflict), never on message. Each code has one HTTP status; see components.x-error-catalog.
- `message` (string, required) — Safe description; no provider payload or submitted secrets.
- `details` (map from string to any, optional) — Safe code-specific details. The public fields for each code are listed in components.x-error-catalog. Details never contain a request fingerprint, a hash of a request, secret material or another tenant's data. forbidden may include required_capabilities (a list).
- `request_id` (string, optional) — Same value as the X-Request-Id header. Quote it to support.
- `retry` (string, optional) — Retry class of this code: no (fix the request or state first), yes (retry the same request and the same Idempotency-Key), retry_after (wait for Retry-After, then retry the same request). Open response vocabulary. Preserve unknown values; never assume they mean success.

## Examples

**Request**

```json
{
  "url": "https://hooks.example.com/rasen",
  "events": [
    "call.completed"
  ]
}
```

**Response**

```json
{
  "id": "wep_01j00000000000000000000000",
  "url": "string",
  "description": "string",
  "events": [
    "string"
  ],
  "state": "string",
  "disabled_at": "2024-01-15T09:30:00Z",
  "secret_hint": "string",
  "previous_secret_expires_at": "2024-01-15T09:30:00Z",
  "last_success_at": "2024-01-15T09:30:00Z",
  "last_failure_at": "2024-01-15T09:30:00Z",
  "failing_since": "2024-01-15T09:30:00Z",
  "created_at": "2024-01-15T09:30:00Z",
  "updated_at": "2024-01-15T09:30:00Z",
  "deleted_at": "2024-01-15T09:30:00Z",
  "revision": "string",
  "secret": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.rasen.ai/v1/webhook-endpoints"

payload = {
    "url": "https://hooks.example.com/rasen",
    "events": ["call.completed"]
}
headers = {
    "Idempotency-Key": "intent-appointment-001",
    "Rasen-Workspace": "ws_01j00000000000000000000000",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.rasen.ai/v1/webhook-endpoints';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'intent-appointment-001',
    'Rasen-Workspace': 'ws_01j00000000000000000000000',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"url":"https://hooks.example.com/rasen","events":["call.completed"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.rasen.ai/v1/webhook-endpoints")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'intent-appointment-001'
request["Rasen-Workspace"] = 'ws_01j00000000000000000000000'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"url\": \"https://hooks.example.com/rasen\",\n  \"events\": [\n    \"call.completed\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.rasen.ai/v1/webhook-endpoints")
  .header("Idempotency-Key", "intent-appointment-001")
  .header("Rasen-Workspace", "ws_01j00000000000000000000000")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"url\": \"https://hooks.example.com/rasen\",\n  \"events\": [\n    \"call.completed\"\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.rasen.ai/v1/webhook-endpoints', [
  'body' => '{
  "url": "https://hooks.example.com/rasen",
  "events": [
    "call.completed"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'intent-appointment-001',
    'Rasen-Workspace' => 'ws_01j00000000000000000000000',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.rasen.ai/v1/webhook-endpoints");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "intent-appointment-001");
request.AddHeader("Rasen-Workspace", "ws_01j00000000000000000000000");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"url\": \"https://hooks.example.com/rasen\",\n  \"events\": [\n    \"call.completed\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Idempotency-Key": "intent-appointment-001",
  "Rasen-Workspace": "ws_01j00000000000000000000000",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "url": "https://hooks.example.com/rasen",
  "events": ["call.completed"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.rasen.ai/v1/webhook-endpoints")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```