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

# List opt-outs

> Retrieve a list of opt-out blocks.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/messaging/optouts.yml get /messaging_optouts
openapi: 3.1.0
info:
  title: Telnyx Messaging Opt-outs API
  version: 2.0.0
  description: API for messaging opt-outs.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /messaging_optouts:
    get:
      tags:
        - Opt-Out Management
      summary: List opt-outs
      description: Retrieve a list of opt-out blocks.
      operationId: ListOptOuts
      parameters:
        - name: redaction_enabled
          in: query
          description: >-
            If receiving address (+E.164 formatted phone number) should be
            redacted
          required: false
          example: +447766****
          schema:
            type: string
            x-format: boolean
        - name: filter
          in: query
          style: deepObject
          explode: true
          description: >-
            Consolidated filter parameter (deepObject style). Originally:
            filter[messaging_profile_id], filter[from]
          schema:
            type: object
            properties:
              messaging_profile_id:
                type: string
                description: The ID of the messaging profile to retrieve opt-outs for
              from:
                type: string
                description: >-
                  The sending address (+E.164 formatted phone number,
                  alphanumeric sender ID, or short code) to retrieve opt-outs
                  for
        - $ref: '#/components/parameters/PageConsolidated'
        - name: created_at
          in: query
          style: deepObject
          explode: true
          description: >-
            Consolidated created_at parameter (deepObject style). Originally:
            created_at[gte], created_at[lte]
          schema:
            type: object
            properties:
              gte:
                type: string
                format: date-time
                description: Filter opt-outs created after this date (ISO-8601 format)
              lte:
                type: string
                format: date-time
                description: Filter opt-outs created before this date (ISO-8601 format)
      responses:
        '200':
          description: Successful response with opt-out list data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OptOutListResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/messaging_Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/messaging_Error'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            // Automatically fetches more pages as needed.

            for await (const messagingOptoutListResponse of
            client.messagingOptouts.list()) {
              console.log(messagingOptoutListResponse.messaging_profile_id);
            }
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            page = client.messaging_optouts.list()
            page = page.data[0]
            print(page.messaging_profile_id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.MessagingOptouts.List(context.TODO(), telnyx.MessagingOptoutListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.messagingoptouts.MessagingOptoutListPage;

            import
            com.telnyx.sdk.models.messagingoptouts.MessagingOptoutListParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    MessagingOptoutListPage page = client.messagingOptouts().list();
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            page = telnyx.messaging_optouts.list

            puts(page)
        - lang: CLI
          source: |-
            telnyx messaging-optouts list \
              --api-key 'My API Key'
components:
  parameters:
    PageConsolidated:
      name: page
      in: query
      style: deepObject
      explode: true
      description: >-
        Consolidated page parameter (deepObject style). Originally:
        page[number], page[size]
      schema:
        type: object
        properties:
          number:
            type: integer
            minimum: 1
            default: 1
            description: The page number to load
          size:
            type: integer
            minimum: 1
            maximum: 250
            default: 20
            description: The size of the page
  schemas:
    OptOutListResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/OptOutItem'
        meta:
          $ref: '#/components/schemas/messaging_PaginationMeta'
    messaging_Error:
      required:
        - code
        - title
      properties:
        code:
          type: string
          x-format: integer
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
              format: json-pointer
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
    OptOutItem:
      type: object
      properties:
        from:
          type: string
          description: >-
            Sending address (+E.164 formatted phone number, alphanumeric sender
            ID, or short code).
          x-format: address
        to:
          $ref: '#/components/schemas/ToNumber'
        messaging_profile_id:
          type:
            - string
            - 'null'
          description: Unique identifier for a messaging profile.
        keyword:
          type:
            - string
            - 'null'
          description: The keyword that triggered the opt-out.
          example: STOP
        created_at:
          type: string
          format: date-time
          description: The timestamp when the opt-out was created
          example: '2025-04-28 12:00:38.631252+00:00'
    messaging_PaginationMeta:
      type: object
      required:
        - total_pages
        - total_results
        - page_size
        - page_number
      properties:
        total_pages:
          type: integer
          example: 3
        total_results:
          type: integer
          example: 55
        page_number:
          type: integer
          example: 2
        page_size:
          type: integer
          example: 25
    ToNumber:
      type: string
      description: Receiving address (+E.164 formatted phone number or short code).
      example: +E.164
      x-format: address
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````