Create Phrase Replacement Config - Uplift AI API Docs

Create phrase replacement config

JavaScript

{
  "phraseReplacements": [
    {
      "phrase": "سیونگز اکاؤنٹ",
      "replacement": "savings account"
    },
    {
      "phrase": "Isabion",
      "replacement": "ایزابیان"
    },
    {
      "phrase": "Meezan bank",
      "replacement": "میزان بینک"
    }
  ]
}

cURL

curl --request POST \
  --url https://api.upliftai.org/v1/synthesis/phrase-replacement-config \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "phraseReplacements": [
    {
      "phrase": "<string>",
      "replacement": "<string>"
    }
  ]
}
'

Python

import requests

url = "https://api.upliftai.org/v1/synthesis/phrase-replacement-config"

payload = { "phraseReplacements": [
        {
            "phrase": "<string>",
            "replacement": "<string>"
        }
    ] }
headers = {
    "Authorization": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.upliftai.org/v1/synthesis/phrase-replacement-config",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'phraseReplacements' => [
        [
                'phrase' => '<string>',
                'replacement' => '<string>'
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: <api-key>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

url := "https://api.upliftai.org/v1/synthesis/phrase-replacement-config"

payload := strings.NewReader("{\n  \"phraseReplacements\": [\n    {\n      \"phrase\": \"<string>\",\n      \"replacement\": \"<string>\"\n    }\n  ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<api-key>")
    req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Java

HttpResponse<String> response = Unirest.post("https://api.upliftai.org/v1/synthesis/phrase-replacement-config")
  .header("Authorization", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phraseReplacements\": [\n    {\n      \"phrase\": \"<string>\",\n      \"replacement\": \"<string>\"\n    }\n  ]\n}")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://api.upliftai.org/v1/synthesis/phrase-replacement-config")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phraseReplacements\": [\n    {\n      \"phrase\": \"<string>\",\n      \"replacement\": \"<string>\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body

Response Examples

Success Response (201)

{
  "configId": "<string>",
  "phraseReplacements": [
    {
      "phrase": "<string>",
      "replacement": "<string>"
    }
  ]
}

Error Response (400)

{
  "message": "<string>"
}

Rate Limit Exceeded (429)

{
  "message": "Rate limit exceeded, please try again later"
}

Authorizations

Body