# Create a phone Switch

`POST /phone_call_redirects`

> This is a subset of the full specification, limited to the `POST /phone_call_redirects` operation.
>
> You can find the full specification here: /_bundle/docs/references/@2.11/rest-api/api.intercom.io.yaml

```yaml
openapi: 3.0.1
info:
  title: Intercom API
  version: '2.11'
  description: This is a subset of the full specification, limited to the `POST /phone_call_redirects` operation.
  contact:
    name: Intercom Developer Hub
    url: https://developers.intercom.com
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
servers:
  - url: https://api.intercom.io
    description: The production API server
  - url: https://api.eu.intercom.io
    description: The european API server
  - url: https://api.au.intercom.io
    description: The australian API server
security:
  - bearerAuth: []
tags:
  - name: Switch
    description: Everything about Switch
    externalDocs:
      description: 'Meet Switch: from on hold to messaging in just a few taps'
      url: https://www.intercom.com/switch
paths:
  /phone_call_redirects:
    post:
      summary: Create a phone Switch
      parameters:
        - name: Intercom-Version
          in: header
          schema:
            $ref: '#/components/schemas/intercom_version'
      tags:
        - Switch
      operationId: createPhoneSwitch
      description: |
        You can use the API to deflect phone calls to the Intercom Messenger.
        Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified.

        If custom attributes are specified, they will be added to the user or lead's custom data attributes.
      responses:
        '200':
          description: successful
          content:
            application/json:
              examples:
                successful:
                  value:
                    url: http://via.intercom.io/msgr/6eb60123-dadb-4881-80fd-4fc2cf272b12
                    type: phone_call_redirect
              schema:
                $ref: '#/components/schemas/phone_switch'
        '400':
          description: bad request - invalid number
          content:
            application/json:
              examples:
                bad request - exception sending sms:
                  value:
                    error_key: sms_failed
                    message: SMS was not sent due to an unknown error
                bad request - invalid number:
                  value:
                    error_key: invalid_phone_number
                    message: Invalid phone number
        '401':
          description: Unauthorized
          content:
            application/json:
              examples:
                Unauthorized:
                  value:
                    type: error.list
                    request_id: 5da7a3e7-dcb0-4378-8575-0a0e9bae3862
                    errors:
                      - code: unauthorized
                        message: Access Token Invalid
              schema:
                $ref: '#/components/schemas/error'
        '422':
          description: unprocessable entity
          content:
            application/json:
              examples:
                unprocessable entity:
                  value:
                    error_key: some_error
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_phone_switch_request'
            examples:
              successful:
                summary: successful
                value:
                  phone: '+353832345678'
                  custom_attributes:
                    issue_type: Billing
                    priority: High
              bad_request_-_exception_sending_sms:
                summary: bad request - exception sending sms
                value:
                  phone: '+353832345678'
                  custom_attributes:
                    issue_type: Billing
                    priority: High
              bad_request_-_invalid_number:
                summary: bad request - invalid number
                value:
                  phone: '+353832345678'
                  custom_attributes:
                    issue_type: Billing
                    priority: High
              unprocessable_entity:
                summary: unprocessable entity
                value:
                  phone: '+40241100100'
                  custom_attributes:
                    issue_type: Billing
                    priority: High
components:
  schemas:
    create_phone_switch_request:
      description: You can create an phone switch
      type: object
      title: Create Phone Switch Request Payload
      properties:
        phone:
          type: string
          description: Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger.
          example: +1 1234567890
        custom_attributes:
          $ref: '#/components/schemas/custom_attributes'
      required:
        - phone
    custom_attributes:
      title: Custom Attributes
      type: object
      description: An object containing the different custom attributes associated to the conversation as key-value pairs. For relationship attributes the value will be a list of custom object instance models.
      additionalProperties:
        anyOf:
          - type: string
          - $ref: '#/components/schemas/custom_object_instance'
    custom_object_instance:
      title: Custom Object Instance
      type: object
      x-tags:
        - Custom Object Instances
      description: A Custom Object Instance represents an instance of a custom object type. This allows you to create and set custom attributes to store data about your customers that is not already captured by Intercom. The parent object includes recommended default attributes and you can add your own custom attributes.
      properties:
        id:
          type: string
          description: The Intercom defined id representing the custom object instance.
          example: 5a7a19e9f59ae20001d1c1e6
        external_id:
          type: string
          description: The id you have defined for the custom object instance.
          example: 0001d1c1e65a7a19e9f59ae2
        type:
          type: string
          description: The identifier of the custom object type that defines the structure of the custom object instance.
          example: Order
        custom_attributes:
          type: object
          description: The custom attributes you have set on the custom object instance.
          additionalProperties:
            type: string
      required:
        - id
        - type
    error:
      type: object
      title: Error
      description: The API will return an Error List for a failed request, which will contain one or more Error objects.
      properties:
        type:
          type: string
          description: The type is error.list
          example: error.list
        request_id:
          type: string
          nullable: true
          format: uuid
          description: ''
          example: f93ecfa8-d08a-4325-8694-89aeb89c8f85
        errors:
          type: array
          description: An array of one or more error objects
          items:
            properties:
              code:
                type: string
                description: A string indicating the kind of error, used to further qualify the HTTP response code
                example: unauthorized
              message:
                type: string
                nullable: true
                description: Optional. Human readable description of the error.
                example: Access Token Invalid
              field:
                type: string
                nullable: true
                description: Optional. Used to identify a particular field or query parameter that was in error.
                example: email
            required:
              - code
      required:
        - type
        - errors
    intercom_version:
      description: Intercom API version.</br>By default, it's equal to the version set in the app package.
      type: string
      example: '2.11'
      default: '2.11'
      enum:
        - '1.0'
        - '1.1'
        - '1.2'
        - '1.3'
        - '1.4'
        - '2.0'
        - '2.1'
        - '2.2'
        - '2.3'
        - '2.4'
        - '2.5'
        - '2.6'
        - '2.7'
        - '2.8'
        - '2.9'
        - '2.10'
        - '2.11'
        - Preview
    phone_switch:
      title: Phone Switch
      type: object
      description: Phone Switch Response
      properties:
        type:
          type: string
          description: ''
          enum:
            - phone_call_redirect
          default: phone_call_redirect
          example: phone_call_redirect
        phone:
          type: string
          description: Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger.
          example: +1 1234567890
      required:
        - type
        - phone
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
```
