API Tokens

Important: Your API token will only be shown once when created. Make sure to copy it and store it securely!

Create New Token

<%= form_with model: @api_token, url: api_tokens_path, class: "space-y-4" do |f| %> <% if @api_token.errors.any? %>
    <% @api_token.errors.full_messages.each do |message| %>
  • <%= message %>
  • <% end %>
<% end %>
<%= f.label :name, "Token Name (e.g., 'Mobile App', 'Third Party Integration')", class: "block text-sm font-medium text-gray-700" %> <%= f.text_field :name, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<%= f.label :expires_at, "Expiration Date (optional)", class: "block text-sm font-medium text-gray-700" %> <%= f.datetime_local_field :expires_at, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>

Leave blank for tokens that never expire

<%= f.submit "Create Token", class: "px-6 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700" %>
<% end %>

Your API Tokens

<% if @api_tokens.any? %>
<% @api_tokens.each do |token| %>
<%= token.name || "Unnamed Token" %>
Token: <%= token.token[0..15] %>...
Created: <%= token.created_at.strftime("%B %d, %Y at %I:%M %p") %>
<% if token.last_used_at %>
Last Used: <%= time_ago_in_words(token.last_used_at) %> ago
<% else %>
Last Used: Never
<% end %> <% if token.expires_at %>
Expires: <%= token.expires_at.strftime("%B %d, %Y") %> <%= " (EXPIRED)" if token.expired? %>
<% else %>
Expires: Never
<% end %>
<%= button_to "Delete", api_token_path(token), method: :delete, data: { turbo_confirm: "Are you sure you want to delete this API token? Apps using this token will stop working. This action cannot be undone." }, class: "px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 text-sm" %>
<% end %>
<% else %>

You haven't created any API tokens yet. Create one above to start using the API.

<% end %>

API Documentation: See API_DOCUMENTATION.md for complete API reference and usage examples.

<%= link_to "← Back to Settings", settings_path, class: "text-indigo-600 hover:text-indigo-800" %>