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

# Customers

Manage customer profiles, track payment history, and streamline recurring transactions in your PeasSwap dashboard.

## Overview

The Customers feature allows you to store and manage profiles for individuals or businesses that make payments to you. Create reusable customer records to simplify checkout, enable recurring billing, and track customer-specific analytics.

## Creating customers

### Via dashboard

1. Navigate to **Customers** in your dashboard sidebar
2. Click **Create Customer**
3. Enter the required information:
   * **Name** (required)
   * **Email** (required)
   * **Phone** (optional)
4. Click **Save**

<img src="https://imgstorepesaswap.blob.core.windows.net/images/CHE%20customers.png" />

<img src="https://imgstorepesaswap.blob.core.windows.net/images/coustomers2.png" />

Your customer will appear in the customers list and be available for future transactions.

### Via API

Create customers programmatically using the PeasSwap API:

```bash theme={"system"}
curl -X POST https://api.peaswap.com/v1/customers \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john.doe@example.com",
    "phone": "+1234567890"
  }'
```

```json theme={"system"}
{
  "id": "cust_1NvQI2eZvKYlo2C0",
  "object": "customer",
  "name": "John Doe",
  "email": "john.doe@example.com",
  "phone": "+1234567890",
  "created": 1640995200,
  "updated": 1640995200
}
```

## Managing customers

### Viewing customers

Your customers appear in a searchable table with:

* **Name** - Customer's full name
* **Email** - Primary contact email
* **Phone** - Contact number (if provided)
* **Created** - Date customer was added

<img src="https://imgstorepesaswap.blob.core.windows.net/images/coustomers3.png" />

### Updating customer information

1. Click on any customer in the list
2. Edit the fields you want to change
3. Click **Save changes**

<img src="https://imgstorepesaswap.blob.core.windows.net/videos/customers%20edit.gif" />

### Deleting customers

1. Select the customer you want to remove
2. Click **Delete customer**
3. Confirm the deletion

> **Note:** Deleting a customer does not affect their past transactions or payment history.

## Using customers in payments

<img src="https://imgstorepesaswap.blob.core.windows.net/images/coustomers4.png" />

### Linking customers to payments

When creating a payment, reference the customer ID:

```bash theme={"system"}
curl -X POST https://api.peaswap.com/v1/payments \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2500,
    "currency": "usd",
    "customer": "cust_1NvQI2eZvKYlo2C0",
    "description": "Premium subscription"
  }'
```

### Retrieving customer payments

Get all payments for a specific customer:

```bash theme={"system"}
curl -X GET "https://api.peaswap.com/v1/payments?customer=cust_1NvQI2eZvKYlo2C0" \
  -H "Authorization: Bearer sk_test_..."
```

## Recurring payments

Customers are required for:

* **Subscriptions** - Automatic recurring billing
* **Payment schedules** - Planned future payments
* **Saved payment methods** - Stored cards or bank accounts

Example subscription creation:

```bash theme={"system"}
curl -X POST https://api.peaswap.com/v1/subscriptions \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cust_1NvQI2eZvKYlo2C0",
    "price": "price_1NvQI2eZvKYlo2C1",
    "payment_behavior": "default_incomplete"
  }'
```

## Customer analytics

Track important customer metrics in your dashboard:

* **Total payments** - Lifetime transaction count
* **Total volume** - Sum of all payments
* **Average transaction** - Mean payment amount
* **Last payment** - Most recent transaction date

Access detailed analytics via API:

```bash theme={"system"}
curl -X GET "https://api.peaswap.com/v1/customers/cust_1NvQI2eZvKYlo2C0/analytics" \
  -H "Authorization: Bearer sk_test_..."
```

## Best practices

### Data quality

* Validate email addresses before saving
* Use consistent naming conventions
* Keep customer information current
* Remove duplicate profiles

### Security

* Never store sensitive payment data in customer records
* Use secure API keys with appropriate permissions
* Implement proper access controls

### Integration

* Create customers before their first payment when possible
* Use customer IDs consistently across your system
* Implement proper error handling for customer operations

## Common use cases

### SaaS platforms

```javascript theme={"system"}
// Create customer during signup
const customer = await peaswap.customers.create({
  name: user.name,
  email: user.email,
  metadata: { user_id: user.id }
});

// Start subscription
const subscription = await peaswap.subscriptions.create({
  customer: customer.id,
  price: 'price_monthly_pro'
});
```

### E-commerce sites

```javascript theme={"system"}
// Create customer at checkout
const customer = await peaswap.customers.create({
  name: orderData.customerName,
  email: orderData.customerEmail,
  phone: orderData.customerPhone
});

// Process payment
const payment = await peaswap.payments.create({
  amount: orderData.total,
  currency: 'usd',
  customer: customer.id
});
```

### Service providers

```javascript theme={"system"}
// Create customer for invoicing
const customer = await peaswap.customers.create({
  name: 'Acme Corporation',
  email: 'accounting@acme.com',
  metadata: { 
    company: 'Acme Corporation',
    contract_id: 'CONTRACT_2024_001'
  }
});
```

## Troubleshooting

### Customer creation fails

* Verify all required fields are provided
* Check that email format is valid
* Ensure API key has customer creation permissions

### Customer not found

* Confirm the customer ID is correct
* Check that customer wasn't deleted
* Verify you're using the correct API environment

### Duplicate customers

* Search existing customers before creating new ones
* Use email as a unique identifier in your system
* Consider implementing customer deduplication logic

## API reference

### Customer object

```json theme={"system"}
{
  "id": "cust_1NvQI2eZvKYlo2C0",
  "object": "customer",
  "name": "John Doe", 
  "email": "john.doe@example.com",
  "phone": "+1234567890",
  "created": 1640995200,
  "updated": 1640995200,
  "metadata": {}
}
```

### Endpoints

* `POST /v1/customers` - Create a customer
* `GET /v1/customers` - List all customers
* `GET /v1/customers/:id` - Retrieve a customer
* `PUT /v1/customers/:id` - Update a customer
* `DELETE /v1/customers/:id` - Delete a customer

For complete API documentation, see our [API Reference](/api-reference).

## Next steps

* Review [Webhooks](/essentials/explore-pesaswap/payment-orchestration/accept-payments/webhooks) to stay updated on customer events
