Upsert User Profiles
curl --request POST \
--url https://api.gurubase.io/api/v1/{guru_slug}/profiles/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"users": [
{
"external_user_id": "<string>",
"memory": {}
}
]
}
'import requests
url = "https://api.gurubase.io/api/v1/{guru_slug}/profiles/"
payload = { "users": [
{
"external_user_id": "<string>",
"memory": {}
}
] }
headers = {
"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-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({users: [{external_user_id: '<string>', memory: {}}]})
};
fetch('https://api.gurubase.io/api/v1/{guru_slug}/profiles/', 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.gurubase.io/api/v1/{guru_slug}/profiles/",
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([
'users' => [
[
'external_user_id' => '<string>',
'memory' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://api.gurubase.io/api/v1/{guru_slug}/profiles/"
payload := strings.NewReader("{\n \"users\": [\n {\n \"external_user_id\": \"<string>\",\n \"memory\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.gurubase.io/api/v1/{guru_slug}/profiles/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"users\": [\n {\n \"external_user_id\": \"<string>\",\n \"memory\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gurubase.io/api/v1/{guru_slug}/profiles/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"users\": [\n {\n \"external_user_id\": \"<string>\",\n \"memory\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"total_users": 2,
"processed_users": 2,
"users_results": [
{
"user_index": 0,
"external_user_id": "user1-id",
"success": true,
"errors": []
},
{
"user_index": 1,
"external_user_id": "user2-id",
"success": true,
"errors": []
}
]
}
{
"error": "Failed to process some users",
"details": [],
"users_results": [
{
"user_index": 0,
"external_user_id": "user1-id",
"success": false,
"errors": [
"Missing memory data"
]
},
{
"user_index": 1,
"external_user_id": "user2-id",
"success": true,
"errors": []
}
]
}
{
"msg": "Invalid API key"
}
{
"msg": "Forbidden"
}
{
"msg": "Guru type my-guru not found"
}
{
"msg": "Request was throttled. Expected available in 56 seconds."
}
{
"error": "Internal server error while saving profiles"
}
Endpoints
Upsert User Profiles
Upsert one or more user profiles with their memory data.
POST
/
{guru_slug}
/
profiles
/
Upsert User Profiles
curl --request POST \
--url https://api.gurubase.io/api/v1/{guru_slug}/profiles/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"users": [
{
"external_user_id": "<string>",
"memory": {}
}
]
}
'import requests
url = "https://api.gurubase.io/api/v1/{guru_slug}/profiles/"
payload = { "users": [
{
"external_user_id": "<string>",
"memory": {}
}
] }
headers = {
"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-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({users: [{external_user_id: '<string>', memory: {}}]})
};
fetch('https://api.gurubase.io/api/v1/{guru_slug}/profiles/', 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.gurubase.io/api/v1/{guru_slug}/profiles/",
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([
'users' => [
[
'external_user_id' => '<string>',
'memory' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://api.gurubase.io/api/v1/{guru_slug}/profiles/"
payload := strings.NewReader("{\n \"users\": [\n {\n \"external_user_id\": \"<string>\",\n \"memory\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.gurubase.io/api/v1/{guru_slug}/profiles/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"users\": [\n {\n \"external_user_id\": \"<string>\",\n \"memory\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gurubase.io/api/v1/{guru_slug}/profiles/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"users\": [\n {\n \"external_user_id\": \"<string>\",\n \"memory\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"total_users": 2,
"processed_users": 2,
"users_results": [
{
"user_index": 0,
"external_user_id": "user1-id",
"success": true,
"errors": []
},
{
"user_index": 1,
"external_user_id": "user2-id",
"success": true,
"errors": []
}
]
}
{
"error": "Failed to process some users",
"details": [],
"users_results": [
{
"user_index": 0,
"external_user_id": "user1-id",
"success": false,
"errors": [
"Missing memory data"
]
},
{
"user_index": 1,
"external_user_id": "user2-id",
"success": true,
"errors": []
}
]
}
{
"msg": "Invalid API key"
}
{
"msg": "Forbidden"
}
{
"msg": "Guru type my-guru not found"
}
{
"msg": "Request was throttled. Expected available in 56 seconds."
}
{
"error": "Internal server error while saving profiles"
}
This endpoint allows you to create or update user profiles in bulk. It is an idempotent operation, meaning you can safely retry requests without creating duplicate profiles.
Path Parameters
string
required
The slug of the Guru to which the profiles belong.
Headers
string
required
Your API key for authentication. You can obtain your API key from the Gurubase dashboard.
Body Parameters
object[]
required
An array of user profile objects to upsert.
Show User Object Properties
Show User Object Properties
Example Request
{
"users": [
{
"external_user_id": "user1-id",
"memory": {
"name": "John Doe",
"email": "[email protected]"
}
},
{
"external_user_id": "user2-id",
"memory": {
"name": "Jane Doe",
"plan": "premium"
}
}
]
}
Response
The response provides a detailed breakdown of the upsert operation.string
Indicates the overall status of the request. Will be “success” if the request was accepted and partially or fully processed.
number
The total number of users in the request payload.
number
The number of users successfully processed.
array
An array of result objects, one for each user in the request, in the same order.
{
"status": "success",
"total_users": 2,
"processed_users": 2,
"users_results": [
{
"user_index": 0,
"external_user_id": "user1-id",
"success": true,
"errors": []
},
{
"user_index": 1,
"external_user_id": "user2-id",
"success": true,
"errors": []
}
]
}
{
"error": "Failed to process some users",
"details": [],
"users_results": [
{
"user_index": 0,
"external_user_id": "user1-id",
"success": false,
"errors": [
"Missing memory data"
]
},
{
"user_index": 1,
"external_user_id": "user2-id",
"success": true,
"errors": []
}
]
}
{
"msg": "Invalid API key"
}
{
"msg": "Forbidden"
}
{
"msg": "Guru type my-guru not found"
}
{
"msg": "Request was throttled. Expected available in 56 seconds."
}
{
"error": "Internal server error while saving profiles"
}
Was this page helpful?
⌘I