Create Contact Memory
curl --request POST \
--url https://api.bland.ai/v1/memory/contact \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"contact_id": "<string>",
"persona_id": "<string>",
"agent_number": "<string>"
}
'import requests
url = "https://api.bland.ai/v1/memory/contact"
payload = {
"contact_id": "<string>",
"persona_id": "<string>",
"agent_number": "<string>"
}
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({contact_id: '<string>', persona_id: '<string>', agent_number: '<string>'})
};
fetch('https://api.bland.ai/v1/memory/contact', 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://api.bland.ai/v1/memory/contact",
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([
'contact_id' => '<string>',
'persona_id' => '<string>',
'agent_number' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$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://api.bland.ai/v1/memory/contact"
payload := strings.NewReader("{\n \"contact_id\": \"<string>\",\n \"persona_id\": \"<string>\",\n \"agent_number\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
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://api.bland.ai/v1/memory/contact")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"<string>\",\n \"persona_id\": \"<string>\",\n \"agent_number\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v1/memory/contact")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contact_id\": \"<string>\",\n \"persona_id\": \"<string>\",\n \"agent_number\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"memory": {
"id": "mem-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"org_id": "11111111-2222-3333-4444-555555555555",
"contact_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"persona_id": "persona-12345678",
"agent_number": null,
"summary": null,
"facts": {},
"recent_messages": [],
"open_items": [],
"memory_history": [],
"created_at": "2025-07-22T10:30:00.000Z",
"updated_at": "2025-07-22T10:30:00.000Z"
},
"created": true
},
"errors": null
}
{
"data": {
"memory": {
"id": "mem-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"org_id": "11111111-2222-3333-4444-555555555555",
"contact_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"persona_id": "persona-12345678",
"agent_number": null,
"summary": "Customer called about order #8821 which was delayed. Promised a follow-up within 24 hours.",
"facts": {
"name": "Sarah Chen",
"phone": "+14155550192",
"preferred_contact": "phone"
},
"recent_messages": [
{
"role": "user",
"content": "Hi, I'm calling about my order",
"channel": "call",
"timestamp": "2025-07-22T10:30:00.000Z"
}
],
"open_items": [
{
"type": "follow_up",
"description": "Follow up on order #8821 delay status",
"created_at": "2025-07-22T10:30:00.000Z",
"priority": "high",
"related_to": {
"entity_type": "order",
"entity_id": "order-8821"
}
}
],
"memory_history": [],
"created_at": "2025-07-20T10:30:00.000Z",
"updated_at": "2025-07-22T15:45:00.000Z"
},
"created": false
},
"errors": null
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "persona_id or agent_number is required"
}
]
}
Memory
Create Contact Memory
Create a memory record for a contact scoped to a persona or agent number. If a record already exists for that pair, it is returned instead of creating a duplicate.
POST
/
v1
/
memory
/
contact
Create Contact Memory
curl --request POST \
--url https://api.bland.ai/v1/memory/contact \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"contact_id": "<string>",
"persona_id": "<string>",
"agent_number": "<string>"
}
'import requests
url = "https://api.bland.ai/v1/memory/contact"
payload = {
"contact_id": "<string>",
"persona_id": "<string>",
"agent_number": "<string>"
}
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({contact_id: '<string>', persona_id: '<string>', agent_number: '<string>'})
};
fetch('https://api.bland.ai/v1/memory/contact', 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://api.bland.ai/v1/memory/contact",
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([
'contact_id' => '<string>',
'persona_id' => '<string>',
'agent_number' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$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://api.bland.ai/v1/memory/contact"
payload := strings.NewReader("{\n \"contact_id\": \"<string>\",\n \"persona_id\": \"<string>\",\n \"agent_number\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
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://api.bland.ai/v1/memory/contact")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"<string>\",\n \"persona_id\": \"<string>\",\n \"agent_number\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v1/memory/contact")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contact_id\": \"<string>\",\n \"persona_id\": \"<string>\",\n \"agent_number\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"memory": {
"id": "mem-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"org_id": "11111111-2222-3333-4444-555555555555",
"contact_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"persona_id": "persona-12345678",
"agent_number": null,
"summary": null,
"facts": {},
"recent_messages": [],
"open_items": [],
"memory_history": [],
"created_at": "2025-07-22T10:30:00.000Z",
"updated_at": "2025-07-22T10:30:00.000Z"
},
"created": true
},
"errors": null
}
{
"data": {
"memory": {
"id": "mem-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"org_id": "11111111-2222-3333-4444-555555555555",
"contact_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"persona_id": "persona-12345678",
"agent_number": null,
"summary": "Customer called about order #8821 which was delayed. Promised a follow-up within 24 hours.",
"facts": {
"name": "Sarah Chen",
"phone": "+14155550192",
"preferred_contact": "phone"
},
"recent_messages": [
{
"role": "user",
"content": "Hi, I'm calling about my order",
"channel": "call",
"timestamp": "2025-07-22T10:30:00.000Z"
}
],
"open_items": [
{
"type": "follow_up",
"description": "Follow up on order #8821 delay status",
"created_at": "2025-07-22T10:30:00.000Z",
"priority": "high",
"related_to": {
"entity_type": "order",
"entity_id": "order-8821"
}
}
],
"memory_history": [],
"created_at": "2025-07-20T10:30:00.000Z",
"updated_at": "2025-07-22T15:45:00.000Z"
},
"created": false
},
"errors": null
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "persona_id or agent_number is required"
}
]
}
Headers
string
required
Your API key for authentication.
Body Parameters
string
required
The unique identifier of the contact.
string
The persona ID for memory scoping. Either
persona_id or agent_number is required.string
The agent phone number for memory scoping. Either
persona_id or agent_number is required.Response
object
Response containing the memory and creation status.
object
The contact memory object.
string
Unique identifier for the contact memory.
string
Organization ID this memory belongs to.
string
Contact ID this memory is associated with.
string
Persona ID this memory is scoped to (null if agent-based).
string
Agent phone number this memory is scoped to (null if persona-based).
string
Rolling summary (empty for new memories).
object
Structured facts (empty object for new memories).
array
Recent messages array (empty for new memories).
boolean
Whether a new memory was created (true) or an existing one was returned (false).
null
Error array (null on success).
{
"data": {
"memory": {
"id": "mem-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"org_id": "11111111-2222-3333-4444-555555555555",
"contact_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"persona_id": "persona-12345678",
"agent_number": null,
"summary": null,
"facts": {},
"recent_messages": [],
"open_items": [],
"memory_history": [],
"created_at": "2025-07-22T10:30:00.000Z",
"updated_at": "2025-07-22T10:30:00.000Z"
},
"created": true
},
"errors": null
}
{
"data": {
"memory": {
"id": "mem-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"org_id": "11111111-2222-3333-4444-555555555555",
"contact_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"persona_id": "persona-12345678",
"agent_number": null,
"summary": "Customer called about order #8821 which was delayed. Promised a follow-up within 24 hours.",
"facts": {
"name": "Sarah Chen",
"phone": "+14155550192",
"preferred_contact": "phone"
},
"recent_messages": [
{
"role": "user",
"content": "Hi, I'm calling about my order",
"channel": "call",
"timestamp": "2025-07-22T10:30:00.000Z"
}
],
"open_items": [
{
"type": "follow_up",
"description": "Follow up on order #8821 delay status",
"created_at": "2025-07-22T10:30:00.000Z",
"priority": "high",
"related_to": {
"entity_type": "order",
"entity_id": "order-8821"
}
}
],
"memory_history": [],
"created_at": "2025-07-20T10:30:00.000Z",
"updated_at": "2025-07-22T15:45:00.000Z"
},
"created": false
},
"errors": null
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "persona_id or agent_number is required"
}
]
}
Docs for agents: llms.txt
Was this page helpful?
⌘I