> ## 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](/skills) with one command:

  ```bash theme={"dark"}
  curl -fsSL https://install.loops.so/wizard | sh
  ```
</Tip>

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](/api-reference/intro#rate-limiting) and [error handling](/api-reference/intro#debugging).

<CardGroup>
  <Card title="RubyGems" icon="gem" href="https://rubygems.org/gems/loops_sdk">
    View the gem on RubyGems.
  </Card>

  <Card title="GitHub" icon="github" href="https://github.com/loops-so/loops-rb">
    View the documentation and source code.
  </Card>

  <Card title="Loops API" icon="rectangle-terminal" href="/api-reference/intro">
    Read the Loops API reference.
  </Card>
</CardGroup>
