Voice API

Start a call from your application. The call is placed from an extension, a ring group or a number on your account, using a pre-authorised caller number. Download the recording of an answered call by its call ID.

Base URL https://portal.par-infinity.com/api/v1 · Authentication · Errors · Product overview

Make a voice call.

POST /voice/call

Start a voice call on any number in the world. The response contains originate_call_id. It is also sent in the call's call_notification webhooks and can be used to download the recording with GET /call/recording/{call_id}.

Request body application/json

NameTypeDescription
to required string Example: 15551928124
from required string Example: 15559381231
number required string Example: 123456789
from_type required string One of: extension, number, ring_group

Example request

cURL

curl -X POST 'https://portal.par-infinity.com/api/v1/voice/call/' \
  -H 'Authorization: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "to": "15551928124",
    "from": "15559381231",
    "number": "123456789"
  }'

Python

import requests

url = "https://portal.par-infinity.com/api/v1/voice/call/"
headers = {"Authorization": "YOUR_API_KEY"}
payload = {
    "to": "15551928124",
    "from": "15559381231",
    "number": "123456789"
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
print(response.status_code, response.json())

Node.js

const res = await fetch("https://portal.par-infinity.com/api/v1/voice/call/", {
  method: "POST",
  headers: {
    Authorization: process.env.PAR_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "15551928124",
    "from": "15559381231",
    "number": "123456789"
  }),
});
console.log(res.status, await res.json());

PHP

<?php

$ch = curl_init('https://portal.par-infinity.com/api/v1/voice/call/');
$headers = ['Authorization: YOUR_API_KEY'];

$payload = <<<'JSON'
{
    "to": "15551928124",
    "from": "15559381231",
    "number": "123456789"
}
JSON;

$headers[] = 'Content-Type: application/json';

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $payload,
    CURLOPT_HTTPHEADER => $headers,
]);

$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), ' ', $response, PHP_EOL;
curl_close($ch);

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
    public static void main(String[] args) throws Exception {
        String payload = """
        {
          "to": "15551928124",
          "from": "15559381231",
          "number": "123456789"
        }
        """;

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://portal.par-infinity.com/api/v1/voice/call/"))
            .header("Authorization", "YOUR_API_KEY")
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString(payload))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}

Go

package main

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

func main() {
	payload := `{
	  "to": "15551928124",
	  "from": "15559381231",
	  "number": "123456789"
	}`

	req, err := http.NewRequest("POST", "https://portal.par-infinity.com/api/v1/voice/call/", strings.NewReader(payload))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	data, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(data))
}

Ruby

require 'net/http'
require 'uri'

uri = URI('https://portal.par-infinity.com/api/v1/voice/call/')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = <<~JSON
  {
    "to": "15551928124",
    "from": "15559381231",
    "number": "123456789"
  }
JSON

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.code, response.body

C# (.NET)

using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://portal.par-infinity.com/api/v1/voice/call/");
request.Headers.TryAddWithoutValidation("Authorization", "YOUR_API_KEY");
var payload = """
{
  "to": "15551928124",
  "from": "15559381231",
  "number": "123456789"
}
""";
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");

var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");

Example response 200

{
  "status": "ok",
  "message": "Call Originated",
  "originate_call_id": "3f0c8a52-5d1e-4b8e-9c55-2b6f8f1d7a10"
}

Errors

401 Unauthorized402 Payment required403 Forbidden404 Not found405 Method not allowed422 Unprocessable entity429 Too many requests500 Internal server error

Download a call recording.

GET /call/recording/{call_id}

Download the recording of one answered call on your PBX as an audio file (audio/mpeg, sent as an attachment). call_id can be any of: call_id from the call_notification webhook; originate_call_id returned by POST /voice/call; call_id from GET /reports/voice. The recording is uploaded a few seconds after the call ends. Until then (for up to 10 minutes after the call) the answer is 404 with the message Recording not ready yet and a Retry-After header (seconds): wait and try again. Only answered, recorded calls of your own account are found; every other case (no recording, not your call, removed after your recording retention period) answers 404 Recording not found. Whether a call was recorded: recording in GET /reports/voice and in the call_notification hangup event. Requires an API key with the voice scope.

Path parameters

NameTypeDescription
call_id required string Letters, digits and @ . _ : + -, 6 to 128 characters. A trailing .mp3 is ignored. Example: 7f00a920-7c0d-47c4-a0f7-d4bf45b7714f

Query parameters

NameTypeDescription
date string The call's start day (UTC), DD-MM-YYYY; that day and the day before are searched. Without it, the last 3 days are searched. Send it for older calls. Example: 19-11-2026

Example request

cURL

status=$(curl -s -X GET 'https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/' \
  -H 'Authorization: YOUR_API_KEY' \
  -o recording.mp3.part -w '%{http_code}')
if [ "$status" = "200" ]; then mv recording.mp3.part recording.mp3; else rm -f recording.mp3.part; fi
echo "$status"

Python

import requests

url = "https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/"
headers = {"Authorization": "YOUR_API_KEY"}

response = requests.get(url, headers=headers, timeout=30)
if response.status_code == 200:
    with open("recording.mp3", "wb") as fh:
        fh.write(response.content)
print(response.status_code)

Node.js

import { writeFile } from "node:fs/promises";

const res = await fetch("https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/", {
  method: "GET",
  headers: {
    Authorization: process.env.PAR_API_KEY,
  },
});
if (res.status === 200) await writeFile("recording.mp3", Buffer.from(await res.arrayBuffer()));
console.log(res.status);

PHP

<?php

$ch = curl_init('https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/');
$headers = ['Authorization: YOUR_API_KEY'];

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status === 200) file_put_contents('recording.mp3', $response);
echo $status, PHP_EOL;
curl_close($ch);

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/"))
            .header("Authorization", "YOUR_API_KEY")
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<byte[]> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofByteArray());
        if (response.statusCode() == 200) Files.write(Path.of("recording.mp3"), response.body());
        System.out.println(response.statusCode());
    }
}

Go

package main

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

func main() {
	req, err := http.NewRequest("GET", "https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "YOUR_API_KEY")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	data, _ := io.ReadAll(res.Body)
	if res.StatusCode == http.StatusOK {
		os.WriteFile("recording.mp3", data, 0o644)
	}
	fmt.Println(res.StatusCode)
}

Ruby

require 'net/http'
require 'uri'

uri = URI('https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'YOUR_API_KEY'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
File.binwrite('recording.mp3', response.body) if response.code == '200'
puts response.code

C# (.NET)

using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("GET"), "https://portal.par-infinity.com/api/v1/call/recording/CALL_ID/");
request.Headers.TryAddWithoutValidation("Authorization", "YOUR_API_KEY");

var response = await client.SendAsync(request);
if ((int)response.StatusCode == 200)
    await File.WriteAllBytesAsync("recording.mp3", await response.Content.ReadAsByteArrayAsync());
Console.WriteLine((int)response.StatusCode);

Response 200 audio/mpeg

The recording file. The body is the file itself (audio/mpeg), not JSON; the examples above save it.

Errors

401 Unauthorized403 Forbidden404 Not found405 Method not allowed422 Unprocessable entity429 Too many requests503 Service unavailable