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

# Testa un flusso webhook

POST https://api.userbot.ai/webhook/test/{userId}
Content-Type: application/json

Invia un payload di esempio per verificare la configurazione di un flusso. Il payload viene recapitato all'utente dashboard specificato tramite notifica WebSocket.

Reference: https://developers.userbot.ai/api-reference/api-reference/flussi/test-webhook

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: swagger
  version: 1.0.0
paths:
  /webhook/test/{userId}:
    post:
      operationId: test-webhook
      summary: Testa un flusso webhook
      description: >-
        Invia un payload di esempio per verificare la configurazione di un
        flusso. Il payload viene recapitato all'utente dashboard specificato
        tramite notifica WebSocket.
      tags:
        - Flussi
      parameters:
        - name: userId
          in: path
          description: >-
            ID utente dashboard che riceve il payload di test in tempo reale via
            WebSocket.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Payload di test accettato e inoltrato al listener della dashboard.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IncomingWebhookResponseDto'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IncomingWebhookDto'
servers:
  - url: https://api.userbot.ai
    description: server di produzione
  - url: https://demo-api.userbot.ai
    description: server demo
  - url: https://userbot.lcl/apiclient
    description: server di sviluppo
components:
  schemas:
    IncomingWebhookDtoData:
      oneOf:
        - type: string
        - type: number
          format: double
        - type: boolean
      description: Valore variabile del flusso
      title: IncomingWebhookDtoData
    IncomingWebhookDtoFilesItems:
      type: object
      properties:
        name:
          type: string
          description: Nome file originale caricato
        mimeType:
          type: string
          description: Tipo MIME rilevato dall'upload
        size:
          type: number
          format: double
          description: Dimensione file in byte
        fileUri:
          type: string
          description: URI storage interno del file caricato
        md5:
          type: string
          description: Checksum MD5 del contenuto file
      required:
        - name
        - mimeType
        - size
        - fileUri
        - md5
      title: IncomingWebhookDtoFilesItems
    IncomingWebhookDto:
      type: object
      properties:
        sessionId:
          type: integer
          description: >-
            ID sessione di una conversazione esistente in cui eseguire il
            flusso. Se fornito, deve essere un intero positivo.
        data:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/IncomingWebhookDtoData'
          description: >-
            Variabili di input passate al flusso. Le chiavi devono corrispondere
            alle variabili definite nella configurazione del flusso.
        files:
          type: array
          items:
            $ref: '#/components/schemas/IncomingWebhookDtoFilesItems'
          description: >-
            File allegati al trigger. Popolati automaticamente con upload
            multipart/form-data.
      title: IncomingWebhookDto
    IncomingWebhookResponseDto:
      type: object
      properties:
        jobId:
          type: string
          description: >-
            Identificatore univoco dell'esecuzione del flusso attivata. Usalo
            per correlare log ed eventi asincroni.
      required:
        - jobId
      title: IncomingWebhookResponseDto

```

## Examples



**Request**

```json
{
  "data": {
    "customerId": "C-001",
    "note": "Test trigger from API"
  }
}
```

**Response**

```json
{
  "jobId": "550e8400-e29b-41d4-a716-446655440000"
}
```

**SDK Code**

```python Payload JSON di esempio
import requests

url = "https://api.userbot.ai/webhook/test/42"

payload = { "data": {
        "customerId": "C-001",
        "note": "Test trigger from API"
    } }
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Payload JSON di esempio
const url = 'https://api.userbot.ai/webhook/test/42';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"data":{"customerId":"C-001","note":"Test trigger from API"}}'
};

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

```go Payload JSON di esempio
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.userbot.ai/webhook/test/42"

	payload := strings.NewReader("{\n  \"data\": {\n    \"customerId\": \"C-001\",\n    \"note\": \"Test trigger from API\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Payload JSON di esempio
require 'uri'
require 'net/http'

url = URI("https://api.userbot.ai/webhook/test/42")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"data\": {\n    \"customerId\": \"C-001\",\n    \"note\": \"Test trigger from API\"\n  }\n}"

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

```java Payload JSON di esempio
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.userbot.ai/webhook/test/42")
  .header("Content-Type", "application/json")
  .body("{\n  \"data\": {\n    \"customerId\": \"C-001\",\n    \"note\": \"Test trigger from API\"\n  }\n}")
  .asString();
```

```php Payload JSON di esempio
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.userbot.ai/webhook/test/42', [
  'body' => '{
  "data": {
    "customerId": "C-001",
    "note": "Test trigger from API"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Payload JSON di esempio
using RestSharp;

var client = new RestClient("https://api.userbot.ai/webhook/test/42");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"data\": {\n    \"customerId\": \"C-001\",\n    \"note\": \"Test trigger from API\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Payload JSON di esempio
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["data": [
    "customerId": "C-001",
    "note": "Test trigger from API"
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.userbot.ai/webhook/test/42")! 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()
```