Create contact record
curl --request POST \
--url https://public-api.frictio.ai/v2/objects/contact/records \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Workspace-Id: <x-workspace-id>' \
--data '
{
"email": "taro.yamada@example.com",
"first_name": "太郎",
"last_name": "山田",
"phone_number": "03-1234-5678",
"job_title": "営業部長",
"department": "営業部"
}
'import requests
url = "https://public-api.frictio.ai/v2/objects/contact/records"
payload = {
"email": "taro.yamada@example.com",
"first_name": "太郎",
"last_name": "山田",
"phone_number": "03-1234-5678",
"job_title": "営業部長",
"department": "営業部"
}
headers = {
"X-Workspace-Id": "<x-workspace-id>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Workspace-Id': '<x-workspace-id>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'taro.yamada@example.com',
first_name: '太郎',
last_name: '山田',
phone_number: '03-1234-5678',
job_title: '営業部長',
department: '営業部'
})
};
fetch('https://public-api.frictio.ai/v2/objects/contact/records', 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",
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([
'email' => 'taro.yamada@example.com',
'first_name' => '太郎',
'last_name' => '山田',
'phone_number' => '03-1234-5678',
'job_title' => '営業部長',
'department' => '営業部'
]),
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"
payload := strings.NewReader("{\n \"email\": \"taro.yamada@example.com\",\n \"first_name\": \"太郎\",\n \"last_name\": \"山田\",\n \"phone_number\": \"03-1234-5678\",\n \"job_title\": \"営業部長\",\n \"department\": \"営業部\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://public-api.frictio.ai/v2/objects/contact/records")
.header("X-Workspace-Id", "<x-workspace-id>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"taro.yamada@example.com\",\n \"first_name\": \"太郎\",\n \"last_name\": \"山田\",\n \"phone_number\": \"03-1234-5678\",\n \"job_title\": \"営業部長\",\n \"department\": \"営業部\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.frictio.ai/v2/objects/contact/records")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Workspace-Id"] = '<x-workspace-id>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"taro.yamada@example.com\",\n \"first_name\": \"太郎\",\n \"last_name\": \"山田\",\n \"phone_number\": \"03-1234-5678\",\n \"job_title\": \"営業部長\",\n \"department\": \"営業部\"\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
Create contact record
Contact を1件作成します。このエンドポイントは Contact 専用です。他のオブジェクトの作成には対応していません。
利用条件
- APIキーに紐づくサービスアカウントのロールに、Contact の作成権限と閲覧権限(ワークスペース全体)が必要です
- サービスアカウントに紐づく APIキーが必要です。サービスアカウントに紐づかない従来の APIキーは、読み取りでは使えても作成では
401(INVALID_API_KEY)になります - Contact のレコード機能が有効なワークスペースだけで利用できます。有効でないワークスペースでは
503(CONTACT_WRITE_UNAVAILABLE)を返します
リクエストの形式
- 本文は
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を付けず本文も空のリクエストは415ではなく400(VALIDATION_FAILED)です
重複と再送
- 同じメールアドレス(大文字小文字は区別しません)の有効な Contact がすでにある場合は
409(CONTACT_EMAIL_CONFLICT)を返します。メールアドレスでの更新(Upsert)や、409のあとの自動更新は行いません。既存の Contact はPATCHで更新してください Idempotency-Keyヘッダーには対応していません- 作成した Contact は全体公開(
visibilityがworkspace)で、担当者(owner)は設定されません。公開日時(published_at)は作成時刻に設定されます - 作成は1つのトランザクションで完結しません。Contact 本体の作成後に別の書き込みで失敗すると、Contact は存在するのにエラー(
502)が返り、公開・所有に関する情報や従来の読み取り処理向けの情報が反映されないまま残ることがあります 502/504/ タイムアウトの時点では、作成の結果は不明です。自動で再送しないでください。再送して409が返った場合は、成功とは扱わず結果の確認が必要です503(WORKSPACE_UNDER_MAINTENANCE)が返った場合も、まれに Contact が作成済みのことがあります。そのあとの再送で409が返った場合は、同じく結果を確認してください- Contact の検索(メールアドレスでの絞り込み)には対応していないため、結果は Frictio 上で確認してください
- 大文字小文字だけが違うメールアドレスをほぼ同時に作成すると、重複した Contact が作られる場合があります。同じメールアドレスのリクエストは並列に送らないでください
副作用
- 変更履歴の記録、Created Activity の記録(ベストエフォート。失敗してもリクエストは成功します)
- 連携している CRM(HubSpot / Salesforce)への送信キューへの登録
レスポンスは、直後の GET /v2/objects/contact/records/{recordId} と同じ内容です。created_by / updated_by は { "kind": "api_key", "name": "<サービスアカウント名>" } で、ID は含まれません。
fields では、first_name / last_name は name({ "firstName", "lastName" })に入り、指定しない(null を含む)と空文字です。phone_number / mobile_phone_number / job_title / department は同じ名前のキーで返り、指定しない(null・空文字を含む)と null です。
POST
/
v2
/
objects
/
contact
/
records
Create contact record
curl --request POST \
--url https://public-api.frictio.ai/v2/objects/contact/records \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Workspace-Id: <x-workspace-id>' \
--data '
{
"email": "taro.yamada@example.com",
"first_name": "太郎",
"last_name": "山田",
"phone_number": "03-1234-5678",
"job_title": "営業部長",
"department": "営業部"
}
'import requests
url = "https://public-api.frictio.ai/v2/objects/contact/records"
payload = {
"email": "taro.yamada@example.com",
"first_name": "太郎",
"last_name": "山田",
"phone_number": "03-1234-5678",
"job_title": "営業部長",
"department": "営業部"
}
headers = {
"X-Workspace-Id": "<x-workspace-id>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Workspace-Id': '<x-workspace-id>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'taro.yamada@example.com',
first_name: '太郎',
last_name: '山田',
phone_number: '03-1234-5678',
job_title: '営業部長',
department: '営業部'
})
};
fetch('https://public-api.frictio.ai/v2/objects/contact/records', 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",
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([
'email' => 'taro.yamada@example.com',
'first_name' => '太郎',
'last_name' => '山田',
'phone_number' => '03-1234-5678',
'job_title' => '営業部長',
'department' => '営業部'
]),
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"
payload := strings.NewReader("{\n \"email\": \"taro.yamada@example.com\",\n \"first_name\": \"太郎\",\n \"last_name\": \"山田\",\n \"phone_number\": \"03-1234-5678\",\n \"job_title\": \"営業部長\",\n \"department\": \"営業部\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://public-api.frictio.ai/v2/objects/contact/records")
.header("X-Workspace-Id", "<x-workspace-id>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"taro.yamada@example.com\",\n \"first_name\": \"太郎\",\n \"last_name\": \"山田\",\n \"phone_number\": \"03-1234-5678\",\n \"job_title\": \"営業部長\",\n \"department\": \"営業部\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.frictio.ai/v2/objects/contact/records")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Workspace-Id"] = '<x-workspace-id>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"taro.yamada@example.com\",\n \"first_name\": \"太郎\",\n \"last_name\": \"山田\",\n \"phone_number\": \"03-1234-5678\",\n \"job_title\": \"営業部長\",\n \"department\": \"営業部\"\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 を返し、無視はされません。
作成した Contact の公開範囲は常に workspace(全体公開)で、担当者(owner)は設定されません。
Response
作成しました