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

# Close CRM

> Sync Dodo Payments data with Close CRM to track leads and manage sales pipeline.

## Introduction

Connect your payment data directly to Close CRM for seamless lead management and sales tracking. Automatically create contacts and opportunities from successful payments, keeping your sales team informed of revenue-generating activities.

<Info>
  This integration requires a Close CRM API key with appropriate permissions.
</Info>

## Getting Started

<Steps>
  <Step title="Open the Webhook Section">
    In your Dodo Payments dashboard, navigate to <b>Webhooks → + Add Endpoint</b> and expand the integrations dropdown.

    <Frame>
      <img src="https://mintcdn.com/dodopayments/slbAEdrLLwKHfaRf/images/integrations/close-crm.png?fit=max&auto=format&n=slbAEdrLLwKHfaRf&q=85&s=bd462e078ea95d7853eb066cdbaebb0f" alt="Add Endpoint and integrations dropdown" style={{ maxHeight: '500px', width: 'auto' }} width="1710" height="948" data-path="images/integrations/close-crm.png" />
    </Frame>
  </Step>

  <Step title="Select Close CRM">
    Choose the <b>Close CRM</b> integration card.
  </Step>

  <Step title="Enter API Key">
    Provide your Close CRM API key in the configuration.
  </Step>

  <Step title="Configure Transformation">
    Edit the transformation code to map payment data to Close CRM objects.
  </Step>

  <Step title="Test & Create">
    Test with sample payloads and click <b>Create</b> to activate the sync.
  </Step>

  <Step title="Done!">
    🎉 Payment events will now automatically create/update records in Close CRM.
  </Step>
</Steps>

## Transformation Code Examples

### Create Contact from Payment

```javascript create_contact.js icon="js" expandable theme={null}
function handler(webhook) {
  if (webhook.eventType === "payment.succeeded") {
    const p = webhook.payload.data;
    webhook.url = "https://api.close.com/api/v1/contact/";
    webhook.payload = {
      name: p.customer.name,
      emails: [p.customer.email],
      phones: [p.customer.phone || ''],
      custom: {
        payment_amount: (p.total_amount / 100).toFixed(2),
        payment_method: p.payment_method || '',
        dodo_customer_id: p.customer.customer_id
      }
    };
  }
  return webhook;
}
```

### Create Opportunity from Subscription

```javascript create_opportunity.js icon="js" expandable theme={null}
function handler(webhook) {
  if (webhook.eventType === "subscription.active") {
    const s = webhook.payload.data;
    webhook.url = "https://api.close.com/api/v1/opportunity/";
    webhook.payload = {
      lead_id: s.customer.customer_id,
      value: (s.recurring_pre_tax_amount / 100).toFixed(2),
      value_period: s.payment_frequency_interval,
      title: `Subscription - ${s.product_id}`,
      custom: {
        subscription_id: s.subscription_id,
        billing_frequency: s.payment_frequency_interval,
        next_billing: s.next_billing_date
      }
    };
  }
  return webhook;
}
```

## Tips

* Use Close CRM's API documentation to understand field mappings
* Include custom fields for payment-specific data
* Map subscription amounts to opportunity values
* Use customer IDs for proper lead associations

## Troubleshooting

<AccordionGroup>
  <Accordion title="Records not created in Close CRM">
    * Verify API key has write permissions
    * Check that required fields are included
    * Ensure email format is valid
    * Review Close CRM API rate limits
  </Accordion>

  <Accordion title="Transformation errors">
    * Validate JSON structure matches Close CRM API format
    * Check that all required fields are present
    * Ensure field names match Close CRM schema exactly
  </Accordion>
</AccordionGroup>
