> ## Documentation Index
> Fetch the complete documentation index at: https://loops.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Ruby SDK

> The official Loops SDK for Ruby.

[![Gem Total Downloads](https://img.shields.io/gem/dt/loops_sdk?style=social)](https://rubygems.org/gems/loops_sdk)

## Installation

Add the gem to your Gemfile:

```bash theme={"dark"}
bundle add loops_sdk
```

Or install it directly:

```bash theme={"dark"}
gem install loops_sdk
```

> [!TIP]
>
> Want your coding agent to help with Loops? Install the Loops CLI and
> [skills](https://loops.so/docs/skills.md) with one command:
>
> ```bash theme={"dark"}
> curl -fsSL https://install.loops.so/wizard | sh
> ```

You will need a Loops API key to use the SDK.

In your Loops account, go to the [API Settings page](https://app.loops.so/settings?page=api) and click **Generate key**.

Copy this key and save it in your application code (for example in an environment variable).

## Usage

Configure the SDK in an initializer:

```ruby config/initializers/loops.rb theme={"dark"}
require "loops_sdk"

LoopsSdk.configure do |config|
  config.api_key = ENV["LOOPS_API_KEY"]
end
```

Then call SDK methods in your application:

```ruby theme={"dark"}
begin
  response = LoopsSdk::Contacts.create(
    email: "test@example.com",
    properties: { firstName: "John" }
  )
rescue LoopsSdk::APIError => e
  puts "Loops API Error: #{e.json['message']} (Status: #{e.statusCode})"
end
```

See the [SDK docs](https://github.com/loops-so/loops-rb) for every method, rate limiting, and error handling.

See the API documentation to learn more about [rate limiting](https://loops.so/docs/api-reference/intro.md#rate-limiting) and [error handling](https://loops.so/docs/api-reference/intro.md#debugging).

> [card] [RubyGems](https://rubygems.org/gems/loops_sdk)
>
> View the gem on RubyGems.

> [card] [GitHub](https://github.com/loops-so/loops-rb)
>
> View the documentation and source code.

> [card] [Loops API](https://loops.so/docs/api-reference/intro.md)
>
> Read the Loops API reference.


## Related topics

- [Loops SDKs](https://loops.so/docs/sdks.md)
- [API Introduction](https://loops.so/docs/api-reference/intro.md)
- [API Changelog](https://loops.so/docs/api-reference/changelog.md)
- [Go SDK](https://loops.so/docs/sdks/go.md)
- [PHP SDK](https://loops.so/docs/sdks/php.md)
