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

# Update phone number

> Updates a phone number's details.



## OpenAPI

````yaml PATCH /phone_numbers/{id}
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /phone_numbers/{id}:
    patch:
      tags:
        - Phone numbers
      summary: Update a phone number
      description: Updates a phone number's details.
      operationId: UpdatePhoneNumber
      parameters:
        - in: path
          name: id
          required: true
          schema:
            description: The ID of the phone number to update.
            example: pn_01jsjwe4d9fx3tpymgtg958d9w
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PhoneNumberUpdateParams'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneNumber'
          description: Updated phone number
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Surge from '@surgeapi/node';


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


            const phoneNumber = await
            client.phoneNumbers.update('pn_01jsjwe4d9fx3tpymgtg958d9w');


            console.log(phoneNumber.id);
        - lang: Python
          source: |-
            import os
            from surge import Surge

            client = Surge(
                api_key=os.environ.get("SURGE_API_KEY"),  # This is the default and can be omitted
            )
            phone_number = client.phone_numbers.update(
                id="pn_01jsjwe4d9fx3tpymgtg958d9w",
            )
            print(phone_number.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/surge-go\"\n\t\"github.com/stainless-sdks/surge-go/option\"\n)\n\nfunc main() {\n\tclient := surge.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tphoneNumber, err := client.PhoneNumbers.Update(\n\t\tcontext.TODO(),\n\t\t\"pn_01jsjwe4d9fx3tpymgtg958d9w\",\n\t\tsurge.PhoneNumberUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", phoneNumber.ID)\n}\n"
        - lang: Ruby
          source: >-
            require "surge_api"


            surge = SurgeAPI::Client.new(api_key: "My API Key")


            phone_number =
            surge.phone_numbers.update("pn_01jsjwe4d9fx3tpymgtg958d9w")


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


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


            use Surge\Client;

            use Surge\Core\Exceptions\APIException;


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


            try {
              $phoneNumber = $client->phoneNumbers->update(
                'pn_01jsjwe4d9fx3tpymgtg958d9w',
                campaignID: 'cpn_01jjnn7s0zfx5tdcsxjfy93et2',
                name: 'Letty\'s Main Line',
              );

              var_dump($phoneNumber);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    PhoneNumberUpdateParams:
      description: Updates a phone number's details.
      example:
        campaign_id: cpn_01jjnn7s0zfx5tdcsxjfy93et2
        name: Letty's Main Line
      properties:
        campaign_id:
          description: Campaign ID to attach this number to (`cpn_...`).
          example: cpn_01jjnn7s0zfx5tdcsxjfy93et2
          type: string
        name:
          description: A human-readable name for the phone number.
          example: Letty's Main Line
          type: string
      required: []
      title: PhoneNumberUpdateParams
      type: object
    PhoneNumber:
      description: A phone number that can be used to send and receive messages and calls
      example:
        campaign_id: cpn_01jjnn7s0zfx5tdcsxjfy93et2
        id: pn_01jsjwe4d9fx3tpymgtg958d9w
        name: (801) 555-1234
        number: '+18015551234'
        type: local
      properties:
        campaign_id:
          description: >-
            The unique identifier of the campaign this phone number is attached
            to, if any
          type:
            - string
            - 'null'
        id:
          description: Unique identifier for the phone number
          type: string
        name:
          description: A human-readable name for the phone number
          type:
            - string
            - 'null'
        number:
          description: The phone number in E.164 format
          example: '+18015551234'
          format: phone-number
          pattern: ^\+[1-9]\d{6,14}$
          type: string
        type:
          description: Whether the phone number is local, toll-free, or short code
          enum:
            - local
            - short_code
            - toll_free
          type: string
      required:
        - id
        - name
        - number
        - type
        - campaign_id
      title: PhoneNumber
      type: object
    ErrorResponse:
      description: An error response
      example:
        error:
          message: The requested resource could not be found.
          type: not_found
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      title: ErrorResponse
      type: object
    Error:
      description: An error response
      example:
        message: The requested resource was not found.
        type: not_found
      properties:
        detail:
          additionalProperties: true
          description: Additional details about the error.
          type: object
        message:
          description: A human-readable error message.
          example: The requested resource was not found.
          type: string
        type:
          description: A unique error code.
          example: not_found
          type: string
      required:
        - type
        - message
      title: Error
      type: object
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````