Blueprint AI · API Reference · v1

GraphQL API

A single GraphQL endpoint to integrate your application with the behavioral well-being platform: accounts, student data, AI analysis, risk intelligence, and notifications. This guide covers both authentication modes and every operation available to external consumers.

Protocol · GraphQL over HTTPS Subscriptions · WebSocket Format · JSON
Every interaction happens against a single GraphQL endpoint. Send a query, mutation, or subscription in the request body; the required credential type is indicated per operation with an authorization label.

Endpoint & transport

Your provider gives you the base URL for your environment. Replace <your-host> with that value.

ResourceMethodURL
GraphQLPOSThttps://<your-host>/graphql
SubscriptionsWebSocketwss://<your-host>/graphql
healthQuerypublic · returns "ok"
# Typical request
POST https://<your-host>/graphql
Content-Type: application/json
Authorization: Bearer <JWT>      # for user auth
X-Api-Key: sk-agth-…-<tenant>-v1   # or server-to-server auth

{ "query": "query { account { id agreement_free } }" }

Authentication

Each field declares which credential it accepts. There are two credentials and four access modes.

The two credentials

CredentialHeaderFor
JWT Authorization: Bearer <token> End users (web/mobile apps). Short-lived access token (~15 min) obtained via login/signup and renewable with refreshToken.
API Key X-Api-Key: sk-agth-<32>-<tenant>-v1 Server-to-server integrations. The key is bound to a tenant; the tenant is inferred from the key itself. Generated with createApiKey and shown only once.

The four access modes

NO_USER

Public endpoints (login, signup). The request is rejected if it arrives already authenticated.

USER

Requires a valid JWT. The user and their tenant are extracted from the token.

API

Requires a valid API Key. Intended for server-to-server processes.

USER_OR_API

Accepts either credential: the API Key is tried first, falling back to the JWT.

Tenant isolation. Every operation is isolated to the credential's tenant. An API Key or a JWT can only see and modify data within its own tenant.

Session lifecycle (JWT)

  • login / signup return { token, refresh_token, user_id, tenant }.
  • The token expires after ~15 min; use refreshToken(refresh_token) to get a fresh pair without re-login (the refresh lasts ~30 days and rotates on each use).
  • logout(refresh_token) ends the session: it invalidates the access token and stops the refresh from rotating.
  • Reusing an already-rotated refresh invalidates the entire session (anti-theft protection).

Errors & conventions

  • Pagination: lists use cursors — page_size + page_token; the response includes the next token.
  • Deletion: most delete* operations are soft-deletes (they set a timestamp, they don't physically remove the record).
  • Amounts: the Int64 scalar represents the minor unit (e.g. cents).
  • Errors: returned in GraphQL's standard errors array. A downstream billing failure propagates as PAYMENT_UNAVAILABLE.

Auth & API Keys

Authentication, registration, and API key management.

OperationTypeAuthArgumentsDescription
accountQueryUSER_OR_APICurrent account info (id, agreement_free).
loginMutNO_USERemail, passwordAuthenticates and returns an AuthPayload (token + refresh + user_id + tenant).
signupMutNO_USERemail, password, nameRegisters a user and returns a ready-to-use token pair.
refreshTokenMutNO_USERrefresh_tokenRotates the refresh and returns a new access + refresh.
logoutMutUSERrefresh_tokenEnds the current session and invalidates the access token.
validateTokenMutUSER_OR_APIValidates the current credential and returns user/tenant info.
createApiKeyMutUSERGenerates an API Key for the user. Shown only once.
validateApiKeyMutUSER_OR_APIapi_keyValidates an API Key and returns { valid, tenant, id, user }.
revokeApiKeyMutUSERapi_keyRevokes an API Key for the tenant (takes effect immediately).
signupCanvasMutNO_USERltiTokenOnboards a school admin from a Canvas LTI 1.3 launch. Idempotent per deployment.
API Key format: sk-agth-<32 characters>-<tenant-uuid>-v1. The tenant is embedded in the key itself.

Payments & Billing

Internal balance, transactions, and payment methods (Stripe).

OperationTypeAuthArgumentsDescription
getBalanceQueryUSER_OR_APIuser_idCurrent balance (current_balance, currency).
listTransactionsQueryUSERuser_id, page_size?, page_token?, start_time?, end_time?Paginated list of transactions with time filters.
getTransactionQueryUSERtransaction_idDetail of a single transaction.
getBillingSettingQueryUSERThe tenant's billing settings.
paymentAccountQueryUSERThe user's Stripe account.
updateBalanceMutUSERamount, metadata?Adjusts the balance (credit/debit).
createBillingSettingMutUSERauto_charge_amount?, paid_limit?, not_paid_limit?Creates the billing settings.
updateBillingSettingMutUSERauto_charge_amount, paid_limit, not_paid_limitReplaces the billing settings.
createPaymentAccountMutUSERemail, id, nameCreates a Stripe Customer.
createCardMutUSERcvc, exp_month, exp_year, number, token?Attaches a card to the account.

Activity Ingestor

CRUD across 8 student behavioral-data domains. Uniform pattern per domain: get, list, create, update, delete · all USER_OR_API.

All list* operations accept user?, page_size?, page_token?. Each create* takes user (UUID) plus the domain-specific fields.

DomainOperationsRepresentative create fields
JournalgetJournal · listJournals · createJournal · updateJournal · deleteJournaltitle, content, mood?, tags?
RiskHistoryget · list · create · update · deleterisk_level, risk_type, flagged, severity, resolved_at?
SleepProfileget · list · create · update · deletehours_slept, quality, bed_time
WinGratitudeget · list · create · update · deletetype, title, category, shared_with?
TrustedPersonget · list · create · update · deletename, relationship, priority?, available?
MiniSurveyget · list · create · update · deletesurvey_type, responses[], score?, category?
SchoolInfoget · list · create · update · deleteschool_name, grade, subjects, grades[], attendance?
PersonalGoalget · list · create · update · deletetitle, status, target_date?, milestones[]

Analysis & Mood

Inference rules, the AI pipeline, analysis results, and emotional state.

Rules & inference

OperationTypeAuthDescription
getRule · listRulesQueryUSER_OR_APIGet/list inference rules.
runInferenceQueryUSER_OR_APIRuns the inference pipeline (consumes tokens/billing).
createRule · updateRule · deleteRuleMutUSER_OR_APIRule CRUD.
testModelsMutUSER_OR_APITest suite across a list of models.

Analysis & feedback

OperationTypeAuthDescription
getAnalysis · listAnalysesQueryUSER_OR_APIGet/list analyses (filters: model, user, score, dates).
getAnalysisFromLLMSQueryUSERAnalyses run across multiple LLMs.
getFeedback · listFeedbacksQueryUSERHuman feedback on analyses.
createAnalysisMutUSER_OR_APICreates an analysis (user, text, context, model?).
createAnalysisFromLLMSMutUSER_OR_APICreates an analysis running several LLMs (consumes billing).
updateAnalysis · deleteAnalysisMutUSERPartial update / delete.
createFeedback · updateFeedback · deleteFeedbackMutUSERManage human feedback.

Mood

OperationTypeAuthDescription
listMoods · listMoodCategoriesQueryUSER_OR_APIMood catalog and categories.
getMoodQueryUSERGet a catalog mood by ID.
getMoodHistory · listMoodHistoryQueryUSER_OR_APIStudent mood history (filters: user, mood).
createMoodHistory · updateMoodHistory · deleteMoodHistoryMutUSER_OR_APIRecords mood entries (list of MoodEntry + note).
createMood · updateMood · deleteMoodMutUSERManage the mood catalog (label, color, tips, video, category).

Chat (streaming)

Chat with the AI agent. Responses arrive streamed over a WebSocket subscription.

Flow: startSession → subscribe to chatMessages(session_id)sendChatMessage. The agent's chunks are emitted over the subscription.

OperationTypeAuthArgumentsDescription
startTestMutUSER_OR_APIuserTest session (not persisted).
startSessionMutUSER_OR_APIuserCreates a real chat session.
sendChatMessageMutUSER_OR_APImessage, session_id, user, metadata?Sends a message; confirms immediately (the reply arrives over the subscription).
chatMessagesSubUSER_OR_APIsession_idStream of ChatChunk (chunk, is_last, inferenceOutput?). One connection per session.
WebSocket auth: when opening the connection (ConnectionInit), you can pass the API Key in the payload under the X-Api-Key key.

Knowledge Graph

The person's behavioral knowledge graph: identity, events, consent, snapshots, connectors, and trust.

Event ingestion and connector/consent administration are API (server-to-server). Reads and student-facing CRUD are USER_OR_API.

Person

OperationTypeAuthDescription
personQueryUSER_OR_APIGet a person by ID.
personsQueryAPIPaginated list of persons.
resolvePersonMutUSER_OR_APIResolves or creates a person from external IDs.
linkExternalID · updatePerson · deletePersonMutUSER_OR_APILink external IDs, update, or soft-delete a person.
erasePersonMutUSER_OR_APIGDPR/FERPA erasure: removes all associated data; requires reason.

Behavioral events · consent · snapshots

OperationTypeAuthDescription
eventTimeline · eventQueryAPIA person's events (with filters) / by ID.
ingestEvent · batchIngestEventsMutAPIEvent ingestion (trust + consent pipeline). The batch returns accepted/flagged/quarantined/rejected totals.
getConsentQueryUSER_OR_APIGet a consent by ID.
consents · checkConsentQueryAPIList consents / check whether consent exists for a category.
grantConsent · revokeConsentMutAPIGrant or revoke consent (FERPA/COPPA).
latestSnapshotQueryUSER_OR_APIA person's most recent snapshot.
snapshotsQueryAPIPaginated snapshot history.
upsertSnapshotMutUSER_OR_APICreates or updates a snapshot.

Connectors · trust · catalogs

OperationTypeAuthDescription
getSourceStatsQueryUSER_OR_APIStats for a connector.
connectors · connectorQueryAPIList / get connectors.
registerConnector · updateConnector · deleteConnectorMutAPIManage the connector registry.
evaluateTrustMutUSER_OR_APIEvaluates the composite trust score (user, source, event_type).
CommonQuestion · CopingTool (CRUD)MixUSER_OR_APIAuxiliary catalogs: get/list/create/update/delete.
TrustRelationship · EnrollmentMixUSER_OR_APIThe person's trust relationships and enrollments.

Metrics Engine

Tier 1 behavioral snapshots, explainability, and cohort metrics. Intended for dashboards and server-to-server pipelines.

OperationTypeAuthArgumentsDescription
snapshotQueryAPIuserMost recent Tier 1 snapshot (mood, engagement, sleep, support, routine, trust).
metricFactorsQueryAPIuser, metricNameBreakdown of factors contributing to a metric.
cohortMetricsQueryAPIscopeType, scopeId?, metricNames, window="30d"Aggregated cohort metrics (TENANT, ORGANIZATION, DISTRICT, CLASSROOM).
triggerTierARecomputeMutAPIuser, eventType, eventIdReal-time (risk-critical) recompute for a person.
triggerTierBRecomputeMutAPIBatch recompute for all active persons in the tenant.

Intervention

Delivery of personalized interventions. A session advances through a linear FSM: EXPRESSION → SUPPORT → ACTION → FOLLOW_UP.

OperationTypeAuthArgumentsDescription
interventionQueryUSER_OR_APIstudentIdDeterministic intervention payload (pathway + supportBlocks + actionPayload).
createInterventionSessionMutUSER_OR_APIstudentIdCreates a session in the EXPRESSION state.
transitionInterventionStateMutUSER_OR_APIsessionId, toStateAdvances the FSM (fails if the transition breaks the guards).
recordInterventionOutcomeMutUSER_OR_APIsessionId, studentId, toolId, moodDelta, …Closes the session, records the outcome, and schedules the follow-up.
Pathway by risk level: 0–2 ROUTINE · 3 OBSERVATION · 4–6 IMMEDIATE_SAFETY (crisis, human-in-the-loop).

Notifications

Webhooks, emails, alert contacts, and risk alerts. All operations USER_OR_API.

OperationTypeArgumentsDescription
getWebhook · listWebhooksQueryid / page_size?, page_token?Tenant webhooks.
createWebhook · updateWebhook · deleteWebhookMutname, url, events[], activeWebhook CRUD. Events are strings (e.g. journal.created, risk.alerted).
getEmailNotification · listEmailNotificationsQueryid / status_filter?, …Email send history.
sendEmailMuttemplate_name, dynamic_data?, recipients?, from_name?Sends a templated email. Returns notification_id + status.
getAlertContact · listAlertContactsQueryid / —Directory of alert contacts.
createAlertContact · updateAlertContact · deleteAlertContactMutuser, activeManage alert contacts (they reference a tenant user).
getRiskAlert · listRiskAlertsQueryid / status?Risk alerts (pending, acknowledged).
acknowledgeRiskAlertMutid, acknowledgedByAcknowledges a risk alert (closes the SLA).

Escalation Policy

Policies defining which roles and contacts are notified when a risk alert fires. All USER_OR_API.

OperationTypeArgumentsDescription
escalationPolicyQueryidGet a policy by ID.
escalationPoliciesQuerytenantIdList the tenant's active policies.
createEscalationPolicy · updateEscalationPolicyMuttargetRoles, contacts, ackTimeoutMinutes, fallbackPolicyIdCreate/update a policy (fallback chain on ACK timeout).
deleteEscalationPolicyMutid, tenantIdSoft-delete the policy.

Re-engagement Policy

One policy per tenant controlling post-intervention follow-up modals. USER_OR_API

OperationTypeArgumentsDescription
reengagementPolicyQueryThe tenant's policy (falls back to the system default if none is configured).
updateReengagementPolicyMutfrequencyCap24h, cooldownMinBetweenModals, criticalSuppressionFlagCreates or replaces the policy.

LMS Connector

Data from external LMSes (Google Classroom, Canvas). All USER_OR_API; every read requires lms_type (e.g. "classroom", "canvas").

OperationTypeArgumentsDescription
listLMSCourses · getLMSCourseQuerylms_type, external_id?LMS courses.
getLMSCourseStudentsQuerylms_type, course_external_idStudents in a course.
listLMSAssignments · getLMSAssignmentQuerylms_type, course_external_id, assignment_external_id?Course assignments.
listLMSSubmissions · getLMSStudentGradesQuerylms_type, course_external_id, …Submissions and grades.
listLMSEnrollmentsQuerylms_type, course_external_idCourse enrollments.
getLMSConnectionStatusQuerylms_typeOAuth connection status (status, expires_at).
registerLMSConnectionMutlms_type, client_id, client_secret, auth_code, …Completes the OAuth flow to register the connection.
refreshLMSTokenMutlms_typeRefreshes the OAuth access token.

Manager

Action/operation registry.

OperationTypeAuthArgumentsDescription
createActionMutUSER_OR_APIaction, url, keyRegisters a pending action/operation.