> ## 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.

# Update short code

> Update the settings for a specific short code. To unbind a short code from a profile, set the `messaging_profile_id` to `null` or an empty string.
To add or update tags, include the tags field as an array of strings.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/messaging/short-codes.yml patch /short_codes/{id}
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/{id}:
    patch:
      tags:
        - Short Codes
      summary: Update short code
      description: >-
        Update the settings for a specific short code. To unbind a short code
        from a profile, set the `messaging_profile_id` to `null` or an empty
        string.

        To add or update tags, include the tags field as an array of strings.
      operationId: UpdateShortCode
      parameters:
        - $ref: '#/components/parameters/ShortCodeId'
      requestBody:
        description: Short code update
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateShortCodeRequest'
      responses:
        '200':
          $ref: '#/components/responses/ShortCodeResponse'
        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
            });


            const shortCode = await
            client.shortCodes.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
              messaging_profile_id: 'abc85f64-5717-4562-b3fc-2c9600000000',
            });


            console.log(shortCode.data);
        - 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
            )
            short_code = client.short_codes.update(
                id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                messaging_profile_id="abc85f64-5717-4562-b3fc-2c9600000000",
            )
            print(short_code.data)
        - 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\tshortCode, err := client.ShortCodes.Update(\n\t\tcontext.TODO(),\n\t\t\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n\t\ttelnyx.ShortCodeUpdateParams{\n\t\t\tMessagingProfileID: \"abc85f64-5717-4562-b3fc-2c9600000000\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", shortCode.Data)\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.ShortCodeUpdateParams;
            import com.telnyx.sdk.models.shortcodes.ShortCodeUpdateResponse;

            public final class Main {
                private Main() {}

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

                    ShortCodeUpdateParams params = ShortCodeUpdateParams.builder()
                        .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
                        .messagingProfileId("abc85f64-5717-4562-b3fc-2c9600000000")
                        .build();
                    ShortCodeUpdateResponse shortCode = client.shortCodes().update(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            short_code = telnyx.short_codes.update(
              "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
              messaging_profile_id: "abc85f64-5717-4562-b3fc-2c9600000000"
            )

            puts(short_code)
        - 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 {
              $shortCode = $client->shortCodes->update(
                '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
                messagingProfileID: 'abc85f64-5717-4562-b3fc-2c9600000000',
                tags: ['test_customer'],
              );

              var_dump($shortCode);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx short-codes update \
              --api-key 'My API Key' \
              --id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
              --messaging-profile-id abc85f64-5717-4562-b3fc-2c9600000000
components:
  parameters:
    ShortCodeId:
      name: id
      in: path
      description: The id of the short code
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    UpdateShortCodeRequest:
      type: object
      required:
        - messaging_profile_id
      properties:
        messaging_profile_id:
          type: string
          description: Unique identifier for a messaging profile.
        tags:
          type:
            - array
          items:
            type: string
      example:
        messaging_profile_id: abc85f64-5717-4562-b3fc-2c9600000000
        tags:
          - test_customer
    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_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
  responses:
    ShortCodeResponse:
      description: Successful response with details about a short code.
      content:
        application/json:
          schema:
            type: object
            title: Short Code Response
            properties:
              data:
                $ref: '#/components/schemas/ShortCode'
    messaging_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/messaging_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````