> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xtremepush.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create segment

> Used to create a new segment.

For more information on segments review our [segmentation guide](https://docs.xtremepush.com/docs/segmentation). For details on the available conditions for this endpoint see our dedicated [segment model properties guide](https://docs.xtremepush.com/reference/segment-model).

## OpenAPI

````json POST /create/segment
{
  "openapi": "3.1.0",
  "info": {
    "title": "external-api",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.eu.xtremepush.com/api/external"
    }
  ],
  "paths": {
    "/create/segment": {
      "post": {
        "summary": "Create segment",
        "description": "Used to create a new segment.\n\nFor more information on segments review our [segmentation guide](https://docs.xtremepush.com/docs/segmentation). For details on the available conditions for this endpoint see our dedicated [segment model properties guide](https://docs.xtremepush.com/reference/segment-model).",
        "operationId": "segment-create",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "apptoken",
                  "title"
                ],
                "properties": {
                  "apptoken": {
                    "type": "string",
                    "description": "Your App token"
                  },
                  "title": {
                    "type": "string",
                    "description": "Title of the segment"
                  },
                  "condition": {
                    "type": "string",
                    "format": "json",
                    "description": "Conditions that define the segment"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": "200",
                      "default": "0"
                    },
                    "success": {
                      "type": "boolean",
                      "example": "true",
                      "default": "true"
                    },
                    "message": {
                      "type": "string",
                      "example": "Segment successfully created"
                    },
                    "model": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "SEGMENT_ID"
                        },
                        "project_id": {
                          "type": "string",
                          "example": "PROJECT_ID"
                        },
                        "title": {
                          "type": "string",
                          "example": "Test"
                        },
                        "conditions": {
                          "type": "object"
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "code": "200",
                      "success": "true",
                      "message": "Segment successfully created",
                      "model": {
                        "id": "SEGMENT_ID",
                        "project_id": "PROJECT_ID",
                        "title": "Test",
                        "conditions": {
                          "0": {
                            "0": [
                              "tags",
                              "=",
                              "15_01_04",
                              [
                                "hits",
                                ">",
                                "5"
                              ],
                              [
                                "daterange",
                                "between",
                                "2015-01-01 to 2015-01-30",
                                "2015-01-01",
                                "2015-01-30"
                              ]
                            ],
                            "1": [
                              "app_downloaded",
                              null,
                              null,
                              [
                                "days_ago",
                                ">",
                                null,
                                null,
                                null,
                                "10"
                              ]
                            ],
                            "2": [
                              "country",
                              "=",
                              "IE"
                            ],
                            "operator": "AND"
                          },
                          "operator": "AND"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": "400",
                      "default": "0"
                    },
                    "success": {
                      "type": "boolean",
                      "example": "false",
                      "default": "true"
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "code": "400",
                      "success": "false"
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Segmentation Methods"
        ]
      }
    }
  }
}
````

