Skip to Content

API Reference

The TEA Platform provides a RESTful API built with Next.js 15 App Router and Prisma ORM.

Auto-Generated Documentation

Our API documentation is automatically generated from the Prisma schema to ensure accuracy and completeness. This page provides an overview and links to the full documentation.

Authentication

The TEA Platform uses NextAuth.js  for authentication. API routes are protected and require a valid session.

Authentication Flow

  1. Sign in via the web interface using GitHub OAuth or email/password
  2. Session cookies are automatically managed by NextAuth.js
  3. API requests include session cookies for authentication

Making Authenticated Requests

When using tools like curl or Postman, you’ll need to include the session cookie:

curl -X GET http://localhost:3000/api/cases \ -H 'Cookie: next-auth.session-token=YOUR_SESSION_TOKEN'

Session Tokens

Session tokens are managed by NextAuth.js and should not be manually created. Use the web interface to authenticate and obtain a valid session.

API Overview

The TEA Platform API is organised around REST principles. All endpoints:

  • Accept and return JSON
  • Use standard HTTP methods (GET, POST, PUT, DELETE)
  • Return appropriate HTTP status codes
  • Require authentication (except public endpoints)

Base URL

EnvironmentBase URL
Local Developmenthttp://localhost:3000/api
Productionhttps://assuranceplatform.azurewebsites.net/api

Core Resources

ResourceDescription
CasesAssurance cases - the primary resource
ElementsGoals, strategies, property claims, evidence, and context within cases
TeamsUser groups for collaborative case management
UsersUser accounts and profiles
CommentsDiscussions and feedback on case elements

API Endpoints

Cases

MethodEndpointDescription
GET/api/casesList all cases accessible to the user
POST/api/casesCreate a new assurance case
GET/api/cases/[id]Retrieve a specific case
PUT/api/cases/[id]Update a case
DELETE/api/cases/[id]Delete a case

Elements

MethodEndpointDescription
GET/api/cases/[id]/elementsList all elements in a case
POST/api/cases/[id]/elementsAdd an element to a case
GET/api/elements/[id]Retrieve a specific element
PUT/api/elements/[id]Update an element
DELETE/api/elements/[id]Delete an element

Teams

MethodEndpointDescription
GET/api/teamsList teams the user belongs to
POST/api/teamsCreate a new team
GET/api/teams/[id]Retrieve team details
PUT/api/teams/[id]Update team settings
DELETE/api/teams/[id]Delete a team

Users

MethodEndpointDescription
GET/api/users/meGet current user’s profile
PUT/api/users/meUpdate current user’s profile

Response Format

Success Response

{ "id": 1, "name": "Example Case", "description": "An example assurance case", "createdAt": "2025-01-15T10:30:00Z", "updatedAt": "2025-01-15T14:45:00Z" }

Error Response

{ "error": "Not Found", "message": "Case with ID 999 not found", "statusCode": 404 }

HTTP Status Codes

CodeDescription
200Success
201Created
400Bad Request - Invalid input
401Unauthorised - Authentication required
403Forbidden - Insufficient permissions
404Not Found
500Internal Server Error

Database Schema

The TEA Platform uses Prisma ORM with PostgreSQL. The schema defines:

  • AssuranceCase - Top-level container for assurance arguments
  • Element - Nodes in the assurance case (goals, strategies, claims, evidence, context)
  • User - User accounts
  • Team - Groups for collaboration
  • Comment - Discussions on elements

For the complete schema, see the Prisma schema file .

Further Resources