> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/users/module-4/segments.md).

# Segments

Customer segmentation utilities

## List available segments for user

> Returns segments available to the authenticated user based on\
> segmentation rules.

```json
{"openapi":"3.1.0","info":{"title":"Users API - Loyalty, Permissions, Segments, and Cards","version":"4.0.0"},"tags":[{"name":"Segments","description":"Customer segmentation utilities"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"security":[{"SessionCookie":[]}],"components":{"securitySchemes":{"SessionCookie":{"type":"apiKey","in":"header","name":"Cookie","description":"Session cookie (e.g., `sessionid=abc123`)"}},"parameters":{"SessionCookieHeader":{"name":"Cookie","in":"header","required":true,"description":"Session cookie header (e.g. `sessionid=abc123`)","schema":{"type":"string"}}},"schemas":{"SegmentSummary":{"type":"object","required":["pk","name","priority"],"properties":{"pk":{"type":"integer"},"name":{"type":"string"},"priority":{"type":"integer"}}}}},"paths":{"/users/segments/":{"get":{"tags":["Segments"],"operationId":"listSegments","summary":"List available segments for user","parameters":[{"$ref":"#/components/parameters/SessionCookieHeader"}],"description":"Returns segments available to the authenticated user based on\nsegmentation rules.","responses":{"200":{"description":"Available segments","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SegmentSummary"}}}}},"401":{"description":"Authentication required"}}}}}}
```

## POST /users/segments/{segment\_id}/set/

> Assign segment

```json
{"openapi":"3.1.0","info":{"title":"Users API - Loyalty, Permissions, Segments, and Cards","version":"4.0.0"},"tags":[{"name":"Segments","description":"Customer segmentation utilities"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"security":[{"SessionCookie":[]}],"components":{"securitySchemes":{"SessionCookie":{"type":"apiKey","in":"header","name":"Cookie","description":"Session cookie (e.g., `sessionid=abc123`)"}},"parameters":{"SessionCookieHeader":{"name":"Cookie","in":"header","required":true,"description":"Session cookie header (e.g. `sessionid=abc123`)","schema":{"type":"string"}},"CSRFTokenHeader":{"name":"X-CSRFToken","in":"header","required":true,"description":"CSRF token header for unsafe methods (POST/PUT/PATCH/DELETE)","schema":{"type":"string"}}},"schemas":{"SegmentCurrent":{"type":"object","required":["pk","name","priority"],"properties":{"pk":{"type":"integer"},"name":{"type":"string"},"priority":{"type":"integer"},"price_list":{"type":["integer","null"]}}}}},"paths":{"/users/segments/{segment_id}/set/":{"post":{"tags":["Segments"],"operationId":"setSegment","summary":"Assign segment","parameters":[{"$ref":"#/components/parameters/SessionCookieHeader"},{"$ref":"#/components/parameters/CSRFTokenHeader"},{"in":"path","name":"segment_id","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Segment assigned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentCurrent"}}}},"401":{"description":"Authentication required"},"404":{"description":"Segment not found"}}}}}}
```

## Recalculate segment (idempotent)

> Re-evaluates segmentation rules and assigns the best matching segment.\
> This action is available without authentication.

```json
{"openapi":"3.1.0","info":{"title":"Users API - Loyalty, Permissions, Segments, and Cards","version":"4.0.0"},"tags":[{"name":"Segments","description":"Customer segmentation utilities"}],"servers":[{"description":"Default commerce site","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce storefront hostname"}}}],"paths":{"/users/segments/recalculate_segment/":{"post":{"tags":["Segments"],"operationId":"recalculateSegment","summary":"Recalculate segment (idempotent)","description":"Re-evaluates segmentation rules and assigns the best matching segment.\nThis action is available without authentication.","responses":{"200":{"description":"Segment recalculated","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}}}}}
```


---

# 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://apidocs.akinon.com/commerce-openapis/users/module-4/segments.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.
