---
title: Switch
slug: switch
docTags: 
createdAt: 2021-07-26T08:55:33.000Z
---

Switches the reponse based on the input provided. e.g if you are looking for a 'convert all reponses to a standardized output



The **default&#x20;**&#x61;ttribute instructs the function to return the value in default if none of the other items match. In the current example if the "**input**" were "**twitter**" the response would be "**unknown source**"

### API Definition

:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://orca.pathfix.com/functions/text/switch",
  "name": "Switch API",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "QbpXuPtXPiYBH5Mp0bWXK",
        "code": "{\n\t\"output\": \"fb\"\n}",
        "language": "200"
      },
      {
        "id": "mCN80kfmUVW1aLtgeskPP",
        "code": "{\n    \"message\": \"error\"\n}",
        "language": "404"
      }
    ],
    "selectedLanguageId": "QbpXuPtXPiYBH5Mp0bWXK"
  },
  "examples": {
    "languages": [
      {
        "id": "DDo-A_Hrdh8pBI1UMD5yO",
        "code": "{\r\n\t\"input\": \"Facebook\",\r\n\t\"switch\": {\r\n\t\t\"Facebook\": \"fb\",\r\n\t\t\"fbook\": \"fb\",\r\n\t\t\"facebook\": \"fb\",\r\n\t\t\"facebk\": \"fb\",\r\n\t\t\"linkedIn\": \"li\",\r\n\t\t\"LinkedIn\": \"li\",\r\n\t\t\"LinkIn\": \"li\"\r\n\t},\r\n\t\"default\":\"unknown source\"\r\n}",
        "language": "json"
      }
    ],
    "selectedLanguageId": "DDo-A_Hrdh8pBI1UMD5yO"
  },
  "description": "Call the following API to switch a response with a standard output",
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```
:::




### Use Cases

Best used for when you want to standardize a response received from multiple providers/sources.



