# 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.akinon.com/commerce-openapis/users/module-4/segments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
