npm package: @matheusprm-nodes/n8n-nodes-rdstation-crm
Description: n8n community node for RD Station CRM API v2
Author: matheusprm
Latest version: 0.5.4

# n8n-nodes-rdstation-crm

This is an n8n community node that integrates with the **RD Station CRM API v2**. It allows you to interact with RD Station CRM resources (Deals, Contacts, Organizations, Products, Tasks, Webhooks, etc.) directly from your n8n workflows.

[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

```bash
npm install @matheusprm-nodes/n8n-nodes-rdstation-crm
```

After installation, restart n8n and look for the **"RD Station CRM"** node.

## Features

- ✅ **OAuth2 Authentication** - Secure authentication using RD Station's OAuth2 flow
- ✅ **18 CRM Resources** - Full support for Campaigns, Contacts, Deals, Organizations, Products, Tasks, Webhooks, and more
- ✅ **CRUD Operations** - Create, Read, Update, Delete operations for all resources
- ✅ **Advanced Filtering** - RDQL (RD Station Query Language) support for complex queries
- ✅ **Pagination** - Built-in support for paginated results
- ✅ **Raw Request Mode** - Advanced mode for custom API calls
- ✅ **Error Handling** - Comprehensive error handling with detailed messages

## Resources Supported

- Campaigns
- Contacts
- Custom Fields
- Deal Products
- Deals
- Attachments
- Lost Reasons
- Notes
- Organizations
- Pipelines
- Products
- Segments
- Sources
- Stages
- Tasks
- Teams
- Users
- Webhooks

## Operations

For each resource, the following operations are available:

- **List** - Retrieve a list of resources with pagination, filtering, and sorting
- **Get** - Retrieve a single resource by ID
- **Create** - Create a new resource
- **Update** - Update an existing resource
- **Delete** - Delete a resource (where applicable)

## Credentials

### RD Station CRM OAuth2 API

To use this node, you need to:

1. **Create an App** in the [RD Station App Publisher](https://app.rdstation.com.br/apps)
2. **Get your credentials**:
   - Client ID
   - Client Secret
3. **Configure the credential** in n8n:
   - Go to Credentials → Add Credential → RD Station CRM OAuth2 API
   - Enter your Client ID and Client Secret
   - Complete the OAuth2 flow

### OAuth2 Flow

The node uses the **Authorization Code** flow with refresh tokens:

- Access tokens are valid for **2 hours**
- Refresh tokens expire if unused for **14 days** (rolling tokens)
- The node automatically handles token refresh

## Usage Examples

### List Deals

1. Add the **RD Station CRM** node to your workflow
2. Select **Resource**: Deal
3. Select **Operation**: List
4. Configure pagination:
   - Page: 1
   - Limit: 25
5. (Optional) Add filters using RDQL:
   - Filter: `status:(won,lost)`

### Create a Deal

1. Add the **RD Station CRM** node
2. Select **Resource**: Deal
3. Select **Operation**: Create
4. In **Body (JSON)**, enter:
   ```json
   {
     "name": "Nova negociação",
     "value": 1000
   }
   ```

### Advanced: Raw Request

For custom endpoints or advanced use cases:

1. Select **Resource**: Raw Request (Advanced)
2. Select **Method**: GET, POST, PUT, PATCH, or DELETE
3. Enter the **Endpoint**: `/deals?page=1&limit=25`
4. (Optional) Add **Query Parameters (JSON)**: `{"page":1,"limit":25,"filter":"name:Teste"}`
5. (For POST/PUT/PATCH) Add **Body (JSON)**

## Filtering with RDQL

The node supports RD Station's query language (RDQL) for advanced filtering:

### Basic Syntax
```
status:won
name:Teste
value:>1000
```

### Operators
- `=` (equals)
- `!=` (not equals, prefix `-`)
- `>`, `<`, `>=`, `<=` (comparison)
- `IN`, `NIN` (in/not in)
- `MATCH` (`~`) (pattern matching)

### Examples
```
status:(won,lost)
name:~Teste
value:>1000 and value:<5000
@setor:tecnologia
```

## Rate Limits

The RD Station CRM API has a rate limit of **120 requests per minute** per token. The node will automatically handle rate limit errors.

## Error Handling

The node provides detailed error messages for:
- Authentication failures (401)
- Rate limit exceeded (429)
- Invalid requests (400, 422)
- Resource not found (404)
- Server errors (500)

## Compatibility

- **Minimum n8n version**: 1.0.0
- **RD Station API**: v2

## Resources

- [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
- [RD Station CRM API v2 Documentation](https://developers.rdstation.com/reference/crm-v2-introduction)
- [RD Station App Publisher](https://app.rdstation.com.br/apps)

## License

MIT

## Support

For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/n8n-io/n8n-nodes-starter).