Skip to main content
POST
/
contexts
Save context
curl --request POST \
  --url https://apigcp.trynia.ai/v2/contexts \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "title": "<string>",
  "summary": "<string>",
  "content": "<string>",
  "agent_source": "<string>",
  "tags": [
    "<string>"
  ],
  "metadata": {},
  "organization_id": "<string>",
  "nia_references": {
    "indexed_resources": [
      {
        "identifier": "<string>",
        "resource_type": "<string>",
        "purpose": "<string>",
        "indexed_at": "<string>"
      }
    ],
    "search_queries": [
      {
        "query": "<string>",
        "query_type": "<string>",
        "key_findings": "<string>",
        "resources_searched": [
          "<string>"
        ],
        "useful_results_count": 0
      }
    ],
    "session_summary": "<string>"
  },
  "edited_files": [
    {
      "file_path": "<string>",
      "operation": "<string>",
      "changes_description": "<string>",
      "key_changes": [
        "<string>"
      ],
      "language": "<string>"
    }
  ],
  "memory_type": "episodic",
  "ttl_seconds": 1,
  "lineage": {
    "source_ids": [
      "<string>"
    ],
    "confidence": 0.5,
    "derived_from": [
      "<string>"
    ],
    "tool_calls": [
      "<string>"
    ],
    "model_version": "<string>"
  }
}
'
import requests

url = "https://apigcp.trynia.ai/v2/contexts"

payload = {
"title": "<string>",
"summary": "<string>",
"content": "<string>",
"agent_source": "<string>",
"tags": ["<string>"],
"metadata": {},
"organization_id": "<string>",
"nia_references": {
"indexed_resources": [
{
"identifier": "<string>",
"resource_type": "<string>",
"purpose": "<string>",
"indexed_at": "<string>"
}
],
"search_queries": [
{
"query": "<string>",
"query_type": "<string>",
"key_findings": "<string>",
"resources_searched": ["<string>"],
"useful_results_count": 0
}
],
"session_summary": "<string>"
},
"edited_files": [
{
"file_path": "<string>",
"operation": "<string>",
"changes_description": "<string>",
"key_changes": ["<string>"],
"language": "<string>"
}
],
"memory_type": "episodic",
"ttl_seconds": 1,
"lineage": {
"source_ids": ["<string>"],
"confidence": 0.5,
"derived_from": ["<string>"],
"tool_calls": ["<string>"],
"model_version": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: '<string>',
summary: '<string>',
content: '<string>',
agent_source: '<string>',
tags: ['<string>'],
metadata: {},
organization_id: '<string>',
nia_references: {
indexed_resources: [
{
identifier: '<string>',
resource_type: '<string>',
purpose: '<string>',
indexed_at: '<string>'
}
],
search_queries: [
{
query: '<string>',
query_type: '<string>',
key_findings: '<string>',
resources_searched: ['<string>'],
useful_results_count: 0
}
],
session_summary: '<string>'
},
edited_files: [
{
file_path: '<string>',
operation: '<string>',
changes_description: '<string>',
key_changes: ['<string>'],
language: '<string>'
}
],
memory_type: 'episodic',
ttl_seconds: 1,
lineage: {
source_ids: ['<string>'],
confidence: 0.5,
derived_from: ['<string>'],
tool_calls: ['<string>'],
model_version: '<string>'
}
})
};

fetch('https://apigcp.trynia.ai/v2/contexts', 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://apigcp.trynia.ai/v2/contexts",
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([
'title' => '<string>',
'summary' => '<string>',
'content' => '<string>',
'agent_source' => '<string>',
'tags' => [
'<string>'
],
'metadata' => [

],
'organization_id' => '<string>',
'nia_references' => [
'indexed_resources' => [
[
'identifier' => '<string>',
'resource_type' => '<string>',
'purpose' => '<string>',
'indexed_at' => '<string>'
]
],
'search_queries' => [
[
'query' => '<string>',
'query_type' => '<string>',
'key_findings' => '<string>',
'resources_searched' => [
'<string>'
],
'useful_results_count' => 0
]
],
'session_summary' => '<string>'
],
'edited_files' => [
[
'file_path' => '<string>',
'operation' => '<string>',
'changes_description' => '<string>',
'key_changes' => [
'<string>'
],
'language' => '<string>'
]
],
'memory_type' => 'episodic',
'ttl_seconds' => 1,
'lineage' => [
'source_ids' => [
'<string>'
],
'confidence' => 0.5,
'derived_from' => [
'<string>'
],
'tool_calls' => [
'<string>'
],
'model_version' => '<string>'
]
]),
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://apigcp.trynia.ai/v2/contexts"

payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"summary\": \"<string>\",\n \"content\": \"<string>\",\n \"agent_source\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {},\n \"organization_id\": \"<string>\",\n \"nia_references\": {\n \"indexed_resources\": [\n {\n \"identifier\": \"<string>\",\n \"resource_type\": \"<string>\",\n \"purpose\": \"<string>\",\n \"indexed_at\": \"<string>\"\n }\n ],\n \"search_queries\": [\n {\n \"query\": \"<string>\",\n \"query_type\": \"<string>\",\n \"key_findings\": \"<string>\",\n \"resources_searched\": [\n \"<string>\"\n ],\n \"useful_results_count\": 0\n }\n ],\n \"session_summary\": \"<string>\"\n },\n \"edited_files\": [\n {\n \"file_path\": \"<string>\",\n \"operation\": \"<string>\",\n \"changes_description\": \"<string>\",\n \"key_changes\": [\n \"<string>\"\n ],\n \"language\": \"<string>\"\n }\n ],\n \"memory_type\": \"episodic\",\n \"ttl_seconds\": 1,\n \"lineage\": {\n \"source_ids\": [\n \"<string>\"\n ],\n \"confidence\": 0.5,\n \"derived_from\": [\n \"<string>\"\n ],\n \"tool_calls\": [\n \"<string>\"\n ],\n \"model_version\": \"<string>\"\n }\n}")

req, _ := http.NewRequest("POST", 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.post("https://apigcp.trynia.ai/v2/contexts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"summary\": \"<string>\",\n \"content\": \"<string>\",\n \"agent_source\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {},\n \"organization_id\": \"<string>\",\n \"nia_references\": {\n \"indexed_resources\": [\n {\n \"identifier\": \"<string>\",\n \"resource_type\": \"<string>\",\n \"purpose\": \"<string>\",\n \"indexed_at\": \"<string>\"\n }\n ],\n \"search_queries\": [\n {\n \"query\": \"<string>\",\n \"query_type\": \"<string>\",\n \"key_findings\": \"<string>\",\n \"resources_searched\": [\n \"<string>\"\n ],\n \"useful_results_count\": 0\n }\n ],\n \"session_summary\": \"<string>\"\n },\n \"edited_files\": [\n {\n \"file_path\": \"<string>\",\n \"operation\": \"<string>\",\n \"changes_description\": \"<string>\",\n \"key_changes\": [\n \"<string>\"\n ],\n \"language\": \"<string>\"\n }\n ],\n \"memory_type\": \"episodic\",\n \"ttl_seconds\": 1,\n \"lineage\": {\n \"source_ids\": [\n \"<string>\"\n ],\n \"confidence\": 0.5,\n \"derived_from\": [\n \"<string>\"\n ],\n \"tool_calls\": [\n \"<string>\"\n ],\n \"model_version\": \"<string>\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://apigcp.trynia.ai/v2/contexts")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"<string>\",\n \"summary\": \"<string>\",\n \"content\": \"<string>\",\n \"agent_source\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {},\n \"organization_id\": \"<string>\",\n \"nia_references\": {\n \"indexed_resources\": [\n {\n \"identifier\": \"<string>\",\n \"resource_type\": \"<string>\",\n \"purpose\": \"<string>\",\n \"indexed_at\": \"<string>\"\n }\n ],\n \"search_queries\": [\n {\n \"query\": \"<string>\",\n \"query_type\": \"<string>\",\n \"key_findings\": \"<string>\",\n \"resources_searched\": [\n \"<string>\"\n ],\n \"useful_results_count\": 0\n }\n ],\n \"session_summary\": \"<string>\"\n },\n \"edited_files\": [\n {\n \"file_path\": \"<string>\",\n \"operation\": \"<string>\",\n \"changes_description\": \"<string>\",\n \"key_changes\": [\n \"<string>\"\n ],\n \"language\": \"<string>\"\n }\n ],\n \"memory_type\": \"episodic\",\n \"ttl_seconds\": 1,\n \"lineage\": {\n \"source_ids\": [\n \"<string>\"\n ],\n \"confidence\": 0.5,\n \"derived_from\": [\n \"<string>\"\n ],\n \"tool_calls\": [\n \"<string>\"\n ],\n \"model_version\": \"<string>\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "user_id": "<string>",
  "title": "<string>",
  "summary": "<string>",
  "content": "<string>",
  "tags": [
    "<string>"
  ],
  "agent_source": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "metadata": {},
  "organization_id": "<string>",
  "updated_at": "2023-11-07T05:31:56Z",
  "nia_references": {
    "indexed_resources": [
      {
        "identifier": "<string>",
        "resource_type": "<string>",
        "purpose": "<string>",
        "indexed_at": "<string>"
      }
    ],
    "search_queries": [
      {
        "query": "<string>",
        "query_type": "<string>",
        "key_findings": "<string>",
        "resources_searched": [
          "<string>"
        ],
        "useful_results_count": 0
      }
    ],
    "session_summary": "<string>"
  },
  "edited_files": [
    {
      "file_path": "<string>",
      "operation": "<string>",
      "changes_description": "<string>",
      "key_changes": [
        "<string>"
      ],
      "language": "<string>"
    }
  ],
  "memory_type": "episodic",
  "expires_at": "2023-11-07T05:31:56Z",
  "lineage": {
    "created_at": "2023-11-07T05:31:56Z",
    "source_ids": [
      "<string>"
    ],
    "confidence": 123,
    "derived_from": [
      "<string>"
    ],
    "tool_calls": [
      "<string>"
    ],
    "model_version": "<string>"
  },
  "category_id": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

API key must be provided in the Authorization header

Body

application/json

Request model for creating a shared context.

title
string
required
Required string length: 1 - 200
summary
string
required
Required string length: 10 - 1000
content
string
required
Minimum string length: 50
agent_source
string
required

Which agent created this context

tags
string[]
metadata
Metadata · object
organization_id
string | null
nia_references
NiaReferences · object | null

Structured tracking of NIA resources used during conversation.

edited_files
EditedFile · object[]
memory_type
enum<string>
default:episodic

Memory type: scratchpad (1hr), episodic (7d), fact (permanent), procedural (permanent)

Available options:
scratchpad,
episodic,
fact,
procedural
ttl_seconds
integer | null

Custom TTL in seconds. If not set, uses memory_type default.

Required range: x >= 0
lineage
LineageInput · object | null

Provenance tracking for this context

Response

Successful Response

Response model for context operations.

id
string
required
user_id
string
required
title
string
required
summary
string
required
content
string
required
tags
string[]
required
agent_source
string
required
created_at
string<date-time>
required
metadata
Metadata · object
required
organization_id
string | null
updated_at
string<date-time> | null
nia_references
NiaReferences · object | null

Structured tracking of NIA resources used during conversation.

edited_files
EditedFile · object[]
memory_type
enum<string>
default:episodic
Available options:
scratchpad,
episodic,
fact,
procedural
expires_at
string<date-time> | null
lineage
LineageMetadata · object | null

Provenance tracking for content artifacts.

category_id
string | null