### Install bugsnag-api Gem Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Instructions for installing the bugsnag-api gem using Bundler or directly via the gem command. This is the initial step to integrate the Bugsnag API toolkit into your Ruby project. ```ruby gem "bugsnag-api" ``` ```bash $ bundle ``` ```bash $ gem install bugsnag-api ``` -------------------------------- ### Run Tests in bugsnag-api-ruby Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/CONTRIBUTING.md This command executes the test suite for the bugsnag-api-ruby library. Ensure all tests pass before submitting a pull request. No specific dependencies are required beyond the standard development environment for the library. ```bash rake spec ``` -------------------------------- ### Build and Push gem for bugsnag-api-ruby Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/CONTRIBUTING.md Commands to build the bugsnag-api-ruby gem and push it to Rubygems for distribution. This process is for core team members and requires a Rubygems account and appropriate permissions. Replace `[version]` with the actual version number. ```bash gem build bugsnag-api.gemspec gem push bugsnag-api-[version].gem ``` -------------------------------- ### Access Related Resources via Bugsnag Hypermedia Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Demonstrates how to navigate related resources in Bugsnag using hypermedia links embedded within API responses. This example shows accessing errors and events associated with a project using `.rels` and `.get`. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end project = Bugsnag::Api.projects("50baed0d9bf39c1431000003").first # Access errors through hypermedia link puts "Errors URL: #{project.rels[:errors].href}" # => Errors URL: https://api.bugsnag.com/projects/51baed1d9cf39c1431000004/errors # Fetch errors using the relationship errors = project.rels[:errors].get.data errors.first(3).each do |error| puts "#{error.error_class}: #{error.message}" # Access events through error's hypermedia link events = error.rels[:events].get.data puts " Has #{events.length} events" end # => NoMethodError: undefined method `upcase' for nil:NilClass # => Has 247 events ``` -------------------------------- ### Authenticate Bugsnag API with Auth Token or Credentials in Ruby Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Provides examples of how to authenticate API requests using either a personal auth token or email/password credentials. It highlights the configuration options available for the Bugsnag API client. ```ruby # Authenticate with your Bugsnag account's auth token Bugsnag::Api.configure do |config| config.auth_token = "your-personal-auth-token" end ``` ```ruby # Authenticate using your Bugsnag email address and password. Unavailable when # using multi-factor authentication. Bugsnag::Api.configure do |config| config.email = "example@example.com" config.password = "password" end ``` -------------------------------- ### Get Single Project Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Fetch detailed information for a specific Bugsnag project using its unique ID. ```APIDOC ## Get Single Project Fetch detailed information about a specific project. ### Method `GET` ### Endpoint `/projects/:id` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the project. ### Request Example ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end project = Bugsnag::Api.project("51baed1d9cf39c1431000004") ``` ### Response #### Success Response (200) - **Project Object**: - **id** (string) - The unique identifier for the project. - **name** (string) - The name of the project. - **type** (string) - The type or platform of the project (e.g., 'rails', 'javascript', 'android'). - **url_whitelist** (Array) - A list of URLs included in the project's whitelist. - **resolve_on_deploy** (boolean) - Indicates if issues should resolve automatically on deployment. #### Response Example ```json { "id": "51baed1d9cf39c1431000004", "name": "Web Application", "type": "rails", "url_whitelist": ["https://app.acme.com", "https://admin.acme.com"], "resolve_on_deploy": true } ``` ``` -------------------------------- ### List and Get Organizations Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Provides methods to list all organizations associated with the authenticated user and to retrieve details for a specific organization using its ID. ```ruby # List your organizations orgs = Bugsnag::Api.organizations # Get a single organization org = Bugsnag::Api.organization("organization-id") ``` -------------------------------- ### Get Single Project Details via Bugsnag API (Ruby) Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt This code retrieves detailed information about a specific Bugsnag project using its ID. After authentication, it calls the `project` method and accesses various project attributes such as name, type, URL whitelist, and resolve-on-deploy settings. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end project = Bugsnag::Api.project("51baed1d9cf39c1431000004") puts "Project: #{project.name}" puts "Type: #{project.type}" puts "URL Whitelist: #{project.url_whitelist.inspect}" puts "Resolve on Deploy: #{project.resolve_on_deploy}" # => Project: Web Application # => Type: rails # => URL Whitelist: ["https://app.acme.com", "https://admin.acme.com"] # => Resolve on Deploy: true ``` -------------------------------- ### List, Get, and Filter Project Events Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Enables listing all events for a project, listing events related to a specific error, and filtering events based on complex criteria. Also supports retrieving the latest or a single event, and deleting events. ```ruby # List project events events = Bugsnag::Api.events("project-id") # List error events events = Bugsnag::Api.error_events("project-id", "error-id") # List events with a filter (see Filtering section for more information) # Returns events with # class `EXC_BAD_INSTRUCTION` OR `EXC_BAD_ACCESS` # AND where the device is jailbroken events = Bugsnag::Api.events(PROJECT_ID, direction:"desc", filters: { "event.class": [{ "type":"eq", "value":"EXC_BAD_INSTRUCTION" }, { "type":"eq", "value":"EXC_BAD_ACCESS" }], "device.jailbroken": [{ "type":"eq", "value":"false"}] }) # Get the latest event event = Bugsnag::Api.latest_event("project-id", "error-id") # Get a single event event = Bugsnag::Api.event("project-id", "event-id") # Delete an event Bugsnag::Api.delete_event("project-id", "event-id") ``` -------------------------------- ### List, Get, and Filter Project Errors Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Provides functionality to list all errors within a project, retrieve a specific error by its ID, and filter errors based on various criteria. Supports updating single or bulk errors and deleting errors. ```ruby # List project errors errors = Bugsnag::Api.errors("project-id", nil) # List errors with a filter (see Filtering section for more information) # Returns errors that match `EXC_BAD_INSTRUCTION`, this could be from the error class, message, context, or stack trace. errors = Bugsnag::Api.errors("project-id", nil, direction:"desc", filters: { "search": [{ "type":"eq", "value":"EXC_BAD_INSTRUCTION" }] }) # Get a single error error = Bugsnag::Api.error("project-id", "error-id") # Update a single error error = Bugsnag::Api.update_errors("project-id", "error-id") # Update bulk errors error = Bugsnag::Api.update_errors("project-id", ["error-id1", "error-id2"]) # Delete an error error = Bugsnag::Api.delete_error("project-id", "error-id") ``` -------------------------------- ### Get Single Error Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Retrieve detailed information about a specific error. ```APIDOC ## Get Single Error ### Description Retrieve detailed information about a specific error. ### Method GET ### Endpoint `/projects/{project_id}/errors/{error_id}` ### Parameters #### Path Parameters - **project_id** (string) - Required - The unique identifier of the project. - **error_id** (string) - Required - The unique identifier of the error. ### Request Example ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end error = Bugsnag::Api.error( "51baed1d9cf39c1431000004", # project ID "52baed3f9cf39c1431000006" # error ID ) puts "Error: #{error.error_class}" puts "Message: #{error.message}" puts "Context: #{error.context}" puts "First seen: #{error.first_seen}" puts "Severity: #{error.severity}" puts "Assigned to: #{error.assigned_collaborator&.name || 'Unassigned'}" ``` ### Response #### Success Response (200) - **error_class** (string) - The class of the error. - **message** (string) - The error message. - **context** (string) - The context in which the error occurred. - **first_seen** (string) - The timestamp when the error was first seen (ISO 8601 format). - **severity** (string) - The severity level of the error (e.g., `error`, `warning`, `info`). - **assigned_collaborator** (object) - Information about the collaborator assigned to the error, if any. - **name** (string) - The name of the assigned collaborator. #### Response Example ```json { "error_class": "NoMethodError", "message": "undefined method `upcase' for nil:NilClass", "context": "users#show", "first_seen": "2025-09-12T08:15:00Z", "severity": "error", "assigned_collaborator": { "id": "50baed4g9cf39c1431000007", "name": "Jane Developer" } } ``` ``` -------------------------------- ### Configure and Use Bugsnag API Client in Ruby Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Shows how to configure the Bugsnag API client with authentication credentials and then make API requests. It illustrates both static method access and instance-based client usage. ```ruby # Provide authentication credentials Bugsnag::Api.configure do |config| config.auth_token = "your-personal-auth-token" end # Access API methods organizations = Bugsnag::Api.organizations ``` ```ruby # Create an non-static API client client = Bugsnag::Api::Client.new(auth_token: "your-personal-auth-token") # Access API methods on the client organizations = client.organizations ``` -------------------------------- ### Get Latest Event for Error Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Retrieve the most recent event occurrence for a specific error. ```APIDOC ## Get Latest Event for Error ### Description Retrieve the most recent event occurrence for a specific error. ### Method GET ### Endpoint `/projects/:project_id/errors/:error_id/latest_event` ### Parameters #### Path Parameters - **project_id** (string) - Required - The ID of the project. - **error_id** (string) - Required - The ID of the error. ### Request Example ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end event = Bugsnag::Api.latest_event( "51baed1d9cf39c1431000004", # project ID "52baed3f9cf39c1431000006" # error ID ) ``` ### Response #### Success Response (200) - **event** (object) - The latest event object. - **error_class** (string) - The class of the error. - **context** (string) - The context of the event. - **app_version** (string) - The application version. - **device_type** (string) - The device type. - **os_version** (string) - The operating system version. - **user** (object, optional) - User information. - **id** (string) - The user ID. - **exceptions** (array) - List of exceptions. - **stacktrace** (array) - Stack trace frames. - **file** (string) - The file path. - **line_number** (integer) - The line number. - **method** (string) - The method name. #### Response Example ```json { "error_class": "NoMethodError", "context": "users#show", "app_version": "3.2.1", "device_type": "iPhone14,2", "os_version": "iOS 17.1", "user": { "id": "user-12345" }, "exceptions": [ { "stacktrace": [ { "file": "app/controllers/users_controller.rb", "line_number": 45, "method": "show" } ] } ] } ``` ``` -------------------------------- ### Configure Bugsnag API with Auth Token (Ruby) Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Demonstrates how to configure the Bugsnag API client using a personal authentication token. This method is recommended for authorizing API requests. It shows both static module-level configuration and instance-based client creation. ```ruby require 'bugsnag/api' # Static configuration Bugsnag::Api.configure do |config| config.auth_token = "your-personal-auth-token-here" end # Now you can make API calls organizations = Bugsnag::Api.organizations puts organizations.first.name # => "Acme Corporation" # Or create a client instance client = Bugsnag::Api::Client.new(auth_token: "your-personal-auth-token-here") organizations = client.organizations puts organizations.first.name # => "Acme Corporation" ``` -------------------------------- ### Get Single Organization Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Fetch detailed information for a specific Bugsnag organization using its unique ID. ```APIDOC ## Get Single Organization Fetch detailed information about a specific organization by ID. ### Method `GET` ### Endpoint `/organizations/:id` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the organization. ### Request Example ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end org = Bugsnag::Api.organization("50baed0d9bf39c1431000003") ``` ### Response #### Success Response (200) - **Organization Object**: - **id** (string) - The unique identifier for the organization. - **name** (string) - The name of the organization. - **slug** (string) - The URL-friendly slug for the organization. - **created_at** (string) - The timestamp when the organization was created. - **billing_emails** (Array) - A list of billing email addresses associated with the organization. - **fields** (Set) - A set of available fields for the organization object. #### Response Example ```json { "id": "50baed0d9bf39c1431000003", "name": "Acme Corporation", "slug": "acme-corp", "created_at": "2023-01-15T10:30:00Z", "billing_emails": ["billing@acme.com", "finance@acme.com"], "fields": [ "id", "name", "slug", "creator", "created_at", "updated_at", "auto_upgrade", "upgrade_url", "billing_emails" ] } ``` ``` -------------------------------- ### Manage Projects with Bugsnag API Ruby Client Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md This snippet demonstrates how to perform common project management operations using the Bugsnag API Ruby client. It covers listing, retrieving, creating, updating, regenerating API keys for, and deleting projects. No external dependencies are required beyond the Bugsnag API client gem. ```ruby # List organization projects projects = Bugsnag::Api.projects("organization-id") # Get a single project project = Bugsnag::Api.project("project-id") # Create a project project = Bugsnag::Api.create_project("organization-id", "project name", "rails") # Update a project project = Bugsnag::Api.update_project("project-id", { name: "New Name" }) # Regenerate a project API key Bugsnag::Api.regenerate_api_key("project-id") # Delete a project Bugsnag::Api.delete_project("project-id") ``` -------------------------------- ### Get Filterable Event Fields for a Project Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Retrieves a list of fields that can be used for filtering events and errors within a specific Bugsnag project. This is useful for understanding the available filtering parameters for API calls. ```ruby fields = Bugsnag::Api.event_fields("project-id") puts "List of the searchable fields for this project:" fields.each_with_index do |field,idx| puts " [#{idx}] #{field.display_id}" end ``` -------------------------------- ### Authentication with Auth Token Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Configure the Bugsnag API client using a personal authentication token for accessing the API. This method supports both static configuration and instance-based client creation. ```APIDOC ## Authentication with Auth Token Configure the client with a personal authentication token from your Bugsnag account settings to authorize all API requests. ### Method N/A (Configuration) ### Endpoint N/A (Configuration) ### Parameters #### Request Body - **auth_token** (string) - Required - Your personal authentication token from Bugsnag settings. ### Request Example ```ruby require 'bugsnag/api' # Static configuration Bugsnag::Api.configure do |config| config.auth_token = "your-personal-auth-token-here" end # Or create a client instance client = Bugsnag::Api::Client.new(auth_token: "your-personal-auth-token-here") ``` ### Response N/A (Configuration) ### Response Example N/A (Configuration) ``` -------------------------------- ### Get Latest Event for Error in Ruby Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Retrieves the most recent event occurrence for a specific error. It returns an event object with details like error class, context, app version, device information, and stack trace. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end event = Bugsnag::Api.latest_event("52baed3f9cf39c1431000006") puts "Latest occurrence:" puts " Class: #{event.error_class}" puts " Context: #{event.context}" puts " App version: #{event.app_version}" puts " Device: #{event.device_type}" puts " OS: #{event.os_version}" puts " User: #{event.user&.id || 'anonymous'}" # Access stack trace event.exceptions.first.stacktrace.first(3).each do |frame| puts " #{frame.file}:#{frame.line_number} in #{frame.method}" end ``` -------------------------------- ### Access Bugsnag API Resources and Fields in Ruby Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Illustrates how to fetch a specific resource (e.g., an organization) using the Bugsnag API client and access its properties using dot notation or array-like access. It also shows how to access related resources via hypermedia link relations. ```ruby # Fetch an organization org = Bugsnag::Api.organization("organization-id") puts org.name # => "Acme Co" puts org.fields # => # ``` ```ruby puts org.id # => "50baed0d9bf39c1431000003" ``` ```ruby account.rels[:upgrade].href # => "https://api.bugsnag.com/organizations/50baed0d9bf39c1431000003/.." ``` ```ruby project = Bugsnag::Api.projects("organization-id").first # Get the users rel, returned from the API as users_url in the resource project.rels[:errors].href # => "https://api.bugsnag.com/projects/50baed0d9bf39c1431000003/errors" ``` ```ruby errors = project.rels[:errors].get.data errors.first.message # => "Can't find method: getStrng()" ``` -------------------------------- ### Create Project via Bugsnag API (Ruby) Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt This snippet demonstrates how to create a new project within a specified organization in Bugsnag. It requires the organization ID, the desired project name, and the project type (e.g., 'rails', 'android'). The output includes the details of the newly created project, such as its name, ID, and API key. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end new_project = Bugsnag::Api.create_project( "50baed0d9bf39c1431000003", # organization ID "Mobile App", # project name "android" # project type (rails, javascript, android, ios, etc.) ) puts "Created project: #{new_project.name}" puts "Project ID: #{new_project.id}" puts "API Key: #{new_project.api_key}" # => Created project: Mobile App # => Project ID: 52baed2e9cf39c1431000005 # => API Key: xyz789ghi012 ``` -------------------------------- ### Project Management API Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Provides methods for listing, retrieving, creating, updating, regenerating API keys for, and deleting Bugsnag projects. ```APIDOC ## GET /projects ### Description Lists all projects for a given organization. ### Method GET ### Endpoint `/projects` ### Parameters #### Query Parameters - **organization_id** (string) - Required - The ID of the organization. ### Response #### Success Response (200) - **projects** (array) - A list of project objects. ### Response Example ```json { "projects": [ { "id": "project-id", "name": "Example Project", "organization_id": "organization-id" } ] } ``` ``` ```APIDOC ## GET /projects/{project-id} ### Description Retrieves details for a specific project. ### Method GET ### Endpoint `/projects/{project-id}` ### Parameters #### Path Parameters - **project-id** (string) - Required - The ID of the project. ### Response #### Success Response (200) - **project** (object) - The project details. ### Response Example ```json { "id": "project-id", "name": "Example Project", "organization_id": "organization-id" } ``` ``` ```APIDOC ## POST /projects ### Description Creates a new project within an organization. ### Method POST ### Endpoint `/projects` ### Parameters #### Request Body - **organization_id** (string) - Required - The ID of the organization. - **name** (string) - Required - The name of the project. - **account_type** (string) - Required - The type of account (e.g., "rails"). ### Request Example ```json { "organization_id": "organization-id", "name": "New Project", "account_type": "rails" } ``` ### Response #### Success Response (201) - **project** (object) - The newly created project details. ### Response Example ```json { "id": "new-project-id", "name": "New Project", "organization_id": "organization-id" } ``` ``` ```APIDOC ## PUT /projects/{project-id} ### Description Updates an existing project. ### Method PUT ### Endpoint `/projects/{project-id}` ### Parameters #### Path Parameters - **project-id** (string) - Required - The ID of the project to update. #### Request Body - **name** (string) - Optional - The new name for the project. ### Request Example ```json { "name": "Updated Project Name" } ``` ### Response #### Success Response (200) - **project** (object) - The updated project details. ### Response Example ```json { "id": "project-id", "name": "Updated Project Name", "organization_id": "organization-id" } ``` ``` ```APIDOC ## POST /projects/{project-id}/api_key ### Description Regenerates the API key for a specific project. ### Method POST ### Endpoint `/projects/{project-id}/api_key` ### Parameters #### Path Parameters - **project-id** (string) - Required - The ID of the project. ### Response #### Success Response (200) - **api_key** (string) - The new API key. ### Response Example ```json { "api_key": "new-generated-api-key" } ``` ``` ```APIDOC ## DELETE /projects/{project-id} ### Description Deletes a specific project. ### Method DELETE ### Endpoint `/projects/{project-id}` ### Parameters #### Path Parameters - **project-id** (string) - Required - The ID of the project to delete. ### Response #### Success Response (204) No content returned on successful deletion. ``` -------------------------------- ### Projects API Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md API methods for managing Bugsnag projects. ```APIDOC ## Projects ### Description API methods for managing Bugsnag projects, such as listing projects. ### Method `GET` ### Endpoints - `/projects` (List projects) ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example ```ruby # List projects projects = Bugsnag::Api.projects ``` ### Response #### Success Response (200) - `projects` (array) - A list of project objects. #### Response Example ```json { "projects": [ { "id": "project-id", "name": "My Awesome Project" } ] } ``` ``` -------------------------------- ### Create Project Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Create a new project within a specified Bugsnag organization. ```APIDOC ## Create Project Create a new project within an organization. ### Method `POST` ### Endpoint `/organizations/:organization_id/projects` ### Parameters #### Path Parameters - **organization_id** (string) - Required - The unique identifier of the organization to create the project in. #### Request Body - **name** (string) - Required - The name for the new project. - **type** (string) - Required - The type or platform of the project (e.g., 'rails', 'javascript', 'android', 'ios'). ### Request Example ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end new_project = Bugsnag::Api.create_project( "50baed0d9bf39c1431000003", # organization ID "Mobile App", # project name "android" # project type ) ``` ### Response #### Success Response (201 Created) - **Project Object**: - **id** (string) - The unique identifier for the newly created project. - **name** (string) - The name of the project. - **api_key** (string) - The API key for the new project. #### Response Example ```json { "id": "52baed2e9cf39c1431000005", "name": "Mobile App", "api_key": "xyz789ghi012" } ``` ``` -------------------------------- ### Manage Releases with Bugsnag API Ruby Client Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md This section covers managing releases using the Bugsnag API Ruby client. It includes listing all releases for a project, viewing a specific release, and listing releases within a release group. Project ID and release ID are required for specific operations. ```ruby # list the releases in a project Bugsnag::Api.releases("project-id") # view a single release Bugsnag::Api.release("project-id", "release-id") # list the releases in a release group Bugsnag::Api.releases_in_group("release-group-id") ``` -------------------------------- ### Get Single Organization Details via Bugsnag API (Ruby) Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt This code retrieves detailed information for a specific Bugsnag organization using its unique ID. After configuring authentication, it calls the `organization` method and accesses various attributes of the returned organization object, such as name, fields, and billing emails. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end org = Bugsnag::Api.organization("50baed0d9bf39c1431000003") puts org.name # => "Acme Corporation" puts org.fields # => # puts org.billing_emails # => ["billing@acme.com", "finance@acme.com"] ``` -------------------------------- ### Manage Collaborators Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Enables listing collaborators for organizations or projects, inviting new users, updating their permissions, and removing them from an account. Requires organization and/or project IDs and user information. ```ruby # List organization collaborators users = Bugsnag::Api.collaborators("organization-id") # List project collaborators users = Bugsnag::Api.collaborators(nil, "project-id") # Invite a user to an account user = Bugsnag::Api.invite_collaborators("org-id", "example@example.com", { admin: true }) # Update a user's account permissions user = Bugsnag::Api.update_collaborator_permissions("org-id", "user-id", { admin: false }) # Remove a user from an account Bugsnag::Api.delete_collaborator("org-id", "user-id") ``` -------------------------------- ### Configure Bugsnag API with Email and Password (Ruby) Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Shows how to authenticate with the Bugsnag API using email and password credentials. Note that this method is unavailable if multi-factor authentication is enabled on the account. It also demonstrates how to check authentication status and access API resources. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.email = "user@example.com" config.password = "your-secure-password" end # Check authentication status puts Bugsnag::Api.client.basic_authenticated? # => true # Access API resources projects = Bugsnag::Api.projects("organization-id") puts "Found #{projects.length} projects" # => "Found 5 projects" ``` -------------------------------- ### Configuration API Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Allows configuration of the Bugsnag API client, including custom endpoints and proxy settings. ```APIDOC ## Configure Custom Endpoint ### Description Configures the Bugsnag API client to communicate with a custom Bugsnag Enterprise endpoint instead of the default SaaS endpoint. ### Method Configuration (Client-side) ### Endpoint N/A ### Parameters #### Configuration Options - **endpoint** (string) - Required - The URL of the custom Bugsnag Enterprise endpoint. ### Request Example ```ruby Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" config.endpoint = "https://bugsnag.enterprise.acme.com" end ``` ## Configure Proxy Settings ### Description Configures the Bugsnag API client to route all requests through a specified proxy server, including support for proxy authentication. ### Method Configuration (Client-side) ### Endpoint N/A ### Parameters #### Configuration Options - **proxy** (hash) - Required - A hash containing proxy configuration details. - **uri** (string) - Required - The URL of the proxy server. - **user** (string) - Optional - The username for proxy authentication. - **password** (string) - Optional - The password for proxy authentication. ### Request Example ```ruby Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" config.proxy = { uri: "http://proxy.acme.com:8080", user: "proxy_username", password: "proxy_password" } end ``` ``` -------------------------------- ### API Configuration Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Configuration options for the Bugsnag API client, including custom endpoints and proxy settings. ```APIDOC ## API Client Configuration ### Endpoint Configuration By default, `https://api.bugsnag.com` is used. For Bugsnag Enterprise, you can configure a custom endpoint. ```ruby Bugsnag::Api.configure do |config| config.endpoint = "http://api.bugsnag.example.com" end ``` ### Proxy Configuration If you are using a proxy, you can configure the API client to use it. ```ruby Bugsnag::Api.configure do |config| config.proxy = { uri: "http://proxy.example.com", user: "foo", password: "bar" } end ``` ``` -------------------------------- ### Require bugsnag-api Gem in Ruby Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Demonstrates how to include the bugsnag-api library in your Ruby script or application using the 'require' keyword. This makes the library's functionality available for use. ```ruby require 'bugsnag/api' ``` -------------------------------- ### Handle Paginated Bugsnag API Responses in Ruby Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Demonstrates how to iterate through paginated API responses by following the 'next' link relation provided in the response headers. This is crucial for retrieving all data when a resource contains many items. ```ruby errors = Bugsnag::Api.errors("project-id", per_page: 100) last_response = Bugsnag::Api.last_response until last_response.rels[:next].nil? last_response = last_response.rels[:next].get errors.concat last_response.data end ``` -------------------------------- ### Configure Proxy for Bugsnag API Ruby Client Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md This code demonstrates how to configure proxy settings for the Bugsnag API Ruby client. It involves setting the `proxy` attribute within the `Bugsnag::Api.configure` block, including URI, username, and password. ```ruby Bugsnag::Api.configure do |config| config.proxy = { uri: "http://proxy.example.com", user: "foo", password: "bar" } end ``` -------------------------------- ### Resource Navigation API Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Enables navigation between related resources using hypermedia links embedded in API responses. ```APIDOC ## Access Related Resources via Hypermedia ### Description Navigate to related resources (e.g., errors from a project, events from an error) using hypermedia links provided in the API responses. ### Method GET ### Endpoint `/projects/{project_id}` (example) ### Parameters None for the initial resource fetch. ### Request Example ```ruby Bugsnag::Api.configure { |config| config.auth_token = "your-auth-token" } project = Bugsnag::Api.projects("50baed0d9bf39c1431000003").first # Access errors via hypermedia link errors_url = project.rels[:errors].href errors = project.rels[:errors].get.data # Access events via hypermedia link project.rels[:errors].get.data.first.rels[:events].get.data ``` ### Response #### Success Response (200) - **Resource Objects** - The requested related resources. - **Hypermedia Links** - Embedded links to navigate to further related resources. #### Response Example ```json { "id": "51baed1d9cf39c1431000004", "name": "My Project", "_links": { "errors": "/projects/51baed1d9cf39c1431000004/errors" } } ``` ``` -------------------------------- ### Analyze Trends with Bugsnag API Ruby Client Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Demonstrates fetching trend data for errors and projects using the Bugsnag API Ruby client. This includes listing trends in buckets for a specific error or by resolution time for a project. ```ruby # list an error's trends in 5 buckets Bugsnag::Api.trends_buckets("project-id", 5, "error-id") # list a project's trends by resolution Bugsnag::Api.trends_resolution("project-id", "2h") ``` -------------------------------- ### Releases API Source: https://github.com/bugsnag/bugsnag-api-ruby/blob/master/README.md Endpoints for managing and retrieving information about project releases. ```APIDOC ## GET /projects/{project-id}/releases ### Description Lists all releases for a given project. ### Method GET ### Endpoint `/projects/{project-id}/releases` ### Parameters #### Path Parameters - **project-id** (string) - Required - The ID of the project. ### Response #### Success Response (200) - **releases** (array) - A list of release objects. ### Response Example ```json { "releases": [ { "id": "release-id", "version": "1.0.0", "released_at": "2023-10-27T10:00:00Z" } ] } ``` ``` ```APIDOC ## GET /projects/{project-id}/releases/{release-id} ### Description Retrieves details for a specific release within a project. ### Method GET ### Endpoint `/projects/{project-id}/releases/{release-id}` ### Parameters #### Path Parameters - **project-id** (string) - Required - The ID of the project. - **release-id** (string) - Required - The ID of the release. ### Response #### Success Response (200) - **release** (object) - The release details. ### Response Example ```json { "id": "release-id", "version": "1.0.0", "released_at": "2023-10-27T10:00:00Z" } ``` ``` ```APIDOC ## GET /release_groups/{release-group-id}/releases ### Description Lists releases belonging to a specific release group. ### Method GET ### Endpoint `/release_groups/{release-group-id}/releases` ### Parameters #### Path Parameters - **release-group-id** (string) - Required - The ID of the release group. ### Response #### Success Response (200) - **releases** (array) - A list of release objects. ### Response Example ```json { "releases": [ { "id": "release-id", "version": "1.0.0", "released_at": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### List Projects in Organization via Bugsnag API (Ruby) Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt This snippet shows how to fetch all projects belonging to a specific organization. It requires the organization's ID and an authentication token. The code iterates through the returned projects, displaying their names, types, IDs, API keys, and the URL for related errors. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end projects = Bugsnag::Api.projects("50baed0d9bf39c1431000003") projects.each do |project| puts "#{project.name} [#{project.type}]" puts " ID: #{project.id}" puts " API Key: #{project.api_key}" puts " Errors URL: #{project.rels[:errors].href}" end # => Web Application [rails] # => ID: 51baed1d9cf39c1431000004 # => API Key: abc123def456 # => Errors URL: https://api.bugsnag.com/projects/51baed1d9cf39c1431000004/errors ``` -------------------------------- ### List Project Errors with Sorting and Filtering (Ruby) Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt This code shows how to retrieve a list of all errors for a given project using the Bugsnag API Ruby client. It supports optional sorting by fields like 'last_seen' and pagination via 'per_page'. Authentication with an auth token is required. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end errors = Bugsnag::Api.errors( "51baed1d9cf39c1431000004", nil, sort: "last_seen", direction: "desc", per_page: 10 ) errors.each do |error| puts "#{error.error_class}: #{error.message}" puts " Events: #{error.events} | Users: #{error.users}" puts " Last seen: #{error.last_seen}" puts " Status: #{error.status}" end # => NoMethodError: undefined method `upcase' for nil:NilClass # => Events: 247 | Users: 89 # => Last seen: 2025-10-17T14:22:30Z # => Status: open ``` -------------------------------- ### Invite Collaborators Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Invite new users to an organization with specified permissions. ```APIDOC ## Invite Collaborators ### Description Invite new users to an organization with specified permissions. ### Method POST ### Endpoint `/organizations/:organization_id/collaborators` ### Parameters #### Path Parameters - **organization_id** (string) - Required - The ID of the organization. #### Request Body - **email** (string or array of strings) - Required - The email address(es) of the user(s) to invite. - **admin** (boolean) - Optional - Whether the invited user should be an admin. - **project_ids** (array of strings) - Optional - List of project IDs to grant access to. ### Request Example ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end # Invite single user user = Bugsnag::Api.invite_collaborators( "50baed0d9bf39c1431000003", # organization ID "newdev@acme.com", # email { admin: false, project_ids: ["51baed1d9cf39c1431000004", "52baed2e9cf39c1431000005"] } ) # Bulk invite multiple users users = Bugsnag::Api.invite_collaborators( "50baed0d9bf39c1431000003", ["dev1@acme.com", "dev2@acme.com"], { admin: false, project_ids: ["51baed1d9cf39c1431000004"] } ) ``` ### Response #### Success Response (201) - **invited_user(s)** (object or array of objects) - The invited collaborator(s). - **email** (string) - The email of the invited user. #### Response Example ```json { "email": "newdev@acme.com" } ``` ``` -------------------------------- ### Invite Collaborators to Organization in Ruby Source: https://context7.com/bugsnag/bugsnag-api-ruby/llms.txt Invites new users to an organization, with options to assign administrative privileges and specific project access. Can invite single users or multiple users in bulk. ```ruby require 'bugsnag/api' Bugsnag::Api.configure do |config| config.auth_token = "your-auth-token" end # Invite single user user = Bugsnag::Api.invite_collaborators( "50baed0d9bf39c1431000003", # organization ID "newdev@acme.com", # email { admin: false, project_ids: ["51baed1d9cf39c1431000004", "52baed2e9cf39c1431000005"] } ) puts "Invited: #{user.email}" # Bulk invite multiple users users = Bugsnag::Api.invite_collaborators( "50baed0d9bf39c1431000003", ["dev1@acme.com", "dev2@acme.com"], { admin: false, project_ids: ["51baed1d9cf39c1431000004"] } ) puts "Invited #{users.length} users" ```