Rybbit
Funnels

Create Funnel

Creates or updates a saved funnel. If `reportId` is provided, updates the existing funnel.

POST /api/sites/:site/funnels

Creates or updates a saved funnel. If reportId is provided, updates the existing funnel.

Path Parameters

Prop

Type

Request Body

Prop

Type

Response

Prop

Type

Create New Funnel
curl -X POST "https://app.rybbit.io/api/sites/1/funnels23" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Checkout Funnel",
    "steps": [
      { "type": "page", "value": "/products/*", "name": "Product Page" },
      { "type": "page", "value": "/cart", "name": "Cart" },
      { "type": "page", "value": "/checkout", "name": "Checkout" },
      { "type": "event", "value": "purchase", "name": "Purchase" }
    ]
  }'
Update Existing Funnel
const response = await fetch(
  'https://app.rybbit.io/api/sites/1/funnels23',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      reportId: 1,  // Update existing funnel
      name: 'Checkout Funnel (Updated)',
      steps: [
        { type: 'page', value: '/products/*', name: 'Product Page' },
        { type: 'page', value: '/cart', name: 'Cart' },
        { type: 'page', value: '/checkout', name: 'Checkout' },
        { type: 'page', value: '/checkout/success', name: 'Success' }
      ]
    })
  }
);

const data = await response.json();
Request
import requests

response = requests.post(
    'https://app.rybbit.io/api/sites/1/funnels23',
    json={
        'name': 'Onboarding Funnel',
        'steps': [
            { 'type': 'page', 'value': '/signup', 'name': 'Signup' },
            { 'type': 'event', 'value': 'account_created', 'name': 'Account Created' },
            { 'type': 'page', 'value': '/onboarding/*', 'name': 'Onboarding' },
            { 'type': 'event', 'value': 'onboarding_complete', 'name': 'Complete' }
        ]
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
$body = [
    'name' => 'Checkout Funnel',
    'steps' => [
        ['type' => 'page', 'value' => '/products/*', 'name' => 'Product Page'],
        ['type' => 'page', 'value' => '/cart', 'name' => 'Cart'],
        ['type' => 'page', 'value' => '/checkout', 'name' => 'Checkout'],
        ['type' => 'event', 'value' => 'purchase', 'name' => 'Purchase']
    ]
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.rybbit.io/api/sites/1/funnels23');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
Request
require 'net/http'
require 'json'

uri = URI('https://app.rybbit.io/api/sites/1/funnels23')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer your_api_key_here'
request['Content-Type'] = 'application/json'
request.body = {
  name: 'Checkout Funnel',
  steps: [
    { type: 'page', value: '/products/*', name: 'Product Page' },
    { type: 'page', value: '/cart', name: 'Cart' },
    { type: 'page', value: '/checkout', name: 'Checkout' },
    { type: 'event', value: 'purchase', name: 'Purchase' }
  ]
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
Request
body := map[string]interface{}{
    "name": "Checkout Funnel",
    "steps": []map[string]string{
        {"type": "page", "value": "/products/*", "name": "Product Page"},
        {"type": "page", "value": "/cart", "name": "Cart"},
        {"type": "page", "value": "/checkout", "name": "Checkout"},
        {"type": "event", "value": "purchase", "name": "Purchase"},
    },
}
jsonBody, _ := json.Marshal(body)

req, _ := http.NewRequest("POST", "https://app.rybbit.io/api/sites/1/funnels23", bytes.NewBuffer(jsonBody))
req.Header.Set("Authorization", "Bearer your_api_key_here")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
Request
let body = serde_json::json!({
    "name": "Checkout Funnel",
    "steps": [
        {"type": "page", "value": "/products/*", "name": "Product Page"},
        {"type": "page", "value": "/cart", "name": "Cart"},
        {"type": "page", "value": "/checkout", "name": "Checkout"},
        {"type": "event", "value": "purchase", "name": "Purchase"}
    ]
});

let client = reqwest::Client::new();
let res = client
    .post("https://app.rybbit.io/api/sites/1/funnels23")
    .header("Authorization", "Bearer your_api_key_here")
    .json(&body)
    .send()
    .await?;

let data: serde_json::Value = res.json().await?;
Request
String json = """
{
  "name": "Checkout Funnel",
  "steps": [
    {"type": "page", "value": "/products/*", "name": "Product Page"},
    {"type": "page", "value": "/cart", "name": "Cart"},
    {"type": "page", "value": "/checkout", "name": "Checkout"},
    {"type": "event", "value": "purchase", "name": "Purchase"}
  ]
}
""";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://app.rybbit.io/api/sites/1/funnels23"))
    .header("Authorization", "Bearer your_api_key_here")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request
var body = new
{
    name = "Checkout Funnel",
    steps = new[]
    {
        new { type = "page", value = "/products/*", name = "Product Page" },
        new { type = "page", value = "/cart", name = "Cart" },
        new { type = "page", value = "/checkout", name = "Checkout" },
        new { type = "event", value = "purchase", name = "Purchase" }
    }
};

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

var content = new StringContent(
    JsonSerializer.Serialize(body),
    Encoding.UTF8,
    "application/json");

var response = await client.PostAsync("https://app.rybbit.io/api/sites/1/funnels23", content);
var data = await response.Content.ReadAsStringAsync();
Response
{
  "success": true,
  "funnelId": 2
}