Understanding the JSON payload definition

Here is a description of the JSON payload used when configuring upstream connectivity

πŸ“˜

About this guide

This guide provide definitions and examples of the configuration payload that can be used to set up upstream API connectivity.

JSON sectionDescription
connector.inputsRequired list of objects specifying inputs that can be used in string interpolation. name and type are required. type needs to be a known demyst type.
connector.credentialsOptional list of credentials that can be used in string interpolation.
request.methodOne of GET | POST
request.urlThe URL of the external API. Credentials and inputs can be interpolated in this string, for example: "https://example.com?api_token=${credentials.api_token}&first_name=${inputs.first_name}".
request.headersAn object describing headers to include in the request. Credentials and inputs can be interpolated in the header values. This is probably most useful setting an Authorization header, for example: { "Authorization": "Bearer ${credentials.token}" }.
request.bodyAn object describing the JSON body to use for POST requests. Credentials and inputs can be interpolated in any string values.
inputsInputs to use when making an initial request to the external API to validate request logic and generate a more detailed JSON definition.
credentialsCredentials to use when making an initial request to the external API to validate request logic and generate a more detailed JSON definition.

Real-world examples

{
  "connector": {
    "inputs": [
      { "name": "domain", "type": "Domain" }
    ],
    "credentials": ["api_token"],
    "request": {
      "method": "GET",
      "url": "https://jsonwhois.com/api/v1/whois?domain=${inputs.domain}",
      "headers": {
        "Authorization": "Token token=${credentials.api_token}"
      }
    }
  },
  "inputs": {
    "domain": "demystdata.com"
  },
  "credentials": {
    "api_token": "interpolated_token"
  }
}
{
  "connector": {
    "inputs": [
      { "name": "address", "type": "Street" },
      { "name": "state",   "type": "State" },
      { "name": "country", "type": "Country" }
    ],

    "request": {
      "method": "POST",
      "url": "https://api.relativity6.guru/naics/naics/search",
      "headers": {
      },
      "body": {
        "token": "secret",
        "name": "${inputs.name}",
        "address": "${inputs.address}",
        "state": "${inputs.state}",
        "advancedSearch": true,
        "prediction": true,
        "existenceCheck": true,
        "keywords": true,
        "inputWarning": true,
        "explainConfidenceScore": true
      }
    }
  },

  "inputs": {
    "address": "TX",
    "state": "TX"
  }
}
{
  "connector": {
    "inputs": [
      { "name": "ip_address",    "type": "IP4" },
      { "name": "email_address", "type": "EmailAddress" }
    ],

    "request": {
      "method": "POST",
      "url": "https://minfraud.maxmind.com/minfraud/v2.0/insights",
      "headers": {
        "Authorization": "Basic hard-coded-in-this-example"
      },
      "body": {
        "device": {
          "ip_address": "${inputs.ip_address}"
        },
        "email": {
          "address": "${inputs.email_address}"
        }
      }
    }
  },

  "inputs": {
    "ip_address": "17.178.96.59",
    "email_address": "[email protected]"
  }
}
{
  "connector": {
    "inputs": [
      { "name": "phone", "type": "String" }
    ],

    "request": {
      "method": "POST",
      "url": "https://rest-ww.telesign.com/v1/phoneid/${inputs.phone}",
      "headers": {
        "Authorization": "Basic secret"
      },
      "body": {
        "addons": { "device_info": {} }
      }
    }
  },

  "inputs": {
    "phone": "18884521505"
  }
}
{
  "connector": {
    "inputs": [
      { "name": "first_name", "type": "FirstName" }
    ],

    "request": {
      "method": "POST",
      "url": "https://postman-echo.com/post",
      "body": {
        "first_name": "${inputs.first_name}"
      }
    }
  },

  "inputs": {
    "first_name": "Julia"
  }
}
{
    "connector": {
      "inputs": [
        {
          "name": "source_text",
          "type": "String"
        }
      ],
      "request": {
        "url": "https://translation.googleapis.com/language/translate/v2?q=${inputs.source_text}&target=en&key=${credentials.google_translate_api_token}",
        "auth": {},
        "method": "POST"
      },
      "credentials": [
        "google_translate_api_token"
      ]
    },
    "inputs": {
      "source_text": "bonjour"
    },
    "credentials": {
        "google_translate_api_token": "YOUR_TOKEN"
    }
}