Build a custom API action card

A Custom API Action (CAPIA) is an action card for connectors that allows the end user to make an authenticated HTTP request to an external service.

The base URL is hard-coded into the connector, so users only need to add the relative URL for the endpoint. They then manually create the required objects for header, query, and request body, if necessary.

The CAPIA then returns data from the service as three outputs: Status Code, Headers, and Body.

  1. Create a flow under the Flows tab by clicking + New Flow in the upper right corner of the page.

  2. Click Action.

  3. Click Save in the toolbar and name the flow Custom API Action.

  4. In the flow description field, type Make an authenticated HTTP request to the {your service} API. Select the Save all data that passes through the Flow option, and then click Save.

  5. Click Add Options on the Connector Action card.

  6. Click Add Field and add a field with the label Request Type and a type of Dropdown: Static Values.

  7. Click Add Option to add a row for each request type the user can choose for your API: GET, PATCH, POST, PUT, and DELETE. Fill in the Option and Value fields with the same text. You don't need to select a default.

  8. Make sure that the field is marked as Required and click Save.

  9. Click Add Inputs on the Connector Action card.

  10. Click Add Field and add the following fields and data types and click Save.

    • Relative URL: Text and Required

    • Query: Object

    • Headers: Object

    • Body: Object

  11. Add input validation for the Relative URL input. This prevents against vulnerabilities such as Cross-Site Request Forgery (CSRF) attacks.

    1. Add a Text At card as the first card in the flow.

    2. Drag the Relative URL output from the Connector Action card into the text input on the Text At card.

    3. Set the position input to 0 on the Text At card.

    4. Add an error handling Return Error If card as the second card in the flow.

    5. Drag the character output from the Text At card into the value a input on the Return Error If card.

    6. Set the comparison option to not equal on the Return Error If card.

    7. Set the value b input to / on the Return Error If card.

    8. For the message input, enter Relative URL must include a leading '/'. on the Return Error If card.

    9. Set the statusCode input to 400 on the Return Error If card.

  12. From the Flow Control functions, add a Call Flow card as the third card in the flow.

  13. Click Choose Flow.

  14. Select the httpHelper flow you previously created. The card automatically populates using the inputs defined in the httpHelper flow.

  15. Drag the Relative URL output from the Connector Action card into the relative_url input on the Call Flow card.

  16. Drag the Request Type output from the Connector Action card into the request_method input on the Call Flow card.

  17. Drag the Query output from the Connector Action card into the query input on the Call Flow card.

  18. Drag the Headers output from the Connector Action card into the headers input on the Call Flow card.

  19. Drag the Body output from the Connector Action card into the body input on the Call Flow card.

  20. For the outputs on the Call Flow card, you also need to define the same keys as on the httpHelper flow's outputs:

    • status_code: Number

    • headers: Object

    • body: Object

  21. Click Add Outputs on the Return Outputs card.

  22. Click Add Field to add the following three new fields with data types and click Save.

    • Status Code: Number

    • Headers: Object

    • Body: Object

  23. Drag the outputs from the Call Flow card to the corresponding inputs on the Return Outputs card.

  24. Drag the auth object from the connector Authping card to the Connection input field of the Call Flow card.

  25. Save and test your flow by manually adding a request method, relative URL, and any other data to the test dialog.

Next steps

Build a revoke flow