Ainstein API Documentation

Version 1.0.0 - RESTful API for content generation and management

Authentication

The API uses Laravel Sanctum for authentication. Include the Bearer token in the Authorization header:

Authorization: Bearer {your-api-token}

Base URL

https://ainstein.it/api/v1

Authentication Endpoints

POST /auth/login
Authenticate user and return token
Body: { "email": "user@example.com", "password": "password" }
POST /auth/register
Register new user
Body: { "name": "User Name", "email": "user@example.com", "password": "password", "password_confirmation": "password", "tenant_id": "tenant-id" }
POST /auth/logout Auth Required
Revoke current token
GET /auth/me Auth Required
Get current user details

Tenant Management

GET /tenants Auth Required
List tenants (super admin sees all, users see only their own)
GET /tenants/{id} Auth Required
Show tenant details
POST /tenants Super Admin Only
Create new tenant
PUT /tenants/{id} Auth Required
Update tenant (super admin or tenant admin)
DELETE /tenants/{id} Super Admin Only
Delete tenant

Page Management

GET /pages Auth Required
List pages for current tenant
Query params: status, category, language, search, sort_by, sort_direction, per_page
GET /pages/{id} Auth Required
Show page details
POST /pages Auth Required
Create new page
PUT /pages/{id} Auth Required
Update page
DELETE /pages/{id} Auth Required
Delete page

Prompt Management

GET /prompts Auth Required
List prompts for current tenant
Query params: category, is_active, search, include_system, sort_by, sort_direction, per_page
GET /prompts/{id} Auth Required
Show prompt details
POST /prompts Auth Required
Create new prompt
PUT /prompts/{id} Auth Required
Update prompt
DELETE /prompts/{id} Auth Required
Delete prompt (cannot delete system prompts)

Content Generation

GET /content-generations Auth Required
List content generations for current tenant
Query params: status, prompt_type, ai_model, page_id, date_from, date_to, sort_by, sort_direction, per_page
GET /content-generations/{id} Auth Required
Show content generation details
POST /content-generations Auth Required
Create new content generation
PUT /content-generations/{id} Auth Required
Update content generation
DELETE /content-generations/{id} Auth Required
Delete content generation (cannot delete published)

Utility Endpoints

GET /utils/tenant Auth Required
Get current user's tenant information
GET /utils/stats Auth Required
Get statistics for current tenant
GET /utils/health Auth Required
API health check

Admin Endpoints

GET /admin/stats Super Admin Only
Get system-wide statistics

Response Format

All API responses follow this consistent format:

{
  "success": true,
  "message": "Operation successful",
  "data": { ... }
}

Paginated responses include additional meta information:

{
  "success": true,
  "message": "Data retrieved successfully",
  "data": [...],
  "meta": {
    "current_page": 1,
    "last_page": 5,
    "per_page": 15,
    "total": 73
  }
}

Error Responses

Error responses return appropriate HTTP status codes with error details:

{
  "success": false,
  "message": "Error message",
  "errors": { ... } // For validation errors
}

Status Codes