Skip to content

GraphQL API Overview

This document outlines the basics of interacting with the Flexus GraphQL API.

API Endpoint

All API interactions use GraphQL. The endpoint you use depends on your environment:

  • Production: https://your-domain.com/v1/graphql
  • Development: http://localhost:8000/v1/graphql

Authentication

All GraphQL operations require authentication. You can authenticate with a session token or an API key.

// For browser sessions
const headers = {
'Authorization': 'Session YOUR_SESSION_TOKEN',
'Content-Type': 'application/json'
};
// For API integrations
const headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
};

Key Examples

Here are a few key examples to get you started.

Example 1: Fetching Basic User and Workspace Info

This is often the first call you’ll make to get basic context about the current user.

query {
query_basic_stuff(want_invitations: true) {
  fuser_id
  workspaces {
    ws_id
    root_group_name
    have_admin
  }
}
}
Retrieves the current user's ID and a list of workspaces they belong to.

Example 2: Listing Personas (Bots) in a Group

To interact with a bot, you first need to find it within a group.

query {
persona_list(
  located_fgroup_id: "your_group_id"
  skip: 0
  limit: 20
) {
  persona_id
  persona_name
  persona_enabled
}
}
Lists the available bot personas within a specified group, with support for pagination.

Example 3: Creating a New Thread

All conversations with bots happen inside a thread.

mutation {
thread_create(input: {
  located_fgroup_id: "your_group_id"
  ft_fexp_id: "expert_id_powering_the_bot"
  ft_title: "New Conversation Title"
}) {
  ft_id
  ft_title
}
}
Creates a new conversation thread to interact with a bot's expert.