Help
Phonesites API Documentation
The Phonesites API provides a straightforward POST endpoint for developers and marketers to programmatically add leads to a specified webpage. This functionality enables the direct insertion of lead data from external sources into the Phonesites ecosystem. The primary advantage is the ability to utilize Phonesites' automation features for leads acquired outside of the standard Form blocks. For developers, this means easy integration with existing systems and for marketers, it offers a centralized platform for lead management and the possibility to leverage connections with other third-party applications for enhanced workflows.
POST to Form Endpoint
This endpoint is designed to handle form data from Phonesites websites via HTTP POST requests.
Endpoint URL
You'll use your public URL of the Website / Page. You can also use your custom domain. Some examples:
https://{custom_subdomain}.phonesites.com
https://{custom_subdomain}.phonesites.com/{page_name}
https://{custom_domain}
https://{custom_domain}/{page_name}
HTTP Method
POST
Request Headers
Content-Type: application/json; charset=UTF-8
Request Body
The body must be a JSON object with key-value pairs that correspond to the Form fields on the URL you want to submit to. You can include other arbitrary data, but if your Form requires data, then your endpoint will validate each request accordingly.
{
"name": "example name",
"email": "example@email.com",
"custom": "Custom Field Text"
}
Response
- Always responses with content-type of "application/json"
- 200 OK: Data received and processed successfully.
{ success: true, lead_id: "lead_id_123" } - 4xx: Client error, such as missing required fields or incorrect data format.
{ error: "Missing fields: name, email" } - 5xx: Server error, indicating a problem with the server's processing of the request.
{ error: "Something went wrong" }
Example Usage
const response = await fetch("https://test.phonesites.com", {
method: "post",
headers: {
'content-type': 'application/json; charset=UTF-8'
},
body: JSON.stringify({ name: "My Name", email: "email@email.com" })
});
const { lead_id } = await response.json();
$url = 'https://test.phonesites.com';
$data = ['name' => 'My Name', 'email' => 'email@email.com'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json; charset=UTF-8']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if (!$response) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
curl_close($ch);
$responseData = json_decode($response, true);
$lead_id = $responseData['lead_id'];
echo "Lead ID: " . $lead_id;
import requests
url = 'https://test.phonesites.com'
headers = {'Content-Type': 'application/json; charset=UTF-8'}
data = {'name': 'My Name', 'email': 'email@email.com'}
response = requests.post(url, json=data, headers=headers)
response_data = response.json()
lead_id = response_data['lead_id']
print(f"Lead ID: {lead_id}")
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('https://test.phonesites.com')
headers = {'Content-Type' => 'application/json; charset=UTF-8'}
data = {name: 'My Name', email: 'email@email.com'}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, headers)
request.body = data.to_json
response = http.request(request)
response_data = JSON.parse(response.body)
lead_id = response_data['lead_id']
puts "Lead ID: #{lead_id}"
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://test.phonesites.com"
data := map[string]string{"name": "My Name", "email": "email@email.com"}
jsonData, _ := json.Marshal(data)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
var responseMap map[string]interface{}
json.Unmarshal(body, &responseMap)
lead_id := responseMap["lead_id"].(string)
fmt.Printf("Lead ID: %s", lead_id)
}
Have questions?