---
schema_version: "1"
id: 5361c21f9ab5f02c05dba958221716afffc028c032ce55531a8ee83068d1d4fa
title: CdpSegment Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_ConnectAPI_CdpSegment_static_methods.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 598748b0ac246240608e67518014b7ac6f153e8c19206cc0cbadb89101af4abd
description: Create, delete, get, publish, and update Data 360 segments.These methods are for CdpSegment. All methods are static.Create a segment.Create a segment in a dataspace.Deactivate a segment by API name.Deactivate a segment by ID.Delete a segment.Publish a segment.Get a segment by API name.Get a segment by ID.Get segments.Get an ordered batch of paginated segments.Get an ordered batch of paginated segments in a dataspace.Get an ordered and filtered batch of paginated segments.Get an ordered and filtered batch of paginated segments in a dataspace.Update a segment.
---
# CdpSegment Class

Create, delete, get, publish, and update Data 360 segments.

## Namespace

[ConnectApi](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_connect_api.htm "The ConnectApi namespace (also called Connect in Apex) provides classes for accessing the same data available in Connect REST API. Use Connect in Apex to create custom experiences in Salesforce.")

## CdpSegment Methods

These methods are for CdpSegment. All methods are static.

- **[createSegment(input)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_createSegment_4)**  
    Create a segment.
- **[createSegment(input, dataspace)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_createSegment_8)**  
    Create a segment in a dataspace.
- **[deactivateSegmentByApiName(segmentApiName)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_deactivateSegmentByApiName_1)**  
    Deactivate a segment by API name.
- **[deactivateSegmentById(segmentId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_deactivateSegmentById_1)**  
    Deactivate a segment by ID.
- **[deleteSegment(segmentApiName)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_deleteSegment_1)**  
    Delete a segment.
- **[executePublishAdhoc(segmentId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_executePublishAdhoc_1)**  
    Publish a segment.
- **[getSegment(segmentApiName)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_getSegment_3)**  
    Get a segment by API name.
- **[getSegmentById(segmentId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_getSegmentById)**  
    Get a segment by ID.
- **[getSegments()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_getSegments_2)**  
    Get segments.
- **[getSegmentsPaginated(batchSize, offset, orderBy)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_getSegmentsPaginated_4)**  
    Get an ordered batch of paginated segments.
- **[getSegmentsPaginated(batchSize, offset, orderBy, dataspace)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_getSegmentsPaginated_5)**  
    Get an ordered batch of paginated segments in a dataspace.
- **[getSegmentsFilteredPaginated(batchSize, offset, orderBy, filters)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_getSegmentsFilteredPaginated_6)**  
    Get an ordered and filtered batch of paginated segments.
- **[getSegmentsFilteredPaginated(batchSize, offset, orderBy, dataspace, filters)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_getSegmentsFilteredPaginated_7)**  
    Get an ordered and filtered batch of paginated segments in a dataspace.
- **[updateSegment(segmentApiName, input)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CdpSegment_static_methods.htm#apex_ConnectAPI_CdpSegment_updateSegment_4)**  
    Update a segment.

### createSegment(input)

Create a segment.

#### API Version

55.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentOutput createSegment(ConnectApi.CdpSegmentInput input)

#### Parameters

input

Type: [ConnectApi.CdpSegmentInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cdp_segment.htm "Segment input.")

A ConnectApi.CdpSegmentInput class.

#### Return Value

Type: [ConnectApi.CdpSegmentOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_output.htm "Segment.")

### createSegment(input, dataspace)

Create a segment in a dataspace.

#### API Version

58.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentOutput createSegment(ConnectApi.CdpSegmentInput input, String dataspace)

#### Parameters

input

Type: [ConnectApi.CdpSegmentInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cdp_segment.htm "Segment input.")

A ConnectApi.CdpSegmentInput class.

dataspace

Type: String

Name of the dataspace in which to perform the action. The user must have permission to the specified dataspace. Specify default to use the default dataspace.

#### Return Value

Type: [ConnectApi.CdpSegmentOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_output.htm "Segment.")

### deactivateSegmentByApiName(segmentApiName)

Deactivate a segment by API name.

#### API Version

59.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentActionOutput deactivateSegmentByApiName(String segmentApiName)

#### Parameters

segmentApiName

Type: String

API name of the segment.

#### Return Value

Type: [ConnectApi.CdpSegmentActionOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_action_output.htm "Segment action.")

### deactivateSegmentById(segmentId)

Deactivate a segment by ID.

#### API Version

59.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentActionOutput deactivateSegmentById(String segmentId)

#### Parameters

segmentId

Type: String

ID of the segment.

#### Return Value

Type: [ConnectApi.CdpSegmentActionOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_action_output.htm "Segment action.")

### deleteSegment(segmentApiName)

Delete a segment.

#### API Version

56.0

#### Requires Chatter

No

#### Signature

public static Void deleteSegment(String segmentApiName)

#### Parameters

segmentApiName

Type: String

API name of the segment.

#### Return Value

Type: Void

### executePublishAdhoc(segmentId)

Publish a segment.

#### API Version

56.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentActionOutput executePublishAdhoc(String segmentId)

#### Parameters

segmentId

Type: String

ID of the segment to publish.

#### Return Value

Type: [ConnectApi.CdpSegmentActionOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_action_output.htm "Segment action.")

### getSegment(segmentApiName)

Get a segment by API name.

#### API Version

56.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentContainerOutput getSegment(String segmentApiName)

#### Parameters

segmentApiName

Type: String

API name of the segment.

#### Return Value

Type: [ConnectApi.CdpSegmentContainerOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_container_output.htm "Segment container.")

### getSegmentById(segmentId)

Get a segment by ID.

#### API Version

65.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentContainerOutput getSegmentById(String segmentId)

#### Parameters

segmentId

Type: String

ID of the segment.

#### Return Value

Type: [ConnectApi.CdpSegmentContainerOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_container_output.htm "Segment container.")

### getSegments()

Get segments.

#### API Version

55.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentContainerOutput getSegments()

#### Return Value

Type: [ConnectApi.CdpSegmentContainerOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_container_output.htm "Segment container.")

### getSegmentsPaginated(batchSize, offset, orderBy)

Get an ordered batch of paginated segments.

#### API Version

56.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentContainerOutput getSegmentsPaginated(Integer batchSize, Integer offset, String orderBy)

#### Parameters

batchSize

Type: Integer

Number of segments to return at one time. Values are from 1 through 200. For example, specify 20 to return 20 segments.

offset

Type: Integer

Number of segments to skip before returning results. Specify 0 to skip no segments.

orderBy

Type: String

Sort order for the result set. Specify a field value followed by an optional sort order, ASC or DESC. For example, Name ASC sorts results by Name in ascending order, and MarketSegmentType DESC sorts results by MarketSegmentType in descending order. Omit ASC and DESC to return results in ascending order by default.

#### Return Value

Type: [ConnectApi.CdpSegmentContainerOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_container_output.htm "Segment container.")

### getSegmentsPaginated(batchSize, offset, orderBy, dataspace)

Get an ordered batch of paginated segments in a dataspace.

#### API Version

58.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentContainerOutput getSegmentsPaginated(Integer batchSize, Integer offset, String orderBy, String dataspace)

#### Parameters

batchSize

Type: Integer

Number of segments to return at one time. Values are from 1 through 200. For example, specify 20 to return 20 segments.

offset

Type: Integer

Number of segments to skip before returning results. Specify 0 to skip no segments.

orderBy

Type: String

Sort order for the result set. Specify a field value followed by an optional sort order, ASC or DESC. For example, Name ASC sorts results by Name in ascending order, and MarketSegmentType DESC sorts results by MarketSegmentType in descending order. Omit ASC and DESC to return results in ascending order by default.

dataspace

Type: String

Name of the dataspace in which to perform the action. The user must have permission to the specified dataspace. Specify default to use the default dataspace.

#### Return Value

Type: [ConnectApi.CdpSegmentContainerOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_container_output.htm "Segment container.")

### getSegmentsFilteredPaginated(batchSize, offset, orderBy, filters)

Get an ordered and filtered batch of paginated segments.

#### API Version

65.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentContainerOutput getSegmentsFilteredPaginated(Integer batchSize, Integer offset, String orderBy, String filters)

#### Parameters

**batchSize**

Type: Integer

Number of segments to return at one time. Values are from 1 through 200. For example, specify 20 to return 20 segments.

**offset**

Type: Integer

Number of segments to skip before returning results. Specify 0 to skip no segments.

**orderBy**

Type: String

Sort order for the result set. Specify a field value followed by an optional sort order, ASC or DESC. For example, Name ASC sorts results by Name in ascending order, and MarketSegmentType DESC sorts results by MarketSegmentType in descending order. Omit ASC and DESC to return results in ascending order by default.

**filters**

Type: String

Filter the result set to a more narrow scope based on segment attributes. Specify a maximum of 10 filters. Separate each filter by an AND logical operator.

These values are supported:

- LastPublishedEndDateTime - Not present in the output type. Indicates the end date and time when the segment was last published. Use only the != operator with this value.
- MarketSegmentType - Matches field segmentType.
- Name - Matches field disaplyName.
- SegmentOn - Matches field segmentOnApiName.
- SegmentStatus - Matches field segmentStatus.

These operators are supported:

- contains - Search operator for identifying strings or substrings within a field.
- eq - Equality operator for identifying values that match exactly.
- in - Comparison operator for determining whether a field matches one or more specified values.
- != - Inequality operator for determining values that don't match.

These are examples of filter parameter specifications:

- Name != NULL AND Name In Seg 01,seg 02 AND Name contains seg AND Name eq seg 01
- SegmentStatus != NULL AND SegmentStatus In Processing,Active AND SegmentStatus contains ive AND SegmentStatus eq active
- MarketSegmentType != NULL AND MarketSegmentType In UI,Dbt AND MarketSegmentType contains i AND MarketSegmentType eq UI
- SegmentOn != NULL AND SegmentOn In individual,account AND SegmentOn contains ual AND SegmentOn eq Account
- SegmentOn != NULL AND SegmentOn In individual,account AND SegmentOn contains nt AND SegmentOn eq Account
- LastPublishedEndDateTime != NULL

#### Return Value

Type: [ConnectApi.CdpSegmentContainerOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_container_output.htm "Segment container.")

### getSegmentsFilteredPaginated(batchSize, offset, orderBy, dataspace, filters)

Get an ordered and filtered batch of paginated segments in a dataspace.

#### API Version

65.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentContainerOutput getSegmentsFilteredPaginated(Integer batchSize, Integer offset, String orderBy, String dataspace, String filters)

#### Parameters

batchSize

Type: Integer

Number of segments to return at one time. Values are from 1 through 200. For example, specify 20 to return 20 segments.

offset

Type: Integer

Number of segments to skip before returning results. Specify 0 to skip no segments.

orderBy

Type: String

Sort order for the result set. Specify a field value followed by an optional sort order, ASC or DESC. For example, Name ASC sorts results by Name in ascending order, and MarketSegmentType DESC sorts results by MarketSegmentType in descending order. Omit ASC and DESC to return results in ascending order by default.

dataspace

Type: String

Name of the dataspace in which to perform the action. The user must have permission to the specified dataspace. Specify default to use the default dataspace.

filters

Type: String

Filter the result set to a more narrow scope based on segment attributes. Specify a maximum of 10 filters. Separate each filter by an AND logical operator.

These values are supported:

- LastPublishedEndDateTime - Not present in the output type. Indicates the end date and time when the segment was last published. Use only the != operator with this value.
- MarketSegmentType - Matches field segmentType.
- Name - Matches field disaplyName.
- SegmentOn - Matches field segmentOnApiName.
- SegmentStatus - Matches field segmentStatus.

These operators are supported:

- contains - Search operator for identifying strings or substrings within a field.
- eq - Equality operator for identifying values that match exactly.
- in - Comparison operator for determining whether a field matches one or more specified values.
- != - Inequality operator for determining values that don't match.

These are examples of filter parameter specifications:

- Name != NULL AND Name In Seg 01,seg 02 AND Name contains seg AND Name eq seg 01
- SegmentStatus != NULL AND SegmentStatus In Processing,Active AND SegmentStatus contains ive AND SegmentStatus eq active
- MarketSegmentType != NULL AND MarketSegmentType In UI,Dbt AND MarketSegmentType contains i AND MarketSegmentType eq UI
- SegmentOn != NULL AND SegmentOn In individual,account AND SegmentOn contains ual AND SegmentOn eq Account
- SegmentOn != NULL AND SegmentOn In individual,account AND SegmentOn contains nt AND SegmentOn eq Account
- LastPublishedEndDateTime != NULL

#### Return Value

Type: [ConnectApi.CdpSegmentContainerOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_container_output.htm "Segment container.")

### updateSegment(segmentApiName, input)

Update a segment.

#### API Version

56.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CdpSegmentOutput updateSegment(String segmentApiName, ConnectApi.CdpSegmentInput input)

#### Parameters

segmentApiName

Type: String

API name of the segment.

input

Type: [ConnectApi.CdpSegmentInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cdp_segment.htm "Segment input.")

A ConnectApi.CdpSegmentInput class with the updates.

#### Return Value

Type: [ConnectApi.CdpSegmentOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cdp_segment_output.htm "Segment.")