Skip to main content
PATCH
/
chatbots
/
{chatbotId}
/
contacts
/
{contactId}
Update a contact
curl --request PATCH \
  --url https://www.chatbase.co/api/v1/chatbots/{chatbotId}/contacts/{contactId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "data": {
    "external_id": "user_123",
    "name": "John Doe",
    "email": "john@example.com",
    "phonenumber": "+1234567890",
    "stripe_accounts": [
      {
        "label": "main",
        "stripe_id": "cus_123abc456",
        "stripe_email": "john@example.com"
      }
    ],
    "custom_attributes": {
      "department": "Engineering",
      "subscription_tier": "Enterprise"
    }
  }
}
'
import requests

url = "https://www.chatbase.co/api/v1/chatbots/{chatbotId}/contacts/{contactId}"

payload = { "data": {
"external_id": "user_123",
"name": "John Doe",
"email": "john@example.com",
"phonenumber": "+1234567890",
"stripe_accounts": [
{
"label": "main",
"stripe_id": "cus_123abc456",
"stripe_email": "john@example.com"
}
],
"custom_attributes": {
"department": "Engineering",
"subscription_tier": "Enterprise"
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
external_id: 'user_123',
name: 'John Doe',
email: 'john@example.com',
phonenumber: '+1234567890',
stripe_accounts: [{label: 'main', stripe_id: 'cus_123abc456', stripe_email: 'john@example.com'}],
custom_attributes: {department: 'Engineering', subscription_tier: 'Enterprise'}
}
})
};

fetch('https://www.chatbase.co/api/v1/chatbots/{chatbotId}/contacts/{contactId}', 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://www.chatbase.co/api/v1/chatbots/{chatbotId}/contacts/{contactId}",
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([
'data' => [
'external_id' => 'user_123',
'name' => 'John Doe',
'email' => 'john@example.com',
'phonenumber' => '+1234567890',
'stripe_accounts' => [
[
'label' => 'main',
'stripe_id' => 'cus_123abc456',
'stripe_email' => 'john@example.com'
]
],
'custom_attributes' => [
'department' => 'Engineering',
'subscription_tier' => 'Enterprise'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$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://www.chatbase.co/api/v1/chatbots/{chatbotId}/contacts/{contactId}"

payload := strings.NewReader("{\n \"data\": {\n \"external_id\": \"user_123\",\n \"name\": \"John Doe\",\n \"email\": \"john@example.com\",\n \"phonenumber\": \"+1234567890\",\n \"stripe_accounts\": [\n {\n \"label\": \"main\",\n \"stripe_id\": \"cus_123abc456\",\n \"stripe_email\": \"john@example.com\"\n }\n ],\n \"custom_attributes\": {\n \"department\": \"Engineering\",\n \"subscription_tier\": \"Enterprise\"\n }\n }\n}")

req, _ := http.NewRequest("PATCH", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
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://www.chatbase.co/api/v1/chatbots/{chatbotId}/contacts/{contactId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"external_id\": \"user_123\",\n \"name\": \"John Doe\",\n \"email\": \"john@example.com\",\n \"phonenumber\": \"+1234567890\",\n \"stripe_accounts\": [\n {\n \"label\": \"main\",\n \"stripe_id\": \"cus_123abc456\",\n \"stripe_email\": \"john@example.com\"\n }\n ],\n \"custom_attributes\": {\n \"department\": \"Engineering\",\n \"subscription_tier\": \"Enterprise\"\n }\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://www.chatbase.co/api/v1/chatbots/{chatbotId}/contacts/{contactId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"external_id\": \"user_123\",\n \"name\": \"John Doe\",\n \"email\": \"john@example.com\",\n \"phonenumber\": \"+1234567890\",\n \"stripe_accounts\": [\n {\n \"label\": \"main\",\n \"stripe_id\": \"cus_123abc456\",\n \"stripe_email\": \"john@example.com\"\n }\n ],\n \"custom_attributes\": {\n \"department\": \"Engineering\",\n \"subscription_tier\": \"Enterprise\"\n }\n }\n}"

response = http.request(request)
puts response.read_body
{
  "message": "Success",
  "data": {
    "id": "contact_internal_123",
    "external_id": "user_123",
    "name": "John Doe",
    "email": "john@example.com",
    "phonenumber": "+1234567890",
    "stripe_accounts": [
      {
        "label": "main",
        "stripe_id": "cus_123abc456",
        "stripe_email": "john@example.com"
      }
    ],
    "custom_attributes": {
      "department": "Sales",
      "subscription_tier": "Premium"
    },
    "created_at": 1704067200,
    "updated_at": 1704153600
  }
}
{
"message": "Invalid request data"
}
{
"message": "No API key provided."
}
{
"message": "Resource not found"
}
{
"message": "Error saving chatbot contact. External ID or email already exists."
}
{
"message": "Rate limit exceeded. Please try again later."
}
{
"message": "Internal server error"
}

Authorizations

Authorization
string
header
required

API key in Bearer token format

Path Parameters

chatbotId
string
required

ID of the chatbot

contactId
string
required

External ID of the contact

Body

application/json
data
object

Response

Contact updated successfully

message
string
Example:

"Success"

data
object