API Reference

Create a new user

Sumary

Introduction

Welcome to the PsycoAI Enterprise API documentation! This API is all about AI Agents of all types. Whether you need emotional support agents or efficiency-boosting enterprise agents, our API has you covered. This guide will help you integrate our advanced features into your platform, including real-time chat, user management, and smart data collection via webhooks. Let's get started!

Key Features

Use Cases

<aside> 💡 For more details on the endpoints, see the https://psycoai.readme.io/reference/post_users

</aside>

Authentication

To access the PsycoAI Enterprise API endpoints, you need to authenticate using an API key provided by us. Include this key in the header of all your requests.

Example

curl --location '<http://backend.psyco.ai/enterprise/v1/users>' \\
--header 'api-key: {{your_key}}'

Authentication Errors

Agents

At PsycoAI, an agent is a system that uses a language model (LLM) to determine and execute a sequence of actions, either to provide personalized emotional support or automate operational workflows in companies. These agents, based on the Nebula Engine, integrate tools and chat models to perform specific tasks and continuously adjust their actions based on user needs. Agent autonomy can range from simple input routing to complex and continuous workflows.

<aside> 💡 To check which Agents your company can use, see https://psycoai.readme.io/reference/get_agents

</aside>

Chat

The chat allows users to interact with Agents through Text, Audio, or even Image messages. PsycoAI Chats, managed by the Nebula Engine, use the main strategies of Short and Long Term Memory, providing the best conversational experience.

Creating a Chat

To create a Chat, you only need a registered User and an available Agent. You can include your own identifier if you want.

curl --request POST \
     --url https://backend.psyco.ai/enterprise/v1/chats \
     --header 'accept: application/json' \
     --header 'api-key: {{your_key}}' \
     --header 'content-type: application/json' \
     --data '
{
  "userId": "{{user_id}}",
  "agentId": "{{agent_id}}",
  "externalIdentifier": "{{your_identifier}}"
}
'

Sending a Message and Receiving a Response

To send a message in a chat, just execute the POST below. You have the option to send a fileId in the body with the id of files that you have previously uploaded to https://psycoai.readme.io/reference/post_uploads.

curl --request POST \
     --url 'https://backend.psyco.ai/enterprise/v1/chats/{{chat_id}}/messages' \
     --header 'accept: application/json' \
     --header 'api-key: {{your_key}}' \
     --header 'content-type: application/json' \
     --data '{"message":"hello!"}'

Synchronous Response

To get the complete response in Json, just insert the header accept: application/json:

{
  "response": "string"
}

<aside> 💡 Use this mode if you can wait for the entire response to be generated.

</aside>

Streaming Response

To receive the response as it is created using streaming, just insert the header accept: text/event-stream. As you can imagine, the response in this case will be a text stream.

File Upload

File upload allows you to send files to our system. Currently, we only accept files in the following formats:

These files can be used for various purposes, such as attachments in conversations, support documents, or any other type of content relevant to user interaction.

Webhook

Webhooks are HTTP callbacks that allow your application to receive real-time notifications about events occurring in our API. Whenever a configured event occurs, the API sends an HTTP POST request to the URL specified in the webhook.

List of Events

user.registered
user.profile.updated
user.deleted
user.context-data.updated

chat.created
chat.deleted
chat.user-traits.updated
chat.user-insights.updated
chat.stage.updated

chat.message.sent
chat.message.received

file.uploaded

Event Schema

Configuration

To configure webhooks for specific events, use the endpoint https://psycoai.readme.io/reference/post_webhooks

Web Chat (Webview)

Get the Link

To create the link for accessing the Web Chat, you need to have a created chat. The HTTP request below will return a URL that should be used directly by the end customer to access our platform. Each generated URL is valid for 1 hour, and once accessed, the session is valid for 24 hours.

curl --request GET \
     --url 'https://backend.psyco.ai/enterprise/v1/auth/whitelabel/{{chat_id}}?partnerUrl={{your_url}}' \
     --header 'accept: application/json' \
     --header 'api-key: {{your_key}}'

<aside> 💡 You can send a URL in the "partnerUrl" query param so that the customer can return directly to your platform by clicking the "back" button.

</aside>

Standardization

API Response Format

Our API adheres to REST standards and uses JSON for content. On some endpoints, such as the Post Chats route and routes that involve file output, you'll have the option for a stream response. A successful request will return a 200 status code, while successful POST requests will return a 201 status code.

Pagination, Filtering and Sorting

For endpoints returning large datasets, you can use pagination and filtering to manage the data.

Pagination

Include the following parameters in your request:

Example:

curl --location 'https://backend.psyco.ai/enterprise/v1/users?page=2&limit=50' \
--header 'api-key: {{your_key}}'

Filtering

In some endpoints, you can filter results using query parameters. For instance, to filter chats by agentId:

Example:

curl --location 'https://backend.psyco.ai/enterprise/v1/chats?agentId={{agent_id}}' \
--header 'api-key: {{your_key}}'

Sorting

On some endpoints, you can sort the response by createdAt date in either ascending (ASC) or descending (DESC) order. Example:

curl --location 'https://backend.psyco.ai/enterprise/v1/chats?sort=ASC' \
--header 'api-key: {{your_key}}'

Rate Limiting

Our API has rate limiting to ensure fair usage. The limits are as follows:

Change Log