# Why create a flight category?

When you are working with flights and campaigns, you may wish to add a category to this flight. The `Create Flight Categories` API endpoint will add this category to the flight; however, if the category does not exist, this API call will create the category and then add it to the flight.

The JSON response will include the unique Flight Category ID that can be used to remove the category from the flight.

# API syntax

When using the `Create Flight Categories` API, it is important to understand the syntax required to make the request. Because the Kevel API is a RESTful API, there is a specific request format that must be followed to ensure the endpoint can process the request. The format is:

`GET https://api.kevel.co//v1/flight/{FlightID}/category`

Where:

- `GET` - the type of API request being made.
- `https://api.kevel.co` - the URL for the request.
- `v1` - the API version.
- `flight` - the API endpoint being called.
- `FlightID` - The ID associated with the flight.
- `category` - The individual category associated with the flight.

### FlightID

| Field     | Type   | Requirement | Description             |
|-----------|--------|-------------|-------------------------|
| FlightID  | int32  | required    | ID of the Flight        |
| Name      | string | required    | The category's name     |
| Id        | int32  | optional    | The category ID. If the category is new to your network, this field is optional |

# Response Format

### `200`

```json
{
  "Id": 4567,
  "Name": "Sports"
}
```

### Creating a new category:

```bash
curl -X POST -H 'X-Adzerk-ApiKey:<APIKEY>' -H "Content-Type:application/json" "https://api.kevel.co/v1/flight/12345/category" --data-binary '{"Name":"Sports"}'
```

### Linking an existing category to the flight:

```bash
curl -X POST -H 'X-Adzerk-ApiKey:<APIKEY>' -H "Content-Type:application/json" "https://api.kevel.co/v1/flight/12345/category" --data-binary '{"Name":"Sports","Id":4567}'
```
