Skip to main content
POST
https://api.nexusgpt.io
/
api
/
public
/
thread
Create Session
curl --request POST \
  --url https://api.nexusgpt.io/api/public/thread \
  --header 'Content-Type: application/json' \
  --header 'api-key: <api-key>' \
  --data '
{
  "message": "<string>"
}
'
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-20T10:30:00Z"
}

Create Session

Creates a new chat session with your configured AI agent. This establishes a conversation thread that maintains context across multiple messages.

Endpoint

POST https://api.nexusgpt.io/api/public/thread

Authentication

api-key
string
required
Your Nexus API key for authentication

Request Body

message
string
Optional initial message to send to the agent when creating the session. This can help set the context for the conversation.
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-20T10:30:00Z"
}

Response Fields

id
string
required
Unique identifier for the created session. You’ll need this ID to send messages and retrieve conversation history.
createdAt
string
required
ISO 8601 timestamp indicating when the session was created

Example Usage

curl -X POST https://api.nexusgpt.io/api/public/thread \
  -H "Content-Type: application/json" \
  -H "api-key: YOUR_API_KEY"

Common Use Cases

1. Customer Support Bot

// Create a session for customer support
const session = await createSession(
  "Hello, I'm having trouble with my recent order #12345"
);

2. Product Assistant

// Create a session for product inquiries
const session = await createSession(
  "I'm looking for recommendations on running shoes for marathons"
);

3. Technical Support

// Create a session for technical assistance
const session = await createSession(
  "My application is showing an error when I try to export data"
);

Error Responses

{
  "statusCode": 401,
  "message": "Invalid API key",
  "error": "Unauthorized"
}

Best Practices

  • Sessions remain active for 24 hours of inactivity
  • Reuse sessions for continued conversations
  • Create new sessions for unrelated topics
  • Store session IDs securely in your application
  • Use initial messages to provide context
  • Include relevant details upfront
  • Set clear expectations for the conversation
  • Avoid sensitive information in initial messages
  • Always check for error responses
  • Implement retry logic for transient failures
  • Log session IDs for debugging
  • Have fallback behavior for session creation failures