> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brudcast.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a contact segment

> Changes a segment and, when `rules` is sent, replaces its rule set wholesale. The segment type cannot be changed here; use the convert endpoint for that. Requires the `contacts:write` scope.



## OpenAPI

````yaml /api-reference/openapi.json patch /api/v1/user/contact-segments/{id}
openapi: 3.0.0
info:
  title: Brudcast API
  version: 1.0.0
servers:
  - url: https://core-service.prod.brudcast.com
    description: Production
security: []
tags:
  - name: Analytics
    x-displayName: Analytics
  - name: Campaigns
    x-displayName: Campaigns
  - name: Contacts
    x-displayName: Contacts
  - name: Mailboxes
    x-displayName: Mailboxes
  - name: Messages
    x-displayName: Messages
  - name: Sender Identities
    x-displayName: Sender Identities
  - name: Sending Domains
    x-displayName: Sending Domains
  - name: Templates
    x-displayName: Templates
  - name: Webhooks
    x-displayName: Webhooks
paths:
  /api/v1/user/contact-segments/{id}:
    patch:
      tags:
        - Contacts
      summary: Update a contact segment
      description: >-
        Changes a segment and, when `rules` is sent, replaces its rule set
        wholesale. The segment type cannot be changed here; use the convert
        endpoint for that. Requires the `contacts:write` scope.
      parameters:
        - in: header
          name: X-Organization-Id
          required: false
          description: >-
            Required when authenticating with an access token. Optional with an
            API key, whose own organization binding is authoritative; a value
            contradicting it is refused with 403.
          schema:
            type: string
            format: uuid
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
                description:
                  type: string
                  maxLength: 2000
                matchMode:
                  enum:
                    - all
                    - any
                rules:
                  type: array
                  items:
                    type: object
                    properties:
                      field:
                        enum:
                          - email_status
                          - sms_status
                          - contact_status
                          - tag
                          - language
                          - timezone
                          - created_at
                          - last_activity
                      operator:
                        enum:
                          - is
                          - is_not
                          - contains
                          - not_contains
                          - starts_with
                          - ends_with
                          - is_set
                          - is_not_set
                          - before
                          - after
                          - 'on'
                          - between
                          - in_last
                      value:
                        anyOf:
                          - type: string
                          - type: number
                          - type: boolean
                          - type: array
                          - type: object
                    required:
                      - field
                      - operator
                    additionalProperties: false
              additionalProperties: false
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactSegmentDataResponse'
        '400':
          description: Another segment in the organization already holds the new name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: The credential is missing, malformed, revoked or expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            The key lacks the scope the endpoint requires, or the organization
            does not match the credential
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: No such segment in the organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: The payload or query string failed validation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '429':
          description: >-
            Rate limit exceeded; retry after the number of seconds in
            `retryAfter`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse'
      security:
        - apiKey: []
        - apiKeyBearer: []
components:
  schemas:
    ContactSegmentDataResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
        data:
          $ref: '#/components/schemas/ContactSegmentData'
      required:
        - success
        - message
        - data
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: Resource not found
        code:
          type: string
          enum:
            - E_VALIDATION_ERROR
            - E_UNAUTHORIZED_ACCESS
            - E_UNAUTHORIZED
            - E_FORBIDDEN
            - E_INSUFFICIENT_SCOPE
            - E_ROW_NOT_FOUND
            - E_TOO_MANY_REQUESTS
            - E_BUSINESS_RULE_VIOLATION
            - E_CAMPAIGN_NOT_SENDABLE
            - INSUFFICIENT_CREDITS
            - SUBSCRIPTION_REQUIRED
          example: E_ROW_NOT_FOUND
      required:
        - success
        - message
        - code
    ValidationErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: The payload is invalid
        code:
          type: string
          enum:
            - E_VALIDATION_ERROR
            - E_UNAUTHORIZED_ACCESS
            - E_UNAUTHORIZED
            - E_FORBIDDEN
            - E_INSUFFICIENT_SCOPE
            - E_ROW_NOT_FOUND
            - E_TOO_MANY_REQUESTS
            - E_BUSINESS_RULE_VIOLATION
            - E_CAMPAIGN_NOT_SENDABLE
            - INSUFFICIENT_CREDITS
            - SUBSCRIPTION_REQUIRED
          example: E_VALIDATION_ERROR
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
      required:
        - success
        - message
        - code
        - errors
    RateLimitErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: Too many requests
        code:
          type: string
          enum:
            - E_VALIDATION_ERROR
            - E_UNAUTHORIZED_ACCESS
            - E_UNAUTHORIZED
            - E_FORBIDDEN
            - E_INSUFFICIENT_SCOPE
            - E_ROW_NOT_FOUND
            - E_TOO_MANY_REQUESTS
            - E_BUSINESS_RULE_VIOLATION
            - E_CAMPAIGN_NOT_SENDABLE
            - INSUFFICIENT_CREDITS
            - SUBSCRIPTION_REQUIRED
          example: E_TOO_MANY_REQUESTS
        retryAfter:
          type: number
          example: 60
      required:
        - success
        - message
        - code
        - retryAfter
    ContactSegmentData:
      type: object
      properties:
        segment:
          $ref: '#/components/schemas/ContactSegment'
      required:
        - segment
    ValidationErrorItem:
      type: object
      properties:
        field:
          type: string
          example: emailAddress
        rule:
          type: string
          example: email
        message:
          type: string
          example: The emailAddress field must be a valid email address
      required:
        - field
        - rule
        - message
    ContactSegment:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organizationId:
          type: string
          format: uuid
        name:
          type: string
          example: Engaged subscribers
        description:
          type: string
          nullable: true
        type:
          type: string
          enum:
            - dynamic
            - static
          description: >-
            A dynamic segment is evaluated from its rules on every read; a
            static one holds a frozen membership snapshot
        matchMode:
          type: string
          enum:
            - all
            - any
          description: Whether a contact must satisfy every rule or any one of them
        contactCount:
          type: number
          description: Cached membership size, recomputed by the refresh-count endpoint
        frozenAt:
          type: string
          format: date-time
          nullable: true
          description: When the membership was frozen, set on static segments only
        sourceSegmentId:
          type: string
          format: uuid
          nullable: true
          description: The dynamic segment this one was snapshotted from, when it was
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        rules:
          type: array
          items:
            $ref: '#/components/schemas/ContactSegmentRule'
          description: Preloaded wherever a segment is returned
        sourceSegment:
          $ref: '#/components/schemas/ContactSegment'
          nullable: true
          description: >-
            Preloaded when a single segment is fetched by id, and null unless it
            was snapshotted from another segment
      required:
        - id
        - organizationId
        - name
        - description
        - type
        - matchMode
        - contactCount
        - frozenAt
        - sourceSegmentId
        - createdAt
        - updatedAt
    ContactSegmentRule:
      type: object
      properties:
        id:
          type: string
          format: uuid
        segmentId:
          type: string
          format: uuid
        field:
          type: string
          enum:
            - email_status
            - sms_status
            - contact_status
            - tag
            - language
            - timezone
            - created_at
            - last_activity
        operator:
          type: string
          enum:
            - is
            - is_not
            - contains
            - not_contains
            - starts_with
            - ends_with
            - is_set
            - is_not_set
            - before
            - after
            - 'on'
            - between
            - in_last
        value:
          description: >-
            The comparison value, shaped by the operator: a scalar for most, an
            array of bounds for `between`, and absent for `is_set` and
            `is_not_set`
        sortOrder:
          type: number
          description: Position of the rule within the segment
      required:
        - id
        - segmentId
        - field
        - operator
        - value
        - sortOrder
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        An organization API key, prefixed `bk_live_`. Takes precedence over
        `Authorization` when both are sent. The key is bound to one
        organization, and the scopes it was issued with are enforced per
        endpoint.
    apiKeyBearer:
      type: http
      scheme: bearer
      bearerFormat: bk_live_...
      description: >-
        The same organization API key sent as `Authorization: Bearer
        bk_live_...`. Accepted only when the value begins with `bk_` and no
        `X-API-Key` header is present.

````