> ## 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 short codes



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/messaging/short-codes.yml get /short_codes
openapi: 3.1.0
info:
  title: Telnyx Short Codes API
  version: 2.0.0
  description: API for short codes.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /short_codes:
    get:
      tags:
        - Short Codes
      summary: List short codes
      operationId: ListShortCodes
      parameters:
        - name: filter
          in: query
          style: deepObject
          explode: true
          description: >-
            Consolidated filter parameter (deepObject style). Originally:
            filter[messaging_profile_id]
          schema:
            type: object
            properties:
              messaging_profile_id:
                type: string
                description: >-
                  Filter by Messaging Profile ID. Use the string `null` for
                  phone numbers without assigned profiles. A synonym for the
                  `/messaging_profiles/{id}/short_codes` endpoint when querying
                  about an extant profile.
        - $ref: '#/components/parameters/PageConsolidated'
      responses:
        '200':
          $ref: '#/components/responses/ListShortCodesResponse'
        4XX:
          $ref: '#/components/responses/messaging_GenericErrorResponse'
      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 shortCode of client.shortCodes.list()) {
              console.log(shortCode.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.short_codes.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.ShortCodes.List(context.TODO(), telnyx.ShortCodeListParams{})\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.shortcodes.ShortCodeListPage;
            import com.telnyx.sdk.models.shortcodes.ShortCodeListParams;

            public final class Main {
                private Main() {}

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

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

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

            page = telnyx.short_codes.list

            puts(page)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $page = $client->shortCodes->list(
                filter: ['messagingProfileID' => 'messaging_profile_id'],
                pageNumber: 0,
                pageSize: 0,
              );

              var_dump($page);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx short-codes 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
  responses:
    ListShortCodesResponse:
      description: Successful response with a list of short codes.
      content:
        application/json:
          schema:
            type: object
            title: List Short Codes Response
            properties:
              data:
                type: array
                items:
                  $ref: '#/components/schemas/ShortCode'
              meta:
                $ref: '#/components/schemas/messaging_PaginationMeta'
    messaging_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/messaging_Errors'
  schemas:
    ShortCode:
      type: object
      required:
        - messaging_profile_id
      example:
        record_type: short_code
        id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
        short_code: '12345'
        country_code: US
        messaging_profile_id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
        tags:
          - test_customer
        created_at: '2019-01-23T18:10:02.574Z'
        updated_at: '2019-01-23T18:10:02.574Z'
      properties:
        record_type:
          type: string
          example: short_code
          enum:
            - short_code
          description: Identifies the type of the resource.
          readOnly: true
        id:
          type: string
          format: uuid
          description: Identifies the type of resource.
          readOnly: true
        short_code:
          type: string
          description: Short digit sequence used to address messages.
          readOnly: true
        country_code:
          type: string
          description: ISO 3166-1 alpha-2 country code.
          pattern: ^[A-Z]{2}$
          example: US
          readOnly: true
        messaging_profile_id:
          type:
            - string
            - 'null'
          description: Unique identifier for a messaging profile.
        tags:
          type:
            - array
          items:
            type: string
        created_at:
          type: string
          format: date-time
          description: ISO 8601 formatted date indicating when the resource was created.
          readOnly: true
        updated_at:
          type: string
          format: date-time
          description: ISO 8601 formatted date indicating when the resource was updated.
          readOnly: true
    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
    messaging_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/messaging_Error'
    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
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````