# App APIs

Sometimes you need to interact with your Application or its data outside of Airkit. Application APIs are a way to build custom API endpoints and interact with Airkit from external systems, leveraging the available data operations to create Journeys, modify existing Journeys, validate data, or even read data from AirData.

## What is an App API?

An App API is a powerful method for integrating Airkit with other applications and services. It is how you can create a custom REST endpoints that are defined by you, through the use of combining and adding data operations together. With App APIs, you are able to create either a GET request or a POST request and can also configure your endpoint path, path parameters, and query parameters.

![](https://3088276961-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC6qMwMGWBgxnN70QsDuH%2Fuploads%2Fgit-blob-8817ce502179d5336d5f7d34ded5bd967a8294a9%2Fapplication-apis-v182-0.png?alt=media)

For a guide on how to build an App API, see [Building an App API](application-apis/building-an-app-api).

## Securing App APIs

If the App API requires Authentication and should not be publicly available, a token must be created. The API token that gets generated is a JWT token. For this you will need an API key that can be generated from the [Console](https://console.airkit.com) (API > Tokens):

![](https://3088276961-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC6qMwMGWBgxnN70QsDuH%2Fuploads%2Fgit-blob-2536a5d384f0d71f43ee9b8886646351d4132903%2Fapplication-apis-v182-1.png?alt=media)

> 🚧 API Keys Make sure to safely store the generated token at that moment since it will not be retrievable after the window is closed. If the API key is lost, you can delete the API key and create a new one.

Once the token has been created in the Console, go to **Settings** and add the API Key in **API Key Filtering**.

![](https://3088276961-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC6qMwMGWBgxnN70QsDuH%2Fuploads%2Fgit-blob-1f94a65e1f4ea319448953b0a958a562053c996e%2Fapplication-apis-v182-2.png?alt=media)

This will make it appear under Authentication in **Triggers** > **App APIs** .

![](https://3088276961-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC6qMwMGWBgxnN70QsDuH%2Fuploads%2Fgit-blob-7e4510970c97e5ebeb1cacacc8c700e99561ccc9%2Fapplication-apis-v182-3.png?alt=media)

### Making a request to a Secure API

If you want to make an HTTP request to an App API that requires Authentication, this requires the request to include the token in the request header.

In the **headers** of the request, add:

```http
Authorization: Bearer <Your API token>
```

### API Tokens and Environments

Upon creation, the token needs to be assigned an environment in multi-environment organizations. This would then make the API Token only accessible to developers who have access to the corresponding environment. For example, if a developer created an API token in the development environment, then that API Token can only be used for an API created in the development environment.

For more information see [Environments](../administration/environments).

![](https://files.readme.io/6194ba0-2022-06-09_10-57-45.png)

## Redirects

When using an App API to redirect to a URL it is recommended to use the `302` response status code instead of `301`. `301`s are cached by the browser which may result in unintended behavior.

![](https://files.readme.io/115d2ce-2022-05-19_14-59-17.png)

## Accessible Data from App API

The following is a sample payload of data that is accessible when you trigger an App API. This data can be passed to a journey and used across your application.

```json
{
  "fqdn": "app.airkit.com",
  "pathMapping": {
    "test": "foo"
  },
  "queryParams": {
    "queryParam": "bar"
  },
  "header": {
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
    "accept-encoding": "gzip, deflate",
    "accept": "*/*",
    "x-forwarded-for": "206.189.180.4"
  },
  "host": "www.domain.com",
  "httpVersion": "1.1",
  "cookies": {
    "name": "value"
  }
}
```

## Limits

> 🚧 **Payload Limits Data passed as a request payload for App APIs have a maximum size of 5mb.**
