Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Segment Definitions

Manage environment-specific standard segment instances (description, keys, segment and environment references, soft-delete).

List Segment Definitions

get
/v4/segment-definitions

Returns a paginated list of Segment Definitions in the Environment specified by environment_id. Defaults to active definitions (status defaults to [ACTIVE]). More than one status returns 400. Returns 404 if environment_id does not identify an active Environment in the project.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
limitinteger · min: 1 · max: 100Optional

Number of items to return per page. Defaults to 100, maximum 100.

Default: 100Example: 100
offsetintegerOptional

Number of items to skip before the first returned result. Defaults to 0.

Default: 0Example: 0
Responses
200

OK — paginated list of segment definitions returned.

application/json

Paginated list of Segment Definitions matching the query.

limitintegerRequired

The page size used for this response.

Example: 100
offsetintegerRequired

The number of items skipped before the first result.

Example: 0
totalCountintegerRequired

Total number of segment definitions matching the query.

Example: 8
get/v4/segment-definitions
GET /fme/api/v4/segment-definitions?account_id={{accountId}}&organization_identifier=default&project_identifier=my_project&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319 HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Accept: */*
{
  "data": [
    {
      "id": "d4e5f6a7-b8c9-0123-def0-234567890123",
      "description": "Power users in production",
      "segment": {
        "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
        "name": "power-users"
      },
      "environment": {
        "id": "ad2eb8f0-9c3a-11ed-873c-e234abaad319",
        "name": "Production"
      },
      "createdAt": "2025-06-01T12:00:00Z",
      "status": "ACTIVE"
    }
  ],
  "limit": 100,
  "offset": 0,
  "totalCount": 8
}

Get a Segment Definition

get
/v4/segment-definitions/{segment-name}

Requires environment_id as a query parameter. Returns a single active Segment Definition for the specified segment in the specified environment. Soft-deleted (ARCHIVED) definitions are not returned by name lookup (404); use LIST with status=ARCHIVED to discover them.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
segment-namestring · max: 100Required

The unique name of the segment within the project. Names must begin with a letter and may contain letters, numbers, underscores, and hyphens. Use the same value that was supplied as name when the segment was created. System-assigned ids are not accepted.

Example: power-usersPattern: ^[A-Za-z][-_A-Za-z0-9]*$
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Responses
200

OK — segment definition returned.

application/json

An environment-specific Segment Definition (standard segment instance).

idstring · uuidRequired

System-assigned identifier for this segment definition.

Example: d4e5f6a7-b8c9-0123-def0-234567890123
descriptionstring · nullableOptional

Human-readable description of this segment in the given environment.

Example: Power users in production
createdAtstring · date-timeRequired

ISO-8601 timestamp when this definition was created.

Example: 2025-06-01T12:00:00Z
statusstring · enumRequired

Lifecycle status of the segment definition.

  • ACTIVE — definition is live.
  • ARCHIVED — definition is no longer active (soft-deleted).
Example: ACTIVEPossible values:
get/v4/segment-definitions/{segment-name}
GET /fme/api/v4/segment-definitions/{segment-name}?account_id={{accountId}}&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Accept: */*
{
  "id": "d4e5f6a7-b8c9-0123-def0-234567890123",
  "description": "Power users in production",
  "segment": {
    "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
    "name": "power-users"
  },
  "environment": {
    "id": "ad2eb8f0-9c3a-11ed-873c-e234abaad319",
    "name": "Production"
  },
  "createdAt": "2025-06-01T12:00:00Z",
  "status": "ACTIVE"
}

Create a Segment Definition

post
/v4/segment-definitions/{segment-name}

Requires environment_id as a query parameter. Creates a new Segment Definition for the specified segment in the specified environment. A definition must not already exist for this segment + environment combination (409 on conflict). When the environment requires approval, returns 403.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
segment-namestring · max: 100Required

The unique name of the segment within the project. Names must begin with a letter and may contain letters, numbers, underscores, and hyphens. Use the same value that was supplied as name when the segment was created. System-assigned ids are not accepted.

Example: power-usersPattern: ^[A-Za-z][-_A-Za-z0-9]*$
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Body

Optional body. Omit or send {} to create the default definition shell.

descriptionstringOptional

Human-readable description of this segment in the given environment.

Example: Power users in production
Responses
201

Created — the segment definition was successfully created.

application/json

Mutation response (create, update): entity plus OPA governance.

post/v4/segment-definitions/{segment-name}
POST /fme/api/v4/segment-definitions/{segment-name}?account_id={{accountId}}&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 43

{
  "description": "Power users in production"
}
{
  "entity": {
    "id": "d4e5f6a7-b8c9-0123-def0-234567890123",
    "description": "Power users in production",
    "segment": {
      "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "name": "power-users"
    },
    "environment": {
      "id": "ad2eb8f0-9c3a-11ed-873c-e234abaad319",
      "name": "Production"
    },
    "createdAt": "2025-06-01T12:00:00Z",
    "status": "ACTIVE"
  },
  "governance": {
    "status": "PASS",
    "details": []
  }
}

Delete a Segment Definition

delete
/v4/segment-definitions/{segment-name}

Requires environment_id as a query parameter. Soft-deletes a Segment Definition by transitioning it to ARCHIVED. After delete, GET by name returns 404; the definition remains discoverable via LIST when status includes ARCHIVED. Returns the OPA governance result. Deleting a definition that is already ARCHIVED returns 404. Returns 409 when a pending change request already exists (pendingChangeConflict), or when keys / flag / rule-based-segment dependents block delete (hasDependents). When the environment requires approval, returns 403. Accepts optional comment/title query parameters for the archive's audit trail; some workspaces require one or both, and omitting a required one returns 400.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
segment-namestring · max: 100Required

The unique name of the segment within the project. Names must begin with a letter and may contain letters, numbers, underscores, and hyphens. Use the same value that was supplied as name when the segment was created. System-assigned ids are not accepted.

Example: power-usersPattern: ^[A-Za-z][-_A-Za-z0-9]*$
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
commentstringOptional

Optional audit comment recorded with the action. Delivered as a query parameter because the endpoint has no request body. Some workspaces require a comment on this action; when required and omitted, returns 400.

Example: Deprecated, no longer targeted
titlestringOptional

Optional audit title recorded with the action. Delivered as a query parameter because the endpoint has no request body. Some workspaces require a title on this action; when required and omitted, returns 400.

Example: Remove unused segment definition
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Responses
200

OK — segment definition deleted. Returns the governance result.

application/json

Response envelope for delete operations. Contains only the OPA governance result — no entity is returned. Shared by all FME resources so delete responses are consistent.

delete/v4/segment-definitions/{segment-name}
DELETE /fme/api/v4/segment-definitions/{segment-name}?account_id={{accountId}}&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Accept: */*
{
  "governance": {
    "status": "PASS",
    "details": []
  }
}

Update a Segment Definition (partial)

patch
/v4/segment-definitions/{segment-name}

Requires environment_id as a query parameter. Partially updates a Segment Definition using JSON Merge Patch semantics (RFC 7396). Only fields present in the request body are modified; omitted fields are left unchanged. JSON null clears description. See UpdateSegmentDefinitionRequest.

Only ACTIVE definitions can be updated. Name lookup for non-active definitions returns 404. Returns 409 when a pending change request already exists for this definition. When the environment requires approval, returns 403.

Updatable fields: description.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
segment-namestring · max: 100Required

The unique name of the segment within the project. Names must begin with a letter and may contain letters, numbers, underscores, and hyphens. Use the same value that was supplied as name when the segment was created. System-assigned ids are not accepted.

Example: power-usersPattern: ^[A-Za-z][-_A-Za-z0-9]*$
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Body

JSON Merge Patch body (RFC 7396) for updating a Segment Definition. Only description is updatable. Omit the field to leave it unchanged; send JSON null to clear it.

descriptionstring · nullableOptional

Updated description, or null to clear.

Example: Updated production power users
Responses
200

OK — segment definition partially updated.

application/json

Mutation response (create, update): entity plus OPA governance.

patch/v4/segment-definitions/{segment-name}
PATCH /fme/api/v4/segment-definitions/{segment-name}?account_id={{accountId}}&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Content-Type: application/merge-patch+json
Accept: */*
Content-Length: 48

{
  "description": "Updated production power users"
}
{
  "entity": {
    "id": "d4e5f6a7-b8c9-0123-def0-234567890123",
    "description": "Power users in production",
    "segment": {
      "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "name": "power-users"
    },
    "environment": {
      "id": "ad2eb8f0-9c3a-11ed-873c-e234abaad319",
      "name": "Production"
    },
    "createdAt": "2025-06-01T12:00:00Z",
    "status": "ACTIVE"
  },
  "governance": {
    "status": "PASS",
    "details": []
  }
}

List Segment Definition Keys

get
/v4/segment-definitions/{segment-name}/keys

Requires environment_id as a query parameter. Returns a paginated list of membership keys for the specified active Segment Definition in the specified environment. Page size is capped at 100.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
segment-namestring · max: 100Required

The unique name of the segment within the project. Names must begin with a letter and may contain letters, numbers, underscores, and hyphens. Use the same value that was supplied as name when the segment was created. System-assigned ids are not accepted.

Example: power-usersPattern: ^[A-Za-z][-_A-Za-z0-9]*$
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
limitinteger · min: 1 · max: 100Optional

Number of items to return per page. Defaults to 100, maximum 100.

Default: 100Example: 100
offsetintegerOptional

Number of items to skip before the first returned result. Defaults to 0.

Default: 0Example: 0
Responses
200

OK — paginated list of membership keys returned.

application/json

Paginated list of membership keys for a Segment Definition.

datastring[]Required

Membership keys on this page.

Example: ["user-1001","user-1002"]
limitintegerRequired

The page size used for this response.

Example: 100
offsetintegerRequired

The number of items skipped before the first result.

Example: 0
totalCountintegerRequired

Total number of membership keys in the Segment Definition.

Example: 250
get/v4/segment-definitions/{segment-name}/keys
GET /fme/api/v4/segment-definitions/{segment-name}/keys?account_id={{accountId}}&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Accept: */*
{
  "data": [
    "user-1001",
    "user-1002"
  ],
  "limit": 100,
  "offset": 0,
  "totalCount": 250
}

Add Segment Definition Keys

post
/v4/segment-definitions/{segment-name}/keys

Requires environment_id as a query parameter. Adds membership keys to the Segment Definition. When replace=true, the submitted list replaces the existing membership (an empty keys array clears membership); when false (default), keys are merged and an empty list is rejected. At most 10000 keys per request. Only ACTIVE definitions accept key mutations; name lookup for non-active definitions returns 404. When the environment requires approval, returns 403.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
segment-namestring · max: 100Required

The unique name of the segment within the project. Names must begin with a letter and may contain letters, numbers, underscores, and hyphens. Use the same value that was supplied as name when the segment was created. System-assigned ids are not accepted.

Example: power-usersPattern: ^[A-Za-z][-_A-Za-z0-9]*$
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
replacebooleanOptional

When true, replace the entire key membership with the submitted list (including an empty list to clear). When false (default), add the submitted keys without removing existing ones.

Default: falseExample: false
Body

Request body for adding membership keys (or replacing membership when replace=true). An empty keys array is allowed and clears membership when replace=true; when replace=false, the server rejects an empty list.

keysstring[] · max: 10000Required

Traffic keys (for example, user identifiers) to add or replace with.

Example: ["user-1001","user-1002"]
commentstringOptional

Optional comment recorded with the action.

Example: Onboarding cohort for Q3 rollout
titlestringOptional

Optional title recorded with the action.

Example: Add power-user cohort
Responses
200

OK — keys added (or membership replaced when replace=true).

application/json

Submitted membership keys together with the OPA governance result.

keysstring[]Required

Submitted keys accepted for processing. May include keys that were already members (add) or keys that were not members (remove); those cases are treated as no-ops.

Example: ["user-1001","user-1002"]
post/v4/segment-definitions/{segment-name}/keys
POST /fme/api/v4/segment-definitions/{segment-name}/keys?account_id={{accountId}}&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 111

{
  "keys": [
    "user-1001",
    "user-1002"
  ],
  "comment": "Onboarding cohort for Q3 rollout",
  "title": "Add power-user cohort"
}
{
  "keys": [
    "user-1001",
    "user-1002"
  ],
  "governance": {
    "status": "PASS",
    "details": []
  }
}

Remove Segment Definition Keys

post
/v4/segment-definitions/{segment-name}/keys/remove

Requires environment_id as a query parameter. Removes the submitted membership keys from the Segment Definition. Keys that are not currently members are ignored. At most 10000 keys per request. Only ACTIVE definitions accept key mutations; name lookup for non-active definitions returns 404. When the environment requires approval, returns 403.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
segment-namestring · max: 100Required

The unique name of the segment within the project. Names must begin with a letter and may contain letters, numbers, underscores, and hyphens. Use the same value that was supplied as name when the segment was created. System-assigned ids are not accepted.

Example: power-usersPattern: ^[A-Za-z][-_A-Za-z0-9]*$
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
environment_idstring · uuid · max: 128Required

Environment identifier. Scopes the request to a specific environment; combined with the resource name in the path it identifies a specific environment-scoped definition (e.g., a Feature Flag Definition or a Segment Definition).

Example: ad2eb8f0-9c3a-11ed-873c-e234abaad319Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Body

Request body for removing membership keys from a Segment Definition.

keysstring[] · min: 1 · max: 10000Required

Traffic keys (for example, user identifiers) to remove.

Example: ["user-1001","user-1002"]
commentstringOptional

Optional comment recorded with the action.

Example: Remove churned cohort
titlestringOptional

Optional title recorded with the action.

Example: Remove churned users
Responses
200

OK — keys removed.

application/json

Submitted membership keys together with the OPA governance result.

keysstring[]Required

Submitted keys accepted for processing. May include keys that were already members (add) or keys that were not members (remove); those cases are treated as no-ops.

Example: ["user-1001","user-1002"]
post/v4/segment-definitions/{segment-name}/keys/remove
POST /fme/api/v4/segment-definitions/{segment-name}/keys/remove?account_id={{accountId}}&environment_id=ad2eb8f0-9c3a-11ed-873c-e234abaad319&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 99

{
  "keys": [
    "user-1001",
    "user-1002"
  ],
  "comment": "Remove churned cohort",
  "title": "Remove churned users"
}
{
  "keys": [
    "user-1001",
    "user-1002"
  ],
  "governance": {
    "status": "PASS",
    "details": []
  }
}

Last updated

Was this helpful?