1. Home
  2. Docs
  3. Packages
  4. API Builder Package

API Builder Package

The Convoworks API Builder is a versatile tool for constructing robust APIs for your WordPress websites. With this package, you can create and manage API routes using the API Route Filter component, which activates specific workflows when a route match occurs. These workflows can integrate diverse Convoworks features, including conditional logic (if, then), loops, and database access, allowing you to implement intricate, custom logic.

The API Response component is another crucial element, enabling you to dictate the endpoint’s result output, such as the HTTP status, headers, and body content. This ensures your endpoints return accurate and properly formatted data.

Check out example in this blog post Introducing the API Builder Package or how to Create Your Dummy API with Convoworks to Streamline Development

In summary, the Convoworks API Builder equips you with the resources to build tailor-made and efficient APIs, providing the ability to define specific API routes and responses with ease and precision. For a deeper dive into how to leverage these key components, continue reading the following sections.

Here you can see how to start your new API Builder project

API Route Filter

The API Route Filter in Convoworks API Builder allows you to define filters for your API routes. This is useful when you want to match specific API routes during the request.


  • Method: This is the HTTP method for the API route, such as GET, POST, PUT, DELETE, etc.
  • Path: This field is used to specify the URI path for the route. You can use path variables within the URI path to capture specific portions of the URI.
    When a route is matched, you can use expressions like ${result.userId} to get the value of the path variable. This field supports several special values:

    • If left empty, it will match the default route.
    • If set to “*”, it will match all routes.
    • If you define the route as “/my/{userId}”, and the route is matched, ${result.userId} can be used to get the path variable value.

API Response Element

The API Response Element in Convoworks API Builder allows you to define the HTTP response returned by your server. This includes the HTTP status, headers, and body.


  • Status: An integer value that defines the HTTP status code for the response. A successful HTTP request is indicated by 200. Other status codes can be used to represent different responses, such as 404 for Not Found or 500 for Server Error.
  • Headers: Key-value pairs defining the headers of the HTTP response. The default header is ‘Content-Type: application/json’, but you can add more as per your application’s requirements.
  • Body: This field represents the raw response body. You can define the data you want to send in response to the API call here. It can contain a plain string (like JSON), but it can also be evaluated.

Body Field Examples

You can use expressions to dynamically generate the response body:

  • Example 1: If you have a numeric variable, you can include it in a JSON object like so:
    {"field": ${intval( myNumericValue)} }
  • Example 2: If you have an array, you can convert it to a JSON string like so:
    ${json_encode( myArrayValue)}