Bespoke API

Add your own public or admin API's

One key part of extensibility is a feature that lets you create your own REST API endpoints.

This are a really important part when you want to be able to either publicly, or as an admin, validate internal data, or call third party services in a secure way

Here is an example of the manifest of a public script

 {
      "name":"TestAPi",
      "description":"My example test API",
      "type":"PublicScript",
      "actions": ["Get"],
      "log_type": "Tail",
      "enabled": true,
      "handler": "my_script"
      "proxy: true
    }

There are several values to unpack here:

  • Type:

    • PublicScript: A script that can be run form a public URL with no authentication
    • AdminScript: A script that can only be run by a staff user of the system. You are passed the details of the user to allow you to further control permissions
  • Actions:

    • Get: An HTTP GET Command
    • Put: An HTTP PUT Command
    • Post: An HTTP POST Command
    • Delete: An HTTP DELETE Command

You can support several of these in a single script by passing them in to an array

  • Proxy
    • false (default): Specifies that the returned result from the script comes back as a detailed response along with other useful data, such as logs if you've got log_type set to 'Tail'
    • true: Allows your returned result to be passed back via a 'proxy' response. Letting you return headers, custom HTTP status and explicit body response. This can also be controlled form the functions response itself

For some examples of creating, using and calling scripts please see: Scripts in Action