# refreshSegment

mutation · in the family [Pricing](/reference/pricing/)

## What it does

Recompute a rule-based segment’s membership from its rule — shoppers who now match join, shoppers who no longer match leave.

Re-materialize a DYNAMIC segment's membership: a bounded probe sizes YOUR consumer universe first — at most 10,000 evaluates IN-REQUEST (the stored predicate, diffed against the member rows, adds/removes in bounded transactions, evaluatedAt stamped, refreshProblem cleared; answers queued: false + the arithmetic); past that the refresh is QUEUED (answers queued: true, arithmetic absent — the worker re-materializes up to 1,000,000 consumers; evaluatedAt moves on completion, refreshProblem words an over-cap outcome; a scheduled sweep also re-refreshes stale ACTIVE dynamics ~daily). Synchronous matches beyond the 100,000 membership cap refuse BEFORE any write; a static segment refuses (its membership moves via the member ops); legal on active AND inactive segments, never doomed. Not one atomic transaction — re-run heals an interrupted refresh. Requires the unrestricted capability. Template class (v89).

## What happens

Rewrites the membership list and stamps when it was last computed; hand-picked membership is the static kind’s job.

## Who may call it

Capability area: **Pricing** — Prices, price schedules, promotions, coupons and the money rules of selling.

- Owner
- Manager
- An API key whose scope allows `api:refreshSegment`

## Arguments

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | [ID](/types/#scalars) `ID!` | yes | The id of the record. |

## Returns

[RefreshSegmentResult](/types/RefreshSegmentResult/) `RefreshSegmentResult!` — The refreshSegment result — sync (queued: false): the re-stamped segment + the honest arithmetic; queued (queued: true): the CURRENT segment, the arithmetic honestly ABSENT (the worker re-materializes shortly — evaluatedAt moves on completion; refreshProblem words a refresh that could not complete).

## Example request

```graphql
mutation ExampleRefreshSegment($id: ID!) {
  refreshSegment(id: $id) {
    queued
    matched
    added
    removed
  }
}
```

Variables:

```json
{
  "id": "01900000-0000-7000-8000-37386ae00000"
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

## Example response

```json
{
  "data": {
    "refreshSegment": {
      "queued": true,
      "matched": 1,
      "added": 1,
      "removed": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

## Errors this call can answer

- `VALIDATION/INVALID` — Something in the request is not valid. ([VALIDATION](/errors/VALIDATION/))
- `AUTHN/REQUIRED` — Sign in to do this. ([AUTHN](/errors/AUTHN/))
- `AUTHZ/FORBIDDEN` — Your role does not allow this action. ([AUTHZ](/errors/AUTHZ/))
- `RATE_LIMIT/THROTTLED` — Too many requests in a short time. ([RATE_LIMIT](/errors/RATE_LIMIT/))
- `NOT_FOUND/*` — That record could not be found. ([NOT_FOUND](/errors/NOT_FOUND/))
- `CONFLICT/*` — The record’s state, or a change made in the meantime, does not allow this; the codes are on the CONFLICT page. ([CONFLICT](/errors/CONFLICT/))
- `VALIDATION/VERSION_REQUIRED` — The request did not say which app version it came from. ([VALIDATION](/errors/VALIDATION/))

## Used in

- [Group shoppers into segments for marketing](/use-cases/segment-your-customers/)
