> ## Documentation Index
> Fetch the complete documentation index at: https://better-auth-razorpay.amankushwaha.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Customers

> Create, retrieve, list, edit, and manage Razorpay customers and their bank accounts and tokens through the plugin endpoints.

The customers endpoints let you create Razorpay customers, update their details, list and fetch customers, manage bank accounts, and handle saved tokens.

## Create customer

`POST /api/auth/razorpay/customer/create`

Creates a new Razorpay customer.

**Server API name:** `createCustomer`\
**Client method:** `authClient.razorpay.customer.create(...)`

**name** `string`

Customer name.

**email** `string`

Customer email address.

**contact** `string`

Customer phone number with country code.

**failExisting** `boolean`

Whether to fail if a customer with the same email or contact already exists.

**gstin** `string`

Customer GSTIN for tax purposes.

**notes** `object`

Up to 15 key-value pairs for internal metadata.

> [!NOTE]
>
> Errors: `UNABLE_TO_CREATE_CUSTOMER`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.create({
  name: "Aman Kumar",
  email: "aman@example.com",
  contact: "+919876543210",
  notes: { source: "web" },
});
```

```ts server.ts theme={null}
const result = await auth.api.createCustomer({
  body: {
    name: "Aman Kumar",
    email: "aman@example.com",
    contact: "+919876543210",
    notes: { source: "web" },
  },
  headers: await headers(),
});
```

## Edit customer

`POST /api/auth/razorpay/customer/edit`

Updates an existing Razorpay customer.

**Server API name:** `editCustomer`\
**Client method:** `authClient.razorpay.customer.edit(...)`

**customerId** `string` *required*

Razorpay customer id.

**name** `string`

Updated customer name.

**email** `string`

Updated customer email.

**contact** `string`

Updated customer phone number.

**gstin** `string`

Updated GSTIN.

**notes** `object`

Updated notes object.

> [!NOTE]
>
> Errors: `CUSTOMER_EDIT_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.edit({
  customerId: "cust_XXXX",
  name: "Aman Kumar Updated",
});
```

```ts server.ts theme={null}
const result = await auth.api.editCustomer({
  body: {
    customerId: "cust_XXXX",
    name: "Aman Kumar Updated",
  },
  headers: await headers(),
});
```

## List customers

`GET /api/auth/razorpay/customer/list`

Lists Razorpay customers with pagination.

**Server API name:** `listCustomers`\
**Client method:** `authClient.razorpay.customer.list({ query: { ... } })`

**from** `integer`

Unix timestamp. Return customers created after this time.

**to** `integer`

Unix timestamp. Return customers created before this time.

**count** `integer`

Maximum number of customers to return. Maximum value is `100`.

**skip** `integer`

Number of customers to skip.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.list({
  query: { count: 10, skip: 0 },
});
```

```ts server.ts theme={null}
const result = await auth.api.listCustomers({
  query: { count: 10, skip: 0 },
  headers: await headers(),
});
```

## Get customer

`GET /api/auth/razorpay/customer/get`

Retrieves a single Razorpay customer by id.

**Server API name:** `fetchCustomer`\
**Client method:** `authClient.razorpay.customer.get({ query: { customerId } })`

**customerId** `string` *required*

Razorpay customer id.

> [!NOTE]
>
> Errors: `CUSTOMER_NOT_FOUND`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.get({
  query: { customerId: "cust_XXXX" },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchCustomer({
  query: { customerId: "cust_XXXX" },
  headers: await headers(),
});
```

## Add bank account

`POST /api/auth/razorpay/customer/bank-account`

Adds a bank account to an existing Razorpay customer.

**Server API name:** `addBankAccount`\
**Client method:** `authClient.razorpay.customer.bankAccount.create(...)`

**customerId** `string` *required*

Razorpay customer id.

**ifsc\_code** `string` *required*

IFSC code of the bank branch.

**account\_number** `string` *required*

Bank account number.

**beneficiary\_name** `string`

Name of the account holder.

> [!NOTE]
>
> Errors: `BANK_ACCOUNT_ADD_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.bankAccount.create({
  customerId: "cust_XXXX",
  ifsc_code: "HDFC0000123",
  account_number: "123456789012",
  beneficiary_name: "Aman Kumar",
});
```

```ts server.ts theme={null}
const result = await auth.api.addBankAccount({
  body: {
    customerId: "cust_XXXX",
    ifsc_code: "HDFC0000123",
    account_number: "123456789012",
    beneficiary_name: "Aman Kumar",
  },
  headers: await headers(),
});
```

## Delete bank account

`POST /api/auth/razorpay/customer/bank-account/delete`

Deletes a bank account from a Razorpay customer.

**Server API name:** `deleteBankAccount`\
**Client method:** `authClient.razorpay.customer.bankAccount.delete(...)`

**customerId** `string` *required*

Razorpay customer id.

**bankAccountId** `string` *required*

Bank account id to delete.

> [!NOTE]
>
> Errors: `BANK_ACCOUNT_DELETE_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.bankAccount.delete({
  customerId: "cust_XXXX",
  bankAccountId: "ba_YYYY",
});
```

```ts server.ts theme={null}
const result = await auth.api.deleteBankAccount({
  body: {
    customerId: "cust_XXXX",
    bankAccountId: "ba_YYYY",
  },
  headers: await headers(),
});
```

## Fetch tokens

`GET /api/auth/razorpay/customer/tokens`

Lists saved tokens for a Razorpay customer.

**Server API name:** `fetchTokens`\
**Client method:** `authClient.razorpay.customer.tokens({ query: { customerId } })`

**customerId** `string` *required*

Razorpay customer id.

> [!NOTE]
>
> Errors: `TOKEN_FETCH_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.tokens({
  query: { customerId: "cust_XXXX" },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchTokens({
  query: { customerId: "cust_XXXX" },
  headers: await headers(),
});
```

## Fetch token

`GET /api/auth/razorpay/customer/token`

Retrieves a single saved token for a Razorpay customer.

**Server API name:** `fetchToken`\
**Client method:** `authClient.razorpay.customer.token({ query: { customerId, tokenId } })`

**customerId** `string` *required*

Razorpay customer id.

**tokenId** `string` *required*

Token id.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.token({
  query: { customerId: "cust_XXXX", tokenId: "token_YYYY" },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchToken({
  query: { customerId: "cust_XXXX", tokenId: "token_YYYY" },
  headers: await headers(),
});
```

## Delete token

`POST /api/auth/razorpay/customer/token/delete`

Deletes a saved token for a Razorpay customer.

**Server API name:** `deleteToken`\
**Client method:** `authClient.razorpay.customer.token.delete(...)`

**customerId** `string` *required*

Razorpay customer id.

**tokenId** `string` *required*

Token id to delete.

> [!NOTE]
>
> Errors: `TOKEN_DELETE_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.customer.token.delete({
  customerId: "cust_XXXX",
  tokenId: "token_YYYY",
});
```

```ts server.ts theme={null}
const result = await auth.api.deleteToken({
  body: {
    customerId: "cust_XXXX",
    tokenId: "token_YYYY",
  },
  headers: await headers(),
});
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.