# Why create a day part?

When you are working flights and campaigns, you may wish to create a schedule for when your ads are served. This can be during certain parts of the day, different times of the week, or even changing bids or creatives at different times.

For example, you may wish to not have an ad served from 11am - 2pm PST on Wednesdays. Kevel enables this functionality through the `Create Day Part` API, which is why you may want to specify when an ad should be served, and when it should not be served. When used, the day part is created and associates the day part with a flight. Also, note that a flight may be associated with multiple day parts.

> 📘
>
> ### Note  
> For each `WeekDay` in a day part, the day part will serve from the first instance of the `StartTime` until the first instance of the `EndTime`.
>
> The `EndTime` can potentially be earlier than the `StartTime`. In that case, the day part will stop serving when the `EndTime` is reached on the day following the `WeekDay`.

> ❗️
>
> ### Warning  
> Day parts cannot overlap in the same flight.

# API syntax

When using the `Create Day Part` 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:

`POST https://api.kevel.co/v1/flight/{FlightID}/dayparting`

Where:

- `POST`- 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.
- `dayparting`- The schedule (day parts) for the ad.

## Parameters

- **FlightID**  
  `int32`  
  required  
  The ID of the flight

- **StartTime**  
  `string`  
  required  
  A start time for the day part, in the format of `HH:MM:SS`. Uses the local time of the flight based on the flight's TimeZone. Granularity is at the minute level.

- **EndTime**  
  `string`  
  required  
  A start time for the day part, in the format of `HH:MM:SS`. Uses the local time of the flight based on the flight's TimeZone. Granularity is at the minute level.

- **WeekDays**  
  `array of strings`  
  required  
  One or more days of the week the day part applies to, in the form of:  
  "SU" "MO" "TU" "WE" "TH" "FR" "SA"

## Example

```bash
curl -X POST -H "X-Adzerk-ApiKey:$ADZERK_API_KEY" "https://api.kevel.co/v1/flight/12345/dayparting" -d '{"StartTime":"09:30:00","EndTime":"17:00:00","WeekDays":["MO","TU"]}'
```

```json
{
  "TimepartId": 67890
}
```

Updated 10 months ago
