# Recurly

Recurly is a subscription billing and revenue management platform that helps businesses manage recurring billing, subscriptions, invoicing, and payment processing. The Sling Recurly connector extracts data from the Recurly REST API v2021-02-25, supporting accounts, subscriptions, plans, invoices, transactions, and more.

{% hint style="success" %}
**CLI Pro Required**: APIs require a [CLI Pro token](/sling-cli/cli-pro.md) or [Platform Plan](/sling-platform/platform.md).
{% endhint %}

## Setup

The following credentials and inputs are accepted:

**Secrets:**

* `api_key` **(required)** -> Your Recurly private API key

**Inputs:**

* `anchor_date` (optional) -> The starting date for historical data extraction (default: 1 year ago). Format: `YYYY-MM-DD`

### Getting Your API Key

1. Log in to your [Recurly Dashboard](https://app.recurly.com/)
2. Navigate to **Integrations** > **API Credentials**
3. Your default API key will be shown (masked). Click to reveal or copy
4. Alternatively, click **Add Private API Key** to create a new key

{% hint style="warning" %}
**Important:** Treat your API key like a password. It provides full access to your Recurly site's data via the API.
{% endhint %}

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set RECURLY type=api spec=recurly secrets='{ api_key: your_private_api_key }'
```

{% endcode %}

### Environment Variable

See [here](https://docs.slingdata.io/connections/api-connections/pages/eAdVs2BHCgdr6RS8GoJC#dot-env-file-.env.sling) to learn more about the `.env.sling` file.

{% code overflow="wrap" %}

```bash
export RECURLY='{ type: api, spec: recurly, secrets: { api_key: "your_private_api_key" } }'
```

{% endcode %}

### Sling Env File YAML

See [here](https://docs.slingdata.io/connections/api-connections/pages/eAdVs2BHCgdr6RS8GoJC#sling-env-file-env.yaml) to learn more about the sling `env.yaml` file.

```yaml
connections:
  RECURLY:
    type: api
    spec: recurly
    secrets:
      api_key: "your_private_api_key"
```

**With anchor date for historical data:**

```yaml
connections:
  RECURLY:
    type: api
    spec: recurly
    secrets:
      api_key: "your_private_api_key"
    inputs:
      anchor_date: "2024-01-01"
```

## Replication

Here's an example replication configuration to sync Recurly data to a PostgreSQL database:

```yaml
source: RECURLY
target: MY_POSTGRES

defaults:
  mode: incremental
  object: recurly.{stream_name}

streams:
  # sync all endpoints
  '*':

  # Reference data (always full-refresh)
  shipping_methods:
    mode: full-refresh
  measured_units:
    mode: full-refresh
```

**Full refresh example for reference data:**

```yaml
source: RECURLY
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: recurly.{stream_name}

streams:
  shipping_methods:
  measured_units:
```

## Endpoints

### Customers & Subscriptions

| Endpoint        | Description                       | Incremental |
| --------------- | --------------------------------- | ----------- |
| `accounts`      | Customer accounts                 | Yes         |
| `subscriptions` | Active and canceled subscriptions | Yes         |

### Billing & Invoicing

| Endpoint          | Description                         | Incremental |
| ----------------- | ----------------------------------- | ----------- |
| `invoices`        | Invoices                            | Yes         |
| `line_items`      | Invoice line items                  | Yes         |
| `transactions`    | Payment transactions                | Yes         |
| `credit_payments` | Credit payments applied to invoices | Yes         |

### Product Catalog

| Endpoint  | Description           | Incremental |
| --------- | --------------------- | ----------- |
| `plans`   | Subscription plans    | Yes         |
| `add_ons` | Plan add-ons          | Yes         |
| `items`   | Product catalog items | Yes         |
| `coupons` | Discount coupons      | Yes         |

### Configuration

| Endpoint           | Description                        | Incremental |
| ------------------ | ---------------------------------- | ----------- |
| `shipping_methods` | Shipping methods                   | No          |
| `measured_units`   | Usage-based billing measured units | No          |

To discover available endpoints:

```bash
sling conns discover RECURLY
```

## Incremental Sync

The Recurly connector uses time-based incremental sync with the `updated_at` timestamp for most endpoints:

* **First run:** Fetches all records from `anchor_date` (default: 1 year ago) to present
* **Subsequent runs:** Only fetches records updated after the last sync

### Supported Incremental Endpoints

The following endpoints support incremental sync via `begin_time` sorted by `updated_at`:

* `accounts`, `subscriptions`, `plans`, `add_ons`, `items`, `invoices`, `line_items`, `transactions`, `coupons`, `credit_payments`

### Full-Refresh Endpoints

These endpoints do not support incremental filtering and always perform a full refresh:

* `shipping_methods`, `measured_units`

## Rate Limiting

The Recurly API has rate limits:

* **Standard:** 2,000 requests per minute

The connector automatically:

* Uses conservative rate limiting (5 requests/second with concurrency of 3)
* Retries with exponential backoff on 429 (rate limit) responses

## Common Use Cases

### Sync Core Billing Data

```yaml
source: RECURLY
target: MY_POSTGRES

defaults:
  mode: incremental
  object: billing.{stream_name}

streams:
  accounts:
  subscriptions:
  invoices:
  transactions:
```

### Sync Product Catalog

```yaml
source: RECURLY
target: MY_POSTGRES

defaults:
  mode: incremental
  object: catalog.{stream_name}

streams:
  plans:
  add_ons:
  items:
  coupons:
```

If you are facing issues connecting, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.slingdata.io/connections/api-connections/recurly.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
