API & Embed Code — {{ $school->name }}
{{-- School Details --}}
School Details
Name {{ $school->name }}
Code {{ $school->code }}
Status @if ($school->active) Active @else Inactive @endif
Chatbot Records {{ $infoCount }} active
{{-- Subscription & Plan --}}
Subscription & Plan
Current Plan
{{ $school->plan }}
API Requests
{{ number_format($school->api_requests_used) }} / {{ $school->plan === 'enterprise' ? '∞' : number_format($school->api_requests_limit) }}
Expires
@if ($school->plan === 'free') Never @elseif ($school->subscription_expires_at) {{ $school->subscription_expires_at->format('M d, Y') }} @else Not set @endif
Last Reset
{{ $school->api_requests_reset_at ? $school->api_requests_reset_at->format('M d, Y') : 'Never' }}
{{-- Change Plan --}}
@csrf @method('PUT')
@if ($school->plan !== 'free')
@csrf
@endif
@if (!$school->isSubscriptionActive()) @endif
{{-- API Key --}}
API Key
@if ($school->api_key)
{{ $school->api_key }}
@csrf
@else

No API key generated yet. Generate one to enable authenticated API access.

@csrf
@endif
{{-- API Endpoint --}}
API Endpoint

@if ($school->api_key) Send a POST request with your API key in the X-API-Key header. @else Send a POST request to the chatbot API. No API key required for this school. @endif

// POST request
POST {{ url('/api/chatbot') }}
// Headers
Content-Type: application/json
@if ($school->api_key)
X-API-Key: {{ $school->api_key }}
@endif
// Body
{
"message": "Is admission open?",
"school_code": "{{ $school->code }}"
}
{{-- Widget Embed Code --}}
Widget Embed Code

Copy and paste this code into the school's website, just before the closing </body> tag.

<!-- ShikshaLink Chatbot Widget -->
<script src="{{ url('/widget.js') }}"
        data-api="{{ url('/api') }}"
        data-school="{{ $school->code }}"{{ $school->api_key ? "\n        data-key=\"{$school->api_key}\"" : '' }}></script>
{{-- How it works --}}
How It Works
  1. School Admin logs in and adds information via the School Info page
  2. Super Admin sets the plan and generates an API key
  3. The widget embed code is added to the school's website
  4. Visitors ask questions — the API validates the key, checks limits, and responds
@if ($infoCount === 0) @endif