> For the complete documentation index, see [llms.txt](https://docs.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mediarithmics.io/api-reference/userpoint/userpoint-segment.md).

# Userpoint Segment

Operations related to **UserPoint Segments**, the membership records indicating a UserPoint belongs to an audience segment. Each UserSegment contains segment\_id, creation date, and optional expiration (TTL):

* **User Query** - OTQL-based rules
* **User List** - Static imports
* **User Lookalike** - ML-generated expansion of seed segments
* **User Activation** - Campaign interaction tracking
* **Edge Segment** - Client-side evaluation in browser
* **Scenario-generated** - Automation workflow outputs

UserSegments persist independently from segment counting and enable activation through feeds to external platforms.

Relevant documentation:

* [UserSegment](https://developer.mediarithmics.io/user-points/segments)
* [Audience segments](https://userguides.mediarithmics.io/audience/segments)

## PUT /datamarts/{datamart\_id}/user\_points/{user\_identifier}/user\_segments/audience\_segment\_id={segment\_id}

> Upsert user segment

```json
{"openapi":"3.1.1","info":{"title":"mediarithmics openapi API","version":"1.0.0"},"tags":[{"name":"Userpoint Segment","description":"Operations related to **UserPoint Segments**, the membership records indicating a UserPoint belongs to an audience segment. Each UserSegment contains segment_id, creation date, and optional expiration (TTL):\n- **User Query** - OTQL-based rules \n- **User List** - Static imports\n- **User Lookalike** - ML-generated expansion of seed segments\n- **User Activation** - Campaign interaction tracking\n- **Edge Segment** - Client-side evaluation in browser\n- **Scenario-generated** - Automation workflow outputs\n\nUserSegments persist independently from segment counting and enable activation through feeds to external platforms.\n\nRelevant documentation:\n- [UserSegment](https://developer.mediarithmics.io/user-points/segments)\n- [Audience segments](https://userguides.mediarithmics.io/audience/segments)\n"}],"servers":[{"url":"http://api.mediarithmics.local/v1","description":"Development server"},{"url":"https://api.mediarithmics.com/v1","description":"Production server"}],"paths":{"/datamarts/{datamart_id}/user_points/{user_identifier}/user_segments/audience_segment_id={segment_id}":{"put":{"responses":{"200":{"description":"Success !","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"status":{"type":"string","enum":["ok"]},"data":{"$ref":"#/components/schemas/UserSegmentResource"}},"required":["data","status"]},{"type":"object","properties":{"status":{"type":"string","enum":["ok"]}},"required":["status"]}]}}}},"400":{"$ref":"#/components/responses/error"},"401":{"$ref":"#/components/responses/error"},"403":{"$ref":"#/components/responses/error"},"404":{"$ref":"#/components/responses/error"},"500":{"$ref":"#/components/responses/error"},"503":{"$ref":"#/components/responses/error"}},"parameters":[{"required":true,"explode":false,"in":"path","schema":{"type":"string"},"name":"datamart_id","style":"simple"},{"style":"simple","required":true,"name":"user_identifier","in":"path","explode":false,"schema":{"$ref":"#/components/schemas/PublicUserIdentifiers"}},{"in":"path","style":"simple","schema":{"type":"integer","format":"int64"},"explode":false,"required":true,"name":"segment_id"},{"required":false,"style":"form","explode":true,"schema":{"type":"boolean"},"name":"async","in":"query"}],"description":"","operationId":"upsertUserSegment","tags":["Userpoint Segment"],"requestBody":{"description":"The object of the request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserSegmentUpdateResource"}}},"required":true},"summary":"Upsert user segment"}}},"components":{"schemas":{"UserSegmentResource":{"type":"object","properties":{"data_bag":{"type":"string","readOnly":false},"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"segment_id":{"type":"string","readOnly":false},"last_modified_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false}},"required":["data_bag","segment_id"]},"errorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["error"]},"error_code":{"type":"string","enum":["AUTHENTICATION_ERROR","AUTHORIZATION_ERROR","BAD_REQUEST_DATA","BAD_REQUEST_FORMAT","CONSTRAINT_VIOLATION_EXCEPTION","EMAIL_ALREADY_EXISTS","MAC_ERROR","RESOURCE_NOT_FOUND","SERVICE_UNAVAILABLE","TOKEN_ERROR"]},"error_id":{"type":"string"},"error":{"type":"string"}},"required":["error","error_code","error_id","status"]},"PublicUserIdentifiers":{"type":"string","description":"User identifier in one of the following format : - a UUID (a.k.a userpoint id) - user_point_id=xxx where xxx is a UUID - compartment_id=xxx,user_account_id=yyy - user_agent_id=xxx - email_hash=xxx ","pattern":"^([0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}|user_point_id=[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}|compartment_id=\\d+,user_account_id=\\S+|user_account_id=\\S+(,compartment_id=\\d+)?|user_agent_id=\\S+|email_hash=\\S+)$"},"UserSegmentUpdateResource":{"type":"object","properties":{"expiration":{"type":"integer","format":"int32","default":0,"readOnly":false},"data_bag":{"type":"string","readOnly":false}},"required":["data_bag"]}},"responses":{"error":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorResponse"}}}}}}}
```

## DELETE /datamarts/{datamart\_id}/user\_points/{user\_identifier}/user\_segments/audience\_segment\_id={segment\_id}

> Delete user segment

```json
{"openapi":"3.1.1","info":{"title":"mediarithmics openapi API","version":"1.0.0"},"tags":[{"name":"Userpoint Segment","description":"Operations related to **UserPoint Segments**, the membership records indicating a UserPoint belongs to an audience segment. Each UserSegment contains segment_id, creation date, and optional expiration (TTL):\n- **User Query** - OTQL-based rules \n- **User List** - Static imports\n- **User Lookalike** - ML-generated expansion of seed segments\n- **User Activation** - Campaign interaction tracking\n- **Edge Segment** - Client-side evaluation in browser\n- **Scenario-generated** - Automation workflow outputs\n\nUserSegments persist independently from segment counting and enable activation through feeds to external platforms.\n\nRelevant documentation:\n- [UserSegment](https://developer.mediarithmics.io/user-points/segments)\n- [Audience segments](https://userguides.mediarithmics.io/audience/segments)\n"}],"servers":[{"url":"http://api.mediarithmics.local/v1","description":"Development server"},{"url":"https://api.mediarithmics.com/v1","description":"Production server"}],"paths":{"/datamarts/{datamart_id}/user_points/{user_identifier}/user_segments/audience_segment_id={segment_id}":{"delete":{"description":"","summary":"Delete user segment","responses":{"200":{"$ref":"#/components/responses/simple"},"400":{"$ref":"#/components/responses/error"},"401":{"$ref":"#/components/responses/error"},"403":{"$ref":"#/components/responses/error"},"404":{"$ref":"#/components/responses/error"},"500":{"$ref":"#/components/responses/error"},"503":{"$ref":"#/components/responses/error"}},"tags":["Userpoint Segment"],"operationId":"deleteUserSegment","parameters":[{"required":true,"style":"simple","name":"datamart_id","schema":{"type":"string"},"in":"path","explode":false},{"explode":false,"required":true,"schema":{"$ref":"#/components/schemas/PublicUserIdentifiers"},"in":"path","name":"user_identifier","style":"simple"},{"schema":{"type":"integer","format":"int64"},"in":"path","style":"simple","required":true,"explode":false,"name":"segment_id"},{"in":"query","schema":{"type":"boolean"},"name":"async","required":false,"explode":true,"style":"form"}]}}},"components":{"responses":{"simple":{"description":"Success response","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok"]}},"required":["status"]}}}},"error":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorResponse"}}}}},"schemas":{"errorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["error"]},"error_code":{"type":"string","enum":["AUTHENTICATION_ERROR","AUTHORIZATION_ERROR","BAD_REQUEST_DATA","BAD_REQUEST_FORMAT","CONSTRAINT_VIOLATION_EXCEPTION","EMAIL_ALREADY_EXISTS","MAC_ERROR","RESOURCE_NOT_FOUND","SERVICE_UNAVAILABLE","TOKEN_ERROR"]},"error_id":{"type":"string"},"error":{"type":"string"}},"required":["error","error_code","error_id","status"]},"PublicUserIdentifiers":{"type":"string","description":"User identifier in one of the following format : - a UUID (a.k.a userpoint id) - user_point_id=xxx where xxx is a UUID - compartment_id=xxx,user_account_id=yyy - user_agent_id=xxx - email_hash=xxx ","pattern":"^([0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}|user_point_id=[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}|compartment_id=\\d+,user_account_id=\\S+|user_account_id=\\S+(,compartment_id=\\d+)?|user_agent_id=\\S+|email_hash=\\S+)$"}}}}
```

## POST /datamarts/{datamart\_id}/external\_user\_segment\_feed\_events

> Trigger external user segment feed events

```json
{"openapi":"3.1.1","info":{"title":"mediarithmics openapi API","version":"1.0.0"},"tags":[{"name":"Userpoint Segment","description":"Operations related to **UserPoint Segments**, the membership records indicating a UserPoint belongs to an audience segment. Each UserSegment contains segment_id, creation date, and optional expiration (TTL):\n- **User Query** - OTQL-based rules \n- **User List** - Static imports\n- **User Lookalike** - ML-generated expansion of seed segments\n- **User Activation** - Campaign interaction tracking\n- **Edge Segment** - Client-side evaluation in browser\n- **Scenario-generated** - Automation workflow outputs\n\nUserSegments persist independently from segment counting and enable activation through feeds to external platforms.\n\nRelevant documentation:\n- [UserSegment](https://developer.mediarithmics.io/user-points/segments)\n- [Audience segments](https://userguides.mediarithmics.io/audience/segments)\n"}],"servers":[{"url":"http://api.mediarithmics.local/v1","description":"Development server"},{"url":"https://api.mediarithmics.com/v1","description":"Production server"}],"paths":{"/datamarts/{datamart_id}/external_user_segment_feed_events":{"post":{"requestBody":{"description":"The object of the request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExternalUserSegmentFeedEventResource"}}},"required":true},"description":"","tags":["Userpoint Segment"],"summary":"Trigger external user segment feed events","responses":{"200":{"description":"Success !","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok"]},"data":{"$ref":"#/components/schemas/ExternalUserSegmentFeedEventResource"}},"required":["data","status"]}}}},"400":{"$ref":"#/components/responses/error"},"401":{"$ref":"#/components/responses/error"},"403":{"$ref":"#/components/responses/error"},"404":{"$ref":"#/components/responses/error"},"500":{"$ref":"#/components/responses/error"},"503":{"$ref":"#/components/responses/error"}},"operationId":"publishExternalUserSegmentFeedEvents","parameters":[{"name":"datamart_id","style":"simple","schema":{"type":"string"},"required":true,"explode":false,"in":"path"}]}}},"components":{"schemas":{"ExternalUserSegmentFeedEventResource":{"discriminator":{"propertyName":"type","mapping":{"external_upsert_event":"#/components/schemas/UserSegmentFeedLiveUpsertEventResource","external_delete_event":"#/components/schemas/UserSegmentFeedLiveDeleteEventResource"}},"oneOf":[{"$ref":"#/components/schemas/UserSegmentFeedLiveUpsertEventResource"},{"$ref":"#/components/schemas/UserSegmentFeedLiveDeleteEventResource"}],"properties":{"type":{"type":"string","enum":["external_upsert_event","external_delete_event"]}},"required":["type"]},"UserSegmentFeedLiveUpsertEventResource":{"type":"object","properties":{"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"session_id":{"type":"string","readOnly":false},"profiles":{"type":"array","items":{"type":"string","readOnly":false},"readOnly":false},"identifiers":{"type":"array","items":{"$ref":"#/components/schemas/UserIdentifierInfo"},"readOnly":false},"datamart_id":{"type":"string","readOnly":false},"segment_id":{"type":"string","readOnly":false}},"required":["datamart_id","identifiers","profiles","segment_id","session_id"]},"UserIdentifierInfo":{"discriminator":{"propertyName":"type","mapping":{"USER_AGENT":"#/components/schemas/UserAgentIdentifierInfo","USER_DEVICE_POINT":"#/components/schemas/UserDevicePointIdentifierInfo","USER_EMAIL":"#/components/schemas/UserEmailIdentifierInfo","USER_POINT":"#/components/schemas/UserPointIdentifierInfo","USER_ACCOUNT":"#/components/schemas/UserAccountIdentifierInfo"}},"oneOf":[{"$ref":"#/components/schemas/UserDevicePointIdentifierInfo"},{"$ref":"#/components/schemas/UserPointIdentifierInfo"},{"$ref":"#/components/schemas/UserAgentIdentifierInfo"},{"$ref":"#/components/schemas/UserEmailIdentifierInfo"},{"$ref":"#/components/schemas/UserAccountIdentifierInfo"}],"properties":{"type":{"type":"string","enum":["USER_DEVICE_POINT","USER_POINT","USER_AGENT","USER_EMAIL","USER_ACCOUNT"]}},"required":["type"]},"UserDevicePointIdentifierInfo":{"type":"object","properties":{"technical_identifiers":{"type":"array","items":{"$ref":"#/components/schemas/UserDeviceTechnicalIdentifierInfo"},"readOnly":false},"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"device":{"$ref":"#/components/schemas/UserAgentInfo"},"id":{"$ref":"#/components/schemas/VectorId"},"last_activity_ts":{"type":"integer","format":"int64","default":0,"readOnly":false}},"required":["creation_ts","last_activity_ts","technical_identifiers"]},"UserDeviceTechnicalIdentifierInfo":{"type":"object","properties":{"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"last_activity_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"user_agent_id":{"$ref":"#/components/schemas/UserAgentId"},"registry_id":{"type":"string","readOnly":false},"type":{"$ref":"#/components/schemas/DeviceIdRegistryType"}},"required":["creation_ts","last_activity_ts","registry_id","type","user_agent_id"]},"UserAgentId":{"allOf":[{"$ref":"#/components/schemas/UserIdentifier"},{"type":"object"}]},"UserIdentifier":{"type":"object"},"DeviceIdRegistryType":{"type":"string","enum":["INSTALLATION_ID","MUM_ID","NETWORK_DEVICE_ID","CUSTOM_DEVICE_ID","MOBILE_ADVERTISING_ID","MOBILE_VENDOR_ID","TV_ADVERTISING_ID","IP_V4_ADDRESS_ID","IP_V6_ADDRESS_ID"],"readOnly":false},"UserAgentInfo":{"type":"object","properties":{"carrier":{"type":"string","readOnly":false},"initial_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"browser_version":{"type":"string","readOnly":false},"model":{"type":"string","readOnly":false},"form_factor":{"$ref":"#/components/schemas/FormFactor"},"os_family":{"$ref":"#/components/schemas/OperatingSystemFamily"},"brand":{"type":"string","readOnly":false},"raw_value":{"type":"string","readOnly":false},"browser_family":{"$ref":"#/components/schemas/BrowserFamily"},"os_version":{"type":"string","readOnly":false}},"required":["form_factor","initial_ts","os_family"]},"FormFactor":{"type":"string","enum":["OTHER","PERSONAL_COMPUTER","SMART_TV","GAME_CONSOLE","SMARTPHONE","TABLET","WEARABLE_COMPUTER"],"readOnly":false},"OperatingSystemFamily":{"type":"string","enum":["OTHER","WINDOWS","MAC_OS","LINUX","ANDROID","IOS","TIZEN","WEB_OS","ANDROID_TV","GOOGLE_TV","TV_OS","FIRE_TV","ROKU_TV","TITAN_OS"],"readOnly":false},"BrowserFamily":{"type":"string","enum":["OTHER","CHROME","IE","FIREFOX","SAFARI","OPERA","STOCK_ANDROID","BOT","EMAIL_CLIENT","MICROSOFT_EDGE"],"readOnly":false},"VectorId":{"type":"string","description":"The vector id formatted as vec:id or the User device point id formatted as udp:id","pattern":"^(vec|udp):\\d+$"},"UserPointIdentifierInfo":{"type":"object","properties":{"user_point_id":{"type":"string","format":"uuid","readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false}},"required":["user_point_id"]},"UserAgentIdentifierInfo":{"type":"object","properties":{"providers":{"type":"array","items":{"$ref":"#/components/schemas/UserAgentIdentifierProviderResource"},"readOnly":false},"mappings":{"type":"array","items":{"$ref":"#/components/schemas/UserAgentIdMappingResource"},"readOnly":false},"last_activity_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"device":{"$ref":"#/components/schemas/UserAgentInfo"},"installation_ids":{"type":"array","items":{"$ref":"#/components/schemas/InstallationIdResource"},"readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"vector_id":{"$ref":"#/components/schemas/VectorId"}},"required":["creation_ts","installation_ids","last_activity_ts","mappings","providers","vector_id"]},"UserAgentIdentifierProviderResource":{"type":"object","properties":{"technical_name":{"type":"string","readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"last_activity_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false}},"required":["technical_name"]},"UserAgentIdMappingResource":{"type":"object","properties":{"user_agent_id":{"$ref":"#/components/schemas/UserAgentId"},"realm_name":{"type":"string","readOnly":false},"last_activity_ts":{"type":"integer","format":"int64","default":0,"readOnly":false}},"required":["last_activity_ts","realm_name","user_agent_id"]},"InstallationIdResource":{"type":"object","properties":{"channel_id":{"type":"string","readOnly":false},"installation_id":{"type":"string","readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"last_seen_ts":{"type":"integer","format":"int64","default":0,"readOnly":false}},"required":["channel_id","installation_id"]},"UserEmailIdentifierInfo":{"type":"object","properties":{"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"email":{"type":"string","readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"providers":{"type":"array","items":{"$ref":"#/components/schemas/UserEmailIdentifierProviderResource"},"readOnly":false},"operator":{"type":"string","readOnly":false},"last_activity_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"hash":{"type":"string","readOnly":false}},"required":["creation_ts","hash","last_activity_ts","providers"]},"UserEmailIdentifierProviderResource":{"type":"object","properties":{"last_modified_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"status":{"type":"string","readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"last_activity_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"active":{"type":"boolean","default":false,"readOnly":false},"technical_name":{"type":"string","readOnly":false}},"required":["technical_name"]},"UserAccountIdentifierInfo":{"type":"object","properties":{"user_account_id":{"type":"string","readOnly":false},"creation_ts":{"type":"integer","format":"int64","default":0,"readOnly":false},"compartment_id":{"type":"integer","default":0,"format":"int64","readOnly":false},"expiration_ts":{"type":"integer","format":"int64","default":0,"readOnly":false}},"required":["creation_ts","user_account_id"]},"UserSegmentFeedLiveDeleteEventResource":{"type":"object","properties":{"datamart_id":{"type":"string","readOnly":false},"segment_id":{"type":"string","readOnly":false},"session_id":{"type":"string","readOnly":false},"identifiers":{"type":"array","items":{"$ref":"#/components/schemas/UserIdentifierInfo"},"readOnly":false},"profiles":{"type":"array","items":{"type":"string","readOnly":false},"readOnly":false}},"required":["datamart_id","identifiers","profiles","segment_id","session_id"]},"errorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["error"]},"error_code":{"type":"string","enum":["AUTHENTICATION_ERROR","AUTHORIZATION_ERROR","BAD_REQUEST_DATA","BAD_REQUEST_FORMAT","CONSTRAINT_VIOLATION_EXCEPTION","EMAIL_ALREADY_EXISTS","MAC_ERROR","RESOURCE_NOT_FOUND","SERVICE_UNAVAILABLE","TOKEN_ERROR"]},"error_id":{"type":"string"},"error":{"type":"string"}},"required":["error","error_code","error_id","status"]}},"responses":{"error":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorResponse"}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mediarithmics.io/api-reference/userpoint/userpoint-segment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
