Documents

Code Examples for Alchemyst Context API

## Adding Context Data to Alchemyst Context Processor



The `POST /api/v1/context/add` endpoint allows you to add context data such as user ID, organization ID, documents, source information, context type, scope, and metadata. Below is an example of how to add context data using the curl command:



```bash

curl --request POST \ 

  --url https://api.alchemyst.ai/api/v1/context/add \ 

  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ 

  --header 'Content-Type: application/json' \ 

  --data '{

    "user_id": "user123", 



    "organization_id": "org456", 



    "documents": [{



        "content": "Document text here"



    }], 



    "source": "Zoom API", 



    "context_type": "conversation", 



    "scope": "internal", 



    "metadata": {



        "key": "value"



    } 



}'

Deleting Context Data from Alchemyst Context Processor

The POST /api/v1/context/delete endpoint allows you to delete context data based on various parameters including source, user ID, and flags for document deletion or ID deletion. Below is an example using the curl command:

curl --request POST \ 

  --url https://api.alchemyst.ai/api/v1/context/delete \ 

  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ 

  --header 'Content-Type: application/json' \ 

  --data '{



    "source": "Zoom API", 



    "user_id": "user123", 



    "by_doc": true 



}'

Searching Context Data in Alchemyst Context Processor

The POST /api/v1/context/search endpoint allows you to search for context data in the context processor based on a query ensuring relevance and similarity thresholds. Below is an example of issuing a search query:

curl --request POST \ 

  --url https://api.alchemyst.ai/api/v1/context/search \ 

  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ 

  --header 'Content-Type: application/json' \ 

  --data '{

    "query": "Zoom meetings",

    "similarity_threshold": 0.8,

    "minimum_similarity_threshold": 0.5,

    "scope": "internal"

}'

Retrieving User Contexts by Document

The GET /api/v1/context/view/docs endpoint allows you to retrieve documents view for the authenticated user optionally with organization context:

curl --request GET \ 

  --url https://api.alchemyst.ai/api/v1/context/view/docs \ 

  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Viewing User Contexts

The GET /api/v1/context/view endpoint retrieves the context information for the authenticated user:

curl --request GET \ 

  --url https://api.alchemyst.ai/api/v1/context/view \ 

  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Note: Replace YOUR_ACCESS_TOKEN with your actual Alchemyst API token obtained from the authentication process.



Make sure you have the necessary permissions and security measures in place when using these APIs.