02 - APIs & Webhooks
The most common usecase for many is building APIs and Webhooks. The initial part of the tutorial will focus on this.
These can be built from existing endpoints, shell commands, scripts, files etc. and chained with storing to a database or being ingested by another endpoint etc.
As we step through, you will be naturally exposed to how workflows, automations and command based utilities can be built.
Steps
1. HTTP GET API
In this simple example we will be creating a HTTP GET API where we will access the available query parameters. You may add or adjust the query parameters in the validation steps to see how the data is handled.
Deploy via Hosted / Managed
- Ensure you are logged into https://app.airpipe.io
 - Click Deploy
to load the below example config into your account
- Alternatively, go to Configurations > Add New, and copy and paste the example
 
 
Deploy via Self Hosted / Unmanaged
- A 
configsdirectory should have been created automatically for you, else create one. - Copy the below example config into your 
configsdirectory, eg.configs/02-http-get.yml - Stop/Start 
airpipeeg../airpipe server --api-key your-api-key --config-dir configs 
Example Config
Deployloading...
Test
Hosted mode, either navigate to or curl:
- 
The load configuration UI will automatically show you what your detected routes are, you can copy this for the next steps.
 - 
The link is automatically built with your organization uuid and environment, your API endpoints can be found here if required https://app.airpipe.io/configurations.
 - 
Update the route as necessary
 
curl https://app.airpipe.io/your_org_uuid/staging/tutorial/myroute?msg=hello
Self hosted mode, either navigate to or curl:
http://0.0.0.0:4111/tutorial/myroute?msg=hello
curl http://0.0.0.0:4111/tutorial/myroute?msg=hello
Response
{
  "data": {
    "CheckQueryParams": {
      "data": {
        "msg": "hello"
      },
      "time.ms": 3
    }
  }
}
2. HTTP POST API (Webhook)
In this simple example we will be creating a HTTP POST API where we will access data from the posted body. You may add or adjust the payload sent in the validation steps to see how the data is handled.
Deploy via Hosted / Managed
- Ensure you are logged into https://app.airpipe.io
 - Click Deploy
to load the below example config into your account
- Alternatively, go to Configurations > Add New, and copy and paste the example
 
 
Deploy via Self Hosted / Unmanaged
- A 
configsdirectory should have been created automatically for you, else create one. - Copy the below example config into your 
configsdirectory, eg.configs/02-http-post-webhook.yml - Stop/Start 
airpipeeg../airpipe server --api-key your-api-key --config-dir configs 
Example Config
Deployloading...
Test
Hosted mode, curl or use your preferred API testing tool:
- 
The load configuration UI will automatically show you what your detected routes are, you can copy this for the next steps.
 - 
The link is automatically built with your organization uuid and environment, your API endpoints can be found here if required https://app.airpipe.io/configurations.
 - 
Update the route as necessary
 
curl --location 'https://api.airpipe.io/your-org-uuid/staging/tutorial/webhook' \
--header 'Content-Type: application/json' \
--data '{
    "message": "hello world",
    "heroes": [
        {
            "name": "batman",
            "identity": "bruce"
        },
        {
            "name": "superman",
            "identity": "clark"
        }
    ]
}'
Self hosted mode, curl or use your preferred API testing tool:
curl --location 'http://0.0.0.0:4111/tutorial/webhook' \
--header 'Content-Type: application/json' \
--data '{
    "message": "hello world",
    "heroes": [
        {
            "name": "batman",
            "identity": "bruce"
        },
        {
            "name": "superman",
            "identity": "clark"
        }
    ]
}'
Response
{
    "data": {
        "CheckBody": {
            "data": {
                "heroes": [
                    {
                        "identity": "bruce",
                        "name": "batman"
                    },
                    {
                        "identity": "clark",
                        "name": "superman"
                    }
                ],
                "message": "hello world"
            },
            "time.ms": 0
        }
    }
}