A RESTful API for managing context data including adding, searching, deleting, and viewing context information with user and organization-level access control.
All endpoints require Bearer token authentication. Include the token in the Authorization header:
Authorization: Bearer <your-token>
https://platform-backend.getalchemystai.com/api/v1/context
POST /api/v1/context/add
Adds context data to the context processor for further handling.
Field | Type | Required | Description |
---|---|---|---|
user_id |
string | No | Unique identifier of the user |
organization_id |
string | No | Organization ID (nullable) |
documents |
array | No | Array of document objects with content and metadata |
source |
string | No | Source of the context data |
context_type |
string | No | Type: resource , conversation , or instruction |
scope |
string | No | Scope: internal or external (default: internal ) |
metadata |
object | No | Additional metadata (default: {} ) |
chained |
boolean | No | To be chained or not |
{
"content": "string",
"fileName": "string",
"fileType": "string",
"fileSize": "number",
"lastModified": "string",
}
Status | Description |
---|---|
201 |
Context added successfully |
400 |
Invalid or missing context data |
401 |
User not authenticated |
500 |
Internal server error |
POST /api/v1/context/search
Searches for context data based on similarity thresholds and query parameters.
Field | Type | Required | Description |
---|---|---|---|
user_id |
string | No | ID of the user making the request |
query |
string | Yes | Search query string |
similarity_threshold |
number | Yes | Maximum similarity threshold (0-1) |
minimum_similarity_threshold |
number | Yes | Minimum similarity threshold (0-1) |
scope |
string | No | Search scope: internal or external (default: internal ) |
metadata |
object | No | Additional search metadata (default: {} ) |
Status | Description |
---|---|
202 |
Search request processed successfully |
400 |
Invalid or missing search parameters |
500 |
Internal server error |
{
"results": [
{
"contextId": "string",
"contextData": "string"
}
]
}
POST /api/v1/context/delete
Deletes context data based on specified parameters.
Field | Type | Required | Description |
---|---|---|---|
source |
string | No | Source identifier for the context |
user_id |
string | No | User ID (nullable) |
organization_id |
string | No | Organization ID (nullable) |
by_doc |
boolean | No | Delete by document (default: true ) |
by_id |
boolean | No | Delete by ID (default: false ) |
Status | Description |
---|---|
204 |
Successfully deleted context |
400 |
Invalid request parameters |
401 |
User not authenticated |
403 |
User lacks required permissions |
500 |
Internal server error |
GET /api/v1/context/view
Retrieves context information for the authenticated user.
Status | Description |
---|---|
200 |
Successfully retrieved context |
401 |
User not authenticated |
403 |
User lacks required scope |
500 |
Internal server error |
{
"context": [
{
"_id": "string",
"user_id": "string",
"organization_id": "string | null",
"parent_context_nodes": ["string"],
"children_context_nodes": ["string"],
"context_type": "string",
"tags": ["string"],
"source": "string",
"content": "object | string",
"blob": "any | null",
"indexed": "boolean",
"indexable": "boolean",
"governing_policies": "string | array | null",
"override_policy": "boolean",
"telemetry_data": "object",
"createdAt": "string (ISO 8601 timestamp)",
"updatedAt": "string (ISO 8601 timestamp)",
"scopes": ["string"],
"metadata": {
"size": "number",
"file_name": "string",
"doc_type": "string",
"modalities": ["string"]
},
"corresponding_vector_id": "string",
"text": "string",
"score": "number"
}
]
}
GET /api/v1/context/view/docs
Retrieves documents view for the authenticated user with optional organization context.
Status | Description |
---|---|
200 |
Successfully retrieved documents view |
401 |
User not authenticated |
402 |
Invalid user |
403 |
User lacks required scope |
default |
Unexpected error from context processor |
{
"response": "Error message with details",
"error": "Error type"
}
curl -X POST https://platform-backend.getalchemystai.com/api/v1/context/add \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"documents": [
{
"content": "User preferences for AI interactions"
}
],
"source": "platform/maya/smart-settings.upload",
"context_type": "resource",
"chained": "false",
"scope": "internal",
"metadata": {
"file_name" : "Name of file",
"doc_type" : "Type of file",
"modalities": "['text', 'image']",
size : "Size of file"
}
}'
const response = await fetch('https://platform-backend.getalchemystai.com/api/v1/context/add', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
documents: [
{
content: "User preferences for AI interactions"
}
],
source: "platform/maya/smart-settings.upload",
context_type: "resource",
chained: "false",
scope: "internal",
metadata: {
file_name: "Name of file",
doc_type: "Type of file",
modalities: "['text', 'image']",
size: "Size of file"
}
})
});
const result = await response.json();
console.log(result);
import requests
url = 'https://platform-backend.getalchemystai.com/api/v1/context/add'
headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
}
data = {
"documents": [
{
"content": "User preferences for AI interactions"
}
],
"source": "platform/maya/smart-settings.upload",
"context_type": "resource",
"chained": "false",
"scope": "internal",
"metadata": {
"file_name": "Name of file",
"doc_type": "Type of file",
"modalities": "['text', 'image']",
"size": "Size of file"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
curl -X POST https://platform-backend.getalchemystai.com/api/v1/context/search \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"query": "user preferences",
"similarity_threshold": 0.8,
"minimum_similarity_threshold": 0.5,
"scope": "internal",
"metadata": {}
}'
const response = await fetch('https://platform-backend.getalchemystai.com/api/v1/context/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: "user preferences",
similarity_threshold: 0.8,
minimum_similarity_threshold: 0.5,
scope: "internal",
metadata: {}
})
});
const searchResults = await response.json();
console.log(searchResults);
import requests
url = 'https://platform-backend.getalchemystai.com/api/v1/context/search'
headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
}
data = {
"query": "user preferences",
"similarity_threshold": 0.8,
"minimum_similarity_threshold": 0.5,
"scope": "internal",
"metadata": {}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
curl -X POST https://platform-backend.getalchemystai.com/api/v1/context/delete \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"source": "file Name",
"by_doc": true,
"by_id" : false
}'
const response = await fetch('https://platform-backend.getalchemystai.com/api/v1/context/delete', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
source: "file Name",
by_doc: true,
by_id: false
})
});
// 204 status code indicates successful deletion with no content
if (response.status === 204) {
console.log('Context deleted successfully');
}
import requests
url = 'https://platform-backend.getalchemystai.com/api/v1/context/delete'
headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
}
data = {
"source": "file Name",
"by_doc": True,
"by_id": False
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 204:
print('Context deleted successfully')
curl -X GET https://platform-backend.getalchemystai.com/api/v1/context/view \
-H "Authorization: Bearer <token>"
const response = await fetch('https://platform-backend.getalchemystai.com/api/v1/context/view', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
const contextData = await response.json();
console.log(contextData);
import requests
url = 'https://platform-backend.getalchemystai.com/api/v1/context/view'
headers = {
'Authorization': 'Bearer <token>'
}
response = requests.get(url, headers=headers)
print(response.json())
curl -X GET https://platform-backend.getalchemystai.com/api/v1/context/view/docs \
-H "Authorization: Bearer <token>"
const response = await fetch('https://platform-backend.getalchemystai.com/api/v1/context/view/docs', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
const documents = await response.json();
console.log(documents);
import requests
url = 'https://platform-backend.getalchemystai.com/api/v1/context/view/docs'
headers = {
'Authorization': 'Bearer <token>'
}
response = requests.get(url, headers=headers)
print(response.json())
similarity_threshold
>= minimum_similarity_threshold
resource
, conversation
, instruction
internal
, external