Set Fact
curl --request POST \
--url https://composer.personal.ai/lab/api/v1/op/fact.set \
--header 'Content-Type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"value": "<string>",
"fact_type": "<string>",
"agent": "<string>",
"subject": "<string>",
"replaces": "<string>",
"expires_at": "<string>",
"confidence": 123
}
'import requests
url = "https://composer.personal.ai/lab/api/v1/op/fact.set"
payload = {
"value": "<string>",
"fact_type": "<string>",
"agent": "<string>",
"subject": "<string>",
"replaces": "<string>",
"expires_at": "<string>",
"confidence": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
value: '<string>',
fact_type: '<string>',
agent: '<string>',
subject: '<string>',
replaces: '<string>',
expires_at: '<string>',
confidence: 123
})
};
fetch('https://composer.personal.ai/lab/api/v1/op/fact.set', 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://composer.personal.ai/lab/api/v1/op/fact.set",
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([
'value' => '<string>',
'fact_type' => '<string>',
'agent' => '<string>',
'subject' => '<string>',
'replaces' => '<string>',
'expires_at' => '<string>',
'confidence' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://composer.personal.ai/lab/api/v1/op/fact.set"
payload := strings.NewReader("{\n \"value\": \"<string>\",\n \"fact_type\": \"<string>\",\n \"agent\": \"<string>\",\n \"subject\": \"<string>\",\n \"replaces\": \"<string>\",\n \"expires_at\": \"<string>\",\n \"confidence\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://composer.personal.ai/lab/api/v1/op/fact.set")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "<content-type>")
.body("{\n \"value\": \"<string>\",\n \"fact_type\": \"<string>\",\n \"agent\": \"<string>\",\n \"subject\": \"<string>\",\n \"replaces\": \"<string>\",\n \"expires_at\": \"<string>\",\n \"confidence\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://composer.personal.ai/lab/api/v1/op/fact.set")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"value\": \"<string>\",\n \"fact_type\": \"<string>\",\n \"agent\": \"<string>\",\n \"subject\": \"<string>\",\n \"replaces\": \"<string>\",\n \"expires_at\": \"<string>\",\n \"confidence\": 123\n}"
response = http.request(request)
puts response.read_body{
"fact_id": "<string>",
"changed": true,
"replaced": [
{}
],
"retired": [
{}
]
}Memory APIs
Set Fact
Record something about a person
POST
/
lab
/
api
/
v1
/
op
/
fact.set
Set Fact
curl --request POST \
--url https://composer.personal.ai/lab/api/v1/op/fact.set \
--header 'Content-Type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"value": "<string>",
"fact_type": "<string>",
"agent": "<string>",
"subject": "<string>",
"replaces": "<string>",
"expires_at": "<string>",
"confidence": 123
}
'import requests
url = "https://composer.personal.ai/lab/api/v1/op/fact.set"
payload = {
"value": "<string>",
"fact_type": "<string>",
"agent": "<string>",
"subject": "<string>",
"replaces": "<string>",
"expires_at": "<string>",
"confidence": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
value: '<string>',
fact_type: '<string>',
agent: '<string>',
subject: '<string>',
replaces: '<string>',
expires_at: '<string>',
confidence: 123
})
};
fetch('https://composer.personal.ai/lab/api/v1/op/fact.set', 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://composer.personal.ai/lab/api/v1/op/fact.set",
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([
'value' => '<string>',
'fact_type' => '<string>',
'agent' => '<string>',
'subject' => '<string>',
'replaces' => '<string>',
'expires_at' => '<string>',
'confidence' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://composer.personal.ai/lab/api/v1/op/fact.set"
payload := strings.NewReader("{\n \"value\": \"<string>\",\n \"fact_type\": \"<string>\",\n \"agent\": \"<string>\",\n \"subject\": \"<string>\",\n \"replaces\": \"<string>\",\n \"expires_at\": \"<string>\",\n \"confidence\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://composer.personal.ai/lab/api/v1/op/fact.set")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "<content-type>")
.body("{\n \"value\": \"<string>\",\n \"fact_type\": \"<string>\",\n \"agent\": \"<string>\",\n \"subject\": \"<string>\",\n \"replaces\": \"<string>\",\n \"expires_at\": \"<string>\",\n \"confidence\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://composer.personal.ai/lab/api/v1/op/fact.set")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"value\": \"<string>\",\n \"fact_type\": \"<string>\",\n \"agent\": \"<string>\",\n \"subject\": \"<string>\",\n \"replaces\": \"<string>\",\n \"expires_at\": \"<string>\",\n \"confidence\": 123\n}"
response = http.request(request)
puts response.read_body{
"fact_id": "<string>",
"changed": true,
"replaced": [
{}
],
"retired": [
{}
]
}Overview
Records a fact about a person in an assistant’s memory. Pass afact_type (one of your workspace’s fields, see Vocabulary) so the value is checked and stored on the person’s record. Setting the same value again changes nothing.
Changes data, so it needs a key that isn’t read-only.
fact.set.
Authorization
Headers
Body
The assistant whose memory it goes into. Without it, no assistant will recall the fact.
Example
"agent": "my-assistant"
Example Request
{
"value": "America/Los_Angeles",
"fact_type": "timezone",
"agent": "my-assistant"
}
Response
Example Success Response
{
"fact_id": "e2d1c0b9-a8f7-4e6d-5c4b-3a2f1e0d9c8b",
"node": "5d1c3a52-8f1e-4b7e-9c0a-2a4f8e6b9d31",
"replaced": [],
"changed": true,
"fact_type": "timezone",
"retired": [],
"copied_to": []
}
Example cURL
cURL
curl --request POST 'https://composer.personal.ai/lab/api/v1/op/fact.set' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <your-api-key>' \
--data '{"value": "America/Los_Angeles", "fact_type": "timezone", "agent": "my-assistant"}'
Error Codes
| Code | Description |
|---|---|
| 400 | The body doesn’t match the fields above, or the operation failed. The response body says why. |
| 401 | Missing or invalid API key |
| 403 | This key isn’t allowed to call this operation (for example, a read-only key) |