<%= content_for :page_title, "API Key" %> <% if @newly_created && @plain_key %> <%= settings_section title: "API Key Created Successfully", subtitle: "Your new API key has been generated successfully." do %>
<%= render DS::FilledIcon.new( icon: "check-circle", rounded: true, size: "lg", variant: :success ) %>

API Key Created Successfully!

Your new API key "<%= @current_api_key.name %>" has been created and is ready to use.

Your API Key

Copy and store this key securely. You'll need it to authenticate your API requests.

<%= @current_api_key.plain_key %> <%= render DS::Button.new( text: "Copy API Key", variant: "ghost", icon: "copy", data: { action: "clipboard#copy" } ) %>

How to use your API key

Include your API key in the X-Api-Key header when making requests:

curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts
<%= render DS::Link.new( text: "Continue to API Key Settings", href: settings_api_key_path, variant: "primary" ) %>
<% end %> <% elsif @current_api_key %> <%= settings_section title: "Your API Key", subtitle: "Manage your API key for programmatic access to your Maybe data." do %>
<%= render DS::FilledIcon.new( icon: "key", rounded: true, size: "lg" ) %>

<%= @current_api_key.name %>

Created <%= time_ago_in_words(@current_api_key.created_at) %> ago <% if @current_api_key.last_used_at %> • Last used <%= time_ago_in_words(@current_api_key.last_used_at) %> ago <% else %> • Never used <% end %>

Active

Permissions

<% @current_api_key.scopes.each do |scope| %> <%= icon("shield-check", class: "w-3 h-3") %> <%= case scope when "read" then "Read Only" when "read_write" then "Read/Write" else scope.humanize end %> <% end %>

Your API Key

Copy and store this key securely. You'll need it to authenticate your API requests.

<%= @current_api_key.plain_key %> <%= render DS::Button.new( text: "Copy API Key", variant: "ghost", icon: "copy", data: { action: "clipboard#copy" } ) %>

How to use your API key

Include your API key in the X-Api-Key header when making requests:

curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts
<%= render DS::Link.new( text: "Create New Key", href: new_settings_api_key_path(regenerate: true), variant: "secondary" ) %> <%= render DS::Button.new( text: "Revoke Key", href: settings_api_key_path, method: :delete, variant: "destructive", data: { turbo_confirm: "Are you sure you want to revoke this API key?" } ) %>
<% end %> <% else %> <%= settings_section title: "Create Your API Key", subtitle: "Get programmatic access to your Maybe data" do %>
<%= render DS::FilledIcon.new( icon: "key", rounded: true, size: "lg" ) %>

Access your account data programmatically

Generate an API key to integrate with your applications and access your financial data securely.

What you can do with API keys:

<%= render DS::Link.new( text: "Create API Key", href: new_settings_api_key_path, variant: "primary" ) %>
<% end %> <% end %>