@php $keys = $keys ?? collect(); $rawKey = session('api_key_once'); $baseUrl = rtrim(config('app.url'), '/') . '/api/v1'; // One key per workspace — the live (non-revoked) key, if any. $activeKey = $keys->first(fn($k) => !$k->revoked_at); $docsUrl = url('/developers/docs'); @endphp
{{ __('More') }} / {{ __('Developers') }}

{{ __('Developer') }} {{ __('API keys') }}

{{ __('Generate a key to call the :brand REST API from your own apps, CRM or automation — send messages, manage contacts, templates, broadcasts and more. One key per workspace.', ['brand' => brand_name()]) }}

@if (session('error'))
{{ session('error') }}
@endif {{-- One-time raw key — flashed once on mint, never recoverable again. --}} @if ($rawKey)

{{ __('Your new API key') }}

{{ __('Copy this now and store it safely. For your security we only keep a hash — it will never be shown again.') }}

{{ $rawKey }}
@endif @if ($activeKey) {{-- The single active key. --}}

{{ __('Your API key') }}

{{ __('Active') }}
{{ $activeKey->name ?: __('Untitled key') }}
{{ $activeKey->prefix }}… {{ __('Created') }} {{ optional($activeKey->created_at)->format('M j, Y') }} {{ __('Last used') }} {{ $activeKey->last_used_at ? $activeKey->last_used_at->diffForHumans() : __('never') }}
@csrf @method('DELETE')
{{ __('Only one key is allowed per workspace. Revoke this one to issue a new key.') }}
@else {{-- No active key → create form. --}}

{{ __('Create your key') }}

{{ __('Give the key a name so you remember where it is used. The key is shown once on creation.') }}

@csrf
@error('name')

{{ $message }}

@enderror
@endif

{{ __('Quickstart') }}

{{ __('Full reference') }}

{{ __('Send your first message — replace the key and recipient:') }}

curl -X POST '{{ $baseUrl }}/messages' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"to":"919812345678","type":"text","text":"Hello from {{ brand_name() }}"}'