BrainGrid Controller
Workflow Builder
Triggers
API Trigger

API Trigger Setup

API Triggers in the Workflow Management module allow users to automate actions based on specific API responses. This functionality enables integration with external services and systems by reacting to different HTTP methods and status codes.

Overview

API Triggers are configured to monitor and respond to specific API requests and their corresponding status codes. You can set up triggers for various HTTP methods, including GET, POST, PUT, and DELETE, each with their own status codes to indicate different outcomes.

Configuring API Triggers

Configure API Trigger for GET Method with 401 Status

To configure an API Trigger for unauthorized access:

  1. Title: Provide a descriptive title for the trigger.
  2. Description: Explain the purpose of the trigger.
  3. API Method: Select GET.
  4. Status: Set the status code to 401.
  5. API URL: Enter the API endpoint (e.g., api/v1/students).

Example:

  • Title: Unauthorized Student List Access
  • Description: Trigger on unauthorized access to student list API
  • API Method: GET
  • Status: 401
  • API URL: api/v1/students

Configure API Trigger for POST Method with 201 Status

To configure an API Trigger for successful creation:

  1. Title: Provide a descriptive title for the trigger.
  2. Description: Explain the purpose of the trigger.
  3. API Method: Select POST.
  4. Status: Set the status code to 201.
  5. API URL: Enter the API endpoint (e.g., api/v1/students).

Example:

  • Title: Successful Student Creation
  • Description: Trigger on successful student creation via API
  • API Method: POST
  • Status: 201
  • API URL: api/v1/students

Configure API Trigger for PUT Method with Custom Status

To configure an API Trigger for custom status updates:

  1. Title: Provide a descriptive title for the trigger.
  2. Description: Explain the purpose of the trigger.
  3. API Method: Select PUT.
  4. Status: Set the status code to a custom value (e.g., 409).
  5. API URL: Enter the API endpoint with path variables (e.g., api/v1/students/id).

Example:

  • Title: Custom Status Update
  • Description: Trigger on custom status response for updating student information
  • API Method: PUT
  • Status: 409
  • API URL: api/v1/students/id

Configure API Trigger for DELETE Method with 500 Status

To configure an API Trigger for server errors:

  1. Title: Provide a descriptive title for the trigger.
  2. Description: Explain the purpose of the trigger.
  3. API Method: Select DELETE.
  4. Status: Set the status code to 500.
  5. API URL: Enter the API endpoint with path variables (e.g., api/v1/students/id).

Example:

  • Title: Server Error on Student Deletion
  • Description: Trigger on server error during student deletion
  • API Method: DELETE
  • Status: 500
  • API URL: api/v1/students/id

Validating API Triggers

To validate the configuration of an API Trigger:

  1. Review Configuration: Ensure all fields are correctly filled with appropriate values.
  2. Check API Method and Status: Confirm that the correct HTTP method and status code are set.

Validation Checklist:

  • Title
  • Description
  • API Method
  • Status
  • API URL

Verifying API Trigger Activation

Verify GET API Trigger Activation with 401 Status

To verify activation of a GET API trigger for unauthorized access:

  1. Trigger: Make an unauthorized GET request to api/v1/students.
  2. API Response: The API should return a 401 status.

Expected Outcome:

  • The API Trigger should be activated and verified as working correctly.

Verify POST API Trigger Activation with 201 Status

To verify activation of a POST API trigger for successful creation:

  1. Trigger: Make a successful POST request to api/v1/students.
  2. API Response: The API should return a 201 status.

Expected Outcome:

  • The API Trigger should be activated and verified as working correctly.

Verify PUT API Trigger Activation with Custom Status

To verify activation of a PUT API trigger for custom status updates:

  1. Trigger: Make a PUT request to api/v1/students/id resulting in a 409 status.
  2. API Response: The API should return a 409 status.

Expected Outcome:

  • The API Trigger should be activated and verified as working correctly.

Verify DELETE API Trigger Activation with 500 Status

To verify activation of a DELETE API trigger for server errors:

  1. Trigger: Make a DELETE request to api/v1/students/id resulting in a 500 status.
  2. API Response: The API should return a 500 status.

Expected Outcome:

  • The API Trigger should be activated and verified as working correctly.

Summary

API Triggers enable the Workflow Management module to automate actions based on various API responses. By configuring triggers for different HTTP methods and status codes, users can ensure their workflows respond appropriately to changes and issues in API interactions.