Update a custom field
curl --request PUT \
--url https://api.kit.com/v4/custom_fields/{id} \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"label": "Last name"
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/custom_fields/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"label\": \"Last name\"\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'PUT',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({label: 'Last name'})
};
fetch('https://api.kit.com/v4/custom_fields/{id}', 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/custom_fields/{id}"
payload := strings.NewReader("{\n \"label\": \"Last name\"\n}")
req, _ := http.NewRequest("PUT", 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/custom_fields/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'label' => 'Last name'
]),
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/custom_fields/{id}"
payload = { "label": "Last name" }
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text){
"custom_field": {
"id": 27,
"name": "ck_field_27_last_name",
"key": "lastname",
"label": "Last name"
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"Not Found"
]
}{
"errors": [
"Label can't be blank"
]
}Custom Fields
Update a custom field
Updates a custom field label (see Create a custom field for more information on labels). Note that the key will change but the name remains the same when the label is updated.
Warning: An update to a custom field will break all of the liquid personalization tags in emails that reference it - e.g. if you update a Zip_Code custom field to Post_Code, all liquid tags referencing {{ subscriber.Zip_Code }} would no longer work and need to be replaced with {{ subscriber.Post_Code }}.
PUT
/
v4
/
custom_fields
/
{id}
Update a custom field
curl --request PUT \
--url https://api.kit.com/v4/custom_fields/{id} \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"label": "Last name"
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/custom_fields/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"label\": \"Last name\"\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'PUT',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({label: 'Last name'})
};
fetch('https://api.kit.com/v4/custom_fields/{id}', 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/custom_fields/{id}"
payload := strings.NewReader("{\n \"label\": \"Last name\"\n}")
req, _ := http.NewRequest("PUT", 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/custom_fields/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'label' => 'Last name'
]),
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/custom_fields/{id}"
payload = { "label": "Last name" }
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text){
"custom_field": {
"id": 27,
"name": "ck_field_27_last_name",
"key": "lastname",
"label": "Last name"
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"Not Found"
]
}{
"errors": [
"Label can't be blank"
]
}Was this page helpful?
⌘I