# 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.18/rest-api/api.intercom.io.yaml

```yaml
openapi: 3.0.1
info:
  title: Intercom API
  version: '2.18'
  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/1add3dd1-a75e-4a96-96fd-984d16aba059
                    type: phone_call_redirect
              schema:
                $ref: '#/components/schemas/phone_switch'
        '400':
          description: The phone number lookup or the SMS send failed
          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: e1ed4f34-9477-492a-8ddb-22f10af39734
                    errors:
                      - code: unauthorized
                        message: Access Token Invalid
                Feature not available:
                  value:
                    type: error.list
                    request_id: 79b635fd-f1f6-4404-aa83-5782675987fb
                    errors:
                      - code: unauthorized
                        message: App does not have access to this feature
              schema:
                $ref: '#/components/schemas/error'
        '422':
          description: 'The request was invalid. The response is an object with a single `error_key`: `caller_phone` when `phone` is missing, `invalid_phone_number`, `landline_phone`, `twilio_settings` when the workspace has no Twilio account to send the SMS, or `context` when `custom_attributes` is invalid. Any other invalid input returns its own key, such as `send_notification` or `country`.'
          content:
            application/json:
              examples:
                Invalid phone number:
                  value:
                    error_key: invalid_phone_number
                unprocessable entity:
                  value:
                    error_key: landline_phone
                Twilio account not found:
                  value:
                    error_key: twilio_settings
                Missing phone number:
                  value:
                    error_key: caller_phone
                Invalid custom attributes:
                  value:
                    error_key: context
      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
              missing_phone_number:
                summary: Missing phone number
                value:
                  custom_attributes:
                    issue_type: Billing
                    priority: High
              invalid_custom_attributes:
                summary: Invalid custom attributes
                value:
                  phone: '+353832345678'
                  custom_attributes:
                    issue_type:
                      - Billing
components:
  schemas:
    create_phone_switch_request:
      description: You can create an phone switch
      type: object
      title: Create Phone Switch Request Payload
      nullable: true
      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:
          type: object
          description: Custom attributes to add to the user or lead's custom data attributes. Values are strings. Numbers and booleans are converted to strings. An empty string, or any array or object value, returns a `422` error with the key `context`. A `null` value is ignored.
          additionalProperties:
            oneOf:
              - type: string
                nullable: true
              - type: number
              - type: boolean
          example:
            issue_type: Billing
            priority: High
        body:
          type: string
          description: The text of the contact's first message. When you send it, a conversation is created straight away with this text as its first message.
          example: I need help with my invoice
        send_notification:
          type: boolean
          default: true
          description: Whether to send the SMS with the link to the Messenger. When `false`, no SMS is sent.
          example: true
        user_input_phone:
          type: string
          nullable: true
          description: The phone number as the contact typed it, in national format. When sent with `country`, used in place of `phone` to read the number. `phone` is still required.
          example: 087 234 5678
        country:
          type: string
          nullable: true
          description: The two-letter country code used to read `user_input_phone`. When `country` is `US`, Intercom also looks up the carrier to detect landlines.
          example: IE
      required:
        - phone
    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
              data:
                type: object
                nullable: true
                additionalProperties: true
                description: Optional. Extra detail about the error, for example `required_permissions` on a 403 `action_forbidden` error.
                example:
                  required_permissions:
                    - read_conversations
            required:
              - code
      required:
        - type
        - errors
    intercom_version:
      description: Intercom API version.</br>If you omit the header, the API uses the version set in your app package, and 1.0 if none is set.
      type: string
      example: '2.18'
      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'
        - '2.12'
        - '2.13'
        - '2.14'
        - '2.15'
        - '2.16'
        - '2.17'
        - '2.18'
    phone_switch:
      title: Phone Switch
      type: object
      description: Phone Switch Response
      nullable: true
      properties:
        type:
          type: string
          description: ''
          enum:
            - phone_call_redirect
          default: phone_call_redirect
          example: phone_call_redirect
        url:
          type: string
          description: The Messenger link for the phone call redirect, which is also the link sent by SMS to the phone number.
          example: http://via.intercom.io/msgr/1add3dd1-a75e-4a96-96fd-984d16aba059
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
```
