Update contact record
curl --request PATCH \
--url https://public-api.frictio.ai/v2/objects/contact/records/{recordId} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Workspace-Id: <x-workspace-id>' \
--data '
{
"job_title": "取締役",
"department": null
}
'import requests
url = "https://public-api.frictio.ai/v2/objects/contact/records/{recordId}"
payload = {
"job_title": "取締役",
"department": None
}
headers = {
"X-Workspace-Id": "<x-workspace-id>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {
'X-Workspace-Id': '<x-workspace-id>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({job_title: '取締役', department: null})
};
fetch('https://public-api.frictio.ai/v2/objects/contact/records/{recordId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public-api.frictio.ai/v2/objects/contact/records/{recordId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'job_title' => '取締役',
'department' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Workspace-Id: <x-workspace-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.frictio.ai/v2/objects/contact/records/{recordId}"
payload := strings.NewReader("{\n \"job_title\": \"取締役\",\n \"department\": null\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-Workspace-Id", "<x-workspace-id>")
req.Header.Add("X-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))
}HttpResponse<String> response = Unirest.patch("https://public-api.frictio.ai/v2/objects/contact/records/{recordId}")
.header("X-Workspace-Id", "<x-workspace-id>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"job_title\": \"取締役\",\n \"department\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.frictio.ai/v2/objects/contact/records/{recordId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-Workspace-Id"] = '<x-workspace-id>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"job_title\": \"取締役\",\n \"department\": null\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "deal",
"visibility": "workspace",
"fields": {
"name": "Acme",
"pipeline_id": "pipe-1",
"amount": "1200.50",
"my_note": "hello"
},
"created_at": "<string>",
"updated_at": "<string>",
"created_by": {
"kind": "member",
"name": "<string>"
},
"updated_by": {
"kind": "member",
"name": "<string>"
}
}API Reference
Update contact record
Contact を1件更新します。このエンドポイントは Contact 専用です。他のオブジェクトの更新には対応していません。
利用条件
- APIキーに紐づくサービスアカウントのロールに、Contact の編集権限(ワークスペース全体。閲覧権限を含みます)が必要です
- サービスアカウントに紐づく APIキーが必要です。サービスアカウントに紐づかない従来の APIキーは、読み取りでは使えても更新では
401(INVALID_API_KEY)になります - Contact のレコード機能が有効なワークスペースだけで利用できます。有効でないワークスペースでは
503(CONTACT_WRITE_UNAVAILABLE)を返します - 対象が存在しない場合、
recordIdの形式が誤っている場合、別のワークスペースの Contact の場合、非公開(visibilityがworkspaceでない)の Contact の場合は、区別せず404を返します
リクエストの形式
- 本文は
Content-Type: application/json(charset=utf-8のパラメータは付けられます)の JSON オブジェクトで送信してください。application/x-www-form-urlencoded、text/plainなど JSON 以外の形式や、Content-Typeを付けない本文(Transfer-Encoding: chunkedを含む)は415(UNSUPPORTED_MEDIA_TYPE)になり、更新は実行されません Content-Type: application/jsonで本文が{}の場合は200です。Content-Typeを付けず本文も空のリクエストは、JSON オブジェクトを受け取っていないため415ではなく400(VALIDATION_FAILED)になり、何も変更されません
更新の規則
- 省略した項目は変更されません。本文が
{}の場合は、何も変更せず200で現在の内容を返します。email以外の項目は、nullまたは空文字でクリアされます(first_name/last_nameは空文字、phone_number/mobile_phone_number/job_title/departmentはnullになります)。first_name/last_nameの片方だけを指定した場合、もう片方は変わりません。emailはnullと空文字を指定できません(400) - 他の有効な Contact と同じメールアドレスへの変更は
409(CONTACT_EMAIL_CONFLICT)になります - 既存の Company との関連は変更されません
502/504/ タイムアウトの時点では、更新の結果は不明です。自動で再送せず、GET /v2/objects/contact/records/{recordId}で現在の内容を確認してください
副作用(本文が {} の更新を除く)
- 変更履歴の記録
- 連携している CRM(HubSpot / Salesforce)への送信キューへの登録
レスポンスは、直後の GET /v2/objects/contact/records/{recordId} と同じ内容です。created_by は作成時の操作者のままで、updated_by は { "kind": "api_key", "name": "<サービスアカウント名>" } になります。本文が {} の更新では updated_by も変わりません。fields では、first_name / last_name は name({ "firstName", "lastName" })に入り、それ以外の項目は同じ名前のキーで返ります。
PATCH
/
v2
/
objects
/
contact
/
records
/
{recordId}
Update contact record
curl --request PATCH \
--url https://public-api.frictio.ai/v2/objects/contact/records/{recordId} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Workspace-Id: <x-workspace-id>' \
--data '
{
"job_title": "取締役",
"department": null
}
'import requests
url = "https://public-api.frictio.ai/v2/objects/contact/records/{recordId}"
payload = {
"job_title": "取締役",
"department": None
}
headers = {
"X-Workspace-Id": "<x-workspace-id>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {
'X-Workspace-Id': '<x-workspace-id>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({job_title: '取締役', department: null})
};
fetch('https://public-api.frictio.ai/v2/objects/contact/records/{recordId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public-api.frictio.ai/v2/objects/contact/records/{recordId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'job_title' => '取締役',
'department' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Workspace-Id: <x-workspace-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.frictio.ai/v2/objects/contact/records/{recordId}"
payload := strings.NewReader("{\n \"job_title\": \"取締役\",\n \"department\": null\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-Workspace-Id", "<x-workspace-id>")
req.Header.Add("X-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))
}HttpResponse<String> response = Unirest.patch("https://public-api.frictio.ai/v2/objects/contact/records/{recordId}")
.header("X-Workspace-Id", "<x-workspace-id>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"job_title\": \"取締役\",\n \"department\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.frictio.ai/v2/objects/contact/records/{recordId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-Workspace-Id"] = '<x-workspace-id>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"job_title\": \"取締役\",\n \"department\": null\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "deal",
"visibility": "workspace",
"fields": {
"name": "Acme",
"pipeline_id": "pipe-1",
"amount": "1200.50",
"my_note": "hello"
},
"created_at": "<string>",
"updated_at": "<string>",
"created_by": {
"kind": "member",
"name": "<string>"
},
"updated_by": {
"kind": "member",
"name": "<string>"
}
}Headers
Body
application/json
Contact の更新リクエストです。下記の7項目だけを指定できます。
これ以外の項目(company_ids、owner_id、visibility、カスタム項目など)を含めると 400 を返し、無視はされません。
省略した項目は変更されません。email 以外の項目は、null または空文字を指定すると値がクリアされます。
既存の Company との関連は変更されません。
Response
更新しました