Search Results for

    Show / Hide Table of Contents

    Web trigger rule

    Introduction

    A web trigger rule determines whether a new workflow should be triggered when Casewhere receives an HTTP request. Learn more about web triggers here.

    Rule syntax

    Keywords

    The following keywords are available in web trigger rules:

    Name Type Description
    @parameters IDictionary<string, string> The query string parameters from the request URL.
    @headers IDictionary<string, IEnumerable> The HTTP request header key-value pairs.
    @body DynamicDataObject The request payload as a data object. Access attributes using the dot operator (e.g., @body.phoneNumber).
    @apiFactory IManagedApiFactory To construct Casewhere API objects. Read here for the full list of available APIs.

    Examples

    Example 1: Filter by query string

    For the request api/product?category_id=1, access the query string parameter:

    @parameters["category_id"] == "1"
    

    Example 2: Validate API key

    Verify the API key in the request headers and return a structured error response if validation fails.

    #predicate
     
    // Parse the request header
    var dataApi = @apiFactory.Get<IDataApi>();
    
    if (!@headers.ContainsKey("Authorization"))
    {
        return new 
        {
            StatusCode = 400,
            Message = "Authorization header is missing"
        };
    }
     
    // Query Api Keys in DB
    var headerKey = @headers["Authorization"].First();
    var filter = FilterBuilder.Create().Eq("ApiKey", headerKey).Eq("Active", true).Build();
    var found = dataApi.Any("Applications", filter);
    
    if (!found)
    {
        return new 
        {
            StatusCode = 401,
            Message = "Invalid Api key"
        };
    }
    
    return true;
    
    In This Article
    Back to top Generated by DocFX