---
updatedAt: 2025-09-18T21:59:45.000Z
agentTools:
  projectIndex: https://dev.kevel.com/llms.txt
---

# Create Flight Segment Targeting Rule

Create a Flight to Segment targeting rule

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "management-api-2",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.kevel.co"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "name": "X-Adzerk-ApiKey",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/flight/{FlightId}/segmenttargeting": {
      "post": {
        "summary": "Create Flight Segment Targeting Rule",
        "description": "Create a Flight to Segment targeting rule",
        "operationId": "create-flight-segment",
        "parameters": [
          {
            "name": "FlightId",
            "in": "path",
            "description": "The flight the targeting rule applies to",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "SegmentId"
                ],
                "properties": {
                  "SegmentId": {
                    "type": "integer",
                    "description": "Id of the Segment",
                    "format": "int32"
                  },
                  "IsExclude": {
                    "type": "boolean",
                    "description": "Whether targeting is to be excluded or included.",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \t\"Id\": 56789,\n\t\t\"FlightId\": 55555,\n    \"SegmentId\": 123456,\n    \"IsExclude\": false,\n\t\t\"Segment\":\n        \t{\n\t\t\t\t\t\t\"Source\": \"audience\",\n  \t\t\t\t\t\"Name\": \"best customers\",\n  \t\t\t\t\t\"Reach\": { \"all_time\": 3187463, \"28d\": 387434 },\n  \t\t\t\t\t\"Description\": \"top 1% spenders in the last 30 days.\",\n  \t\t\t\t\t\"Category\": \"CRM\"\n\t\t\t\t\t}\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "Id": {
                      "type": "integer",
                      "example": 56789,
                      "default": 0
                    },
                    "FlightId": {
                      "type": "integer",
                      "example": 55555,
                      "default": 0
                    },
                    "SegmentId": {
                      "type": "integer",
                      "example": 123456,
                      "default": 0
                    },
                    "IsExclude": {
                      "type": "boolean",
                      "example": false,
                      "default": "false"
                    },
                    "Segment": {
                      "type": "object",
                      "properties": {
                        "Source": {
                          "type": "string",
                          "example": "audience"
                        },
                        "Name": {
                          "type": "string",
                          "example": "best customers"
                        },
                        "Reach": {
                          "type": "object",
                          "properties": {
                            "all_time": {
                              "type": "integer",
                              "example": 3187463,
                              "default": 0
                            },
                            "28d": {
                              "type": "integer",
                              "example": 387434,
                              "default": 0
                            }
                          }
                        },
                        "Description": {
                          "type": "string",
                          "example": "top 1% spenders in the last 30 days."
                        },
                        "Category": {
                          "type": "string",
                          "example": "CRM"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "curl -X POST -H \"X-Adzerk-ApiKey:<APIKEY>\" -H \"Content-Type:application/json\" https://api.kevel.co/v1/flight/{FlightId}/segmenttargeting --data-binary '{\"SegmentId\":123456,\"IsExclude\":false}' "
            },
            {
              "language": "javascript",
              "code": "// coming soon to @adzerk-management-sdk\n\nconst Adzerk = require('@adzerk/management-sdk');\nconst apiKey = process.env.ADZERK_API_KEY;\n\nasync function createFlightSegment() {\n  let specifications = await Adzerk.fetchSpecifications();\n  let client = await Adzerk.buildClient({apiKey, specifications});\n\n  let targetingRule = await client.run(\"flightSegment\", \"create\", {\n    segmentId:123456,\n    isExclude: false\n  });\n\n  console.log(targetingRule);\n}\n\ncreateFlightSegment();"
            },
            {
              "language": "ruby",
              "code": "## coming soon to @adzerk-management-sdk\n\nrequire \"adzerk\"\n\ndef create_flight_segment()\n    client = Adzerk::Client.new(ENV[\"ADZERK_API_KEY\"])\n    pp client.flightSegment.create(segmentId: 123456, isExclude: false)\nend\ncreate_flight_segment()"
            }
          ],
          "samples-languages": [
            "curl",
            "javascript",
            "ruby"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [
      {
        "key": "X-Adzerk-Sdk-Version",
        "value": "Readme.io:ManagementAPI2"
      }
    ],
    "explorer-enabled": false,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true
}
```