---
updatedAt: 2025-06-09T22:12:47.000Z
agentTools:
  projectIndex: https://developers.baremetrics.com/llms.txt
---

# Create Segment

The category is one of three keys: baremetrics, clearbit, or customer\_properties that you can see from [listing fields](https://developers.baremetrics.com/reference/list-fields).

![481](https://files.readme.io/b5af720-Image_2021-12-08_at_5.41.37_PM.jpg "Image 2021-12-08 at 5.41.37 PM.jpg")

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "production",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.baremetrics.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "x-bearer-format": "bearer",
        "x-default": "APIKEY"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/segments": {
      "post": {
        "summary": "Create Segment",
        "description": "",
        "operationId": "create-segment",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "array",
                    "items": {
                      "properties": {
                        "category": {
                          "type": "string"
                        },
                        "field": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string",
                          "description": "Can be an string, integer, or boolean"
                        },
                        "method": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "category",
                        "field",
                        "value",
                        "method"
                      ],
                      "type": "object"
                    }
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"segment\": {\n    \"id\": \"1\",\n    \"name\": \"Active Customers\",\n    \"query\": [\n      {\n        \"category\": \"baremetrics\",\n        \"field\": \"subscriptions.is_active\",\n        \"method\": \"boolean\",\n        \"value\": \"true\"\n      }\n    ],\n    \"created_at\": 1492523687,\n    \"updated_at\": 1492614366\n  }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "segment": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "1"
                        },
                        "name": {
                          "type": "string",
                          "example": "Active Customers"
                        },
                        "query": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "category": {
                                "type": "string",
                                "example": "baremetrics"
                              },
                              "field": {
                                "type": "string",
                                "example": "subscriptions.is_active"
                              },
                              "method": {
                                "type": "string",
                                "example": "boolean"
                              },
                              "value": {
                                "type": "string",
                                "example": "true"
                              }
                            }
                          }
                        },
                        "created_at": {
                          "type": "integer",
                          "example": 1492523687,
                          "default": 0
                        },
                        "updated_at": {
                          "type": "integer",
                          "example": 1492614366,
                          "default": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": false
  },
  "x-readme-fauxas": true
}
```