Pin a subscriber's location
curl --request POST \
--url https://api.kit.com/v4/subscribers/{subscriber_id}/location \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"location": {
"city": "Boise",
"state_province": "Idaho",
"country_code": "US",
"latitude": 43.62,
"longitude": -116.2,
"timezone": "America/Denver"
}
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/subscribers/{subscriber_id}/location")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"location\": {\n \"city\": \"Boise\",\n \"state_province\": \"Idaho\",\n \"country_code\": \"US\",\n \"latitude\": 43.62,\n \"longitude\": -116.2,\n \"timezone\": \"America/Denver\"\n }\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
location: {
city: 'Boise',
state_province: 'Idaho',
country_code: 'US',
latitude: 43.62,
longitude: -116.2,
timezone: 'America/Denver'
}
})
};
fetch('https://api.kit.com/v4/subscribers/{subscriber_id}/location', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/subscribers/{subscriber_id}/location"
payload := strings.NewReader("{\n \"location\": {\n \"city\": \"Boise\",\n \"state_province\": \"Idaho\",\n \"country_code\": \"US\",\n \"latitude\": 43.62,\n \"longitude\": -116.2,\n \"timezone\": \"America/Denver\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-Api-Key", "<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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/subscribers/{subscriber_id}/location",
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([
'location' => [
'city' => 'Boise',
'state_province' => 'Idaho',
'country_code' => 'US',
'latitude' => 43.62,
'longitude' => -116.2,
'timezone' => 'America/Denver'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/subscribers/{subscriber_id}/location"
payload = { "location": {
"city": "Boise",
"state_province": "Idaho",
"country_code": "US",
"latitude": 43.62,
"longitude": -116.2,
"timezone": "America/Denver"
} }
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"subscriber": {
"id": 1100,
"location": {
"city": "Boise",
"state_province": "Idaho",
"country_code": "US",
"latitude": 43.62,
"longitude": -116.2,
"timezone": "America/Denver"
}
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"Not Found"
]
}{
"errors": [
"Country code can't be blank"
]
}Subscribers
Pin a subscriber's location
Pins an explicit location to a subscriber, overriding any location Kit has inferred from open events. Provide city, state_province, country_code (ISO 3166-1 alpha-2, required), latitude, longitude, and timezone (IANA timezone name, e.g. America/Denver). Returns the subscriber’s id and the pinned location on success.
If the subscriber already has a pinned location this replaces it. To replace the values on an existing pin, use Update a subscriber’s pinned location (PATCH); to remove the pin, use Delete a subscriber’s location. The pinned location is returned on Get a subscriber. Returns 404 when the subscriber is not found, 422 when a required field is missing or invalid.
POST
/
v4
/
subscribers
/
{subscriber_id}
/
location
Pin a subscriber's location
curl --request POST \
--url https://api.kit.com/v4/subscribers/{subscriber_id}/location \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"location": {
"city": "Boise",
"state_province": "Idaho",
"country_code": "US",
"latitude": 43.62,
"longitude": -116.2,
"timezone": "America/Denver"
}
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/subscribers/{subscriber_id}/location")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"location\": {\n \"city\": \"Boise\",\n \"state_province\": \"Idaho\",\n \"country_code\": \"US\",\n \"latitude\": 43.62,\n \"longitude\": -116.2,\n \"timezone\": \"America/Denver\"\n }\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
location: {
city: 'Boise',
state_province: 'Idaho',
country_code: 'US',
latitude: 43.62,
longitude: -116.2,
timezone: 'America/Denver'
}
})
};
fetch('https://api.kit.com/v4/subscribers/{subscriber_id}/location', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/subscribers/{subscriber_id}/location"
payload := strings.NewReader("{\n \"location\": {\n \"city\": \"Boise\",\n \"state_province\": \"Idaho\",\n \"country_code\": \"US\",\n \"latitude\": 43.62,\n \"longitude\": -116.2,\n \"timezone\": \"America/Denver\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-Api-Key", "<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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/subscribers/{subscriber_id}/location",
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([
'location' => [
'city' => 'Boise',
'state_province' => 'Idaho',
'country_code' => 'US',
'latitude' => 43.62,
'longitude' => -116.2,
'timezone' => 'America/Denver'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/subscribers/{subscriber_id}/location"
payload = { "location": {
"city": "Boise",
"state_province": "Idaho",
"country_code": "US",
"latitude": 43.62,
"longitude": -116.2,
"timezone": "America/Denver"
} }
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"subscriber": {
"id": 1100,
"location": {
"city": "Boise",
"state_province": "Idaho",
"country_code": "US",
"latitude": 43.62,
"longitude": -116.2,
"timezone": "America/Denver"
}
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"Not Found"
]
}{
"errors": [
"Country code can't be blank"
]
}Was this page helpful?
⌘I