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

# Api reference

# API Reference

The fype API is organized around REST. All requests should be made to `https://api.fype.dev/v1`.

## Payments

### Create a Payment

`POST /payments`

Create a new payment and generate a hosted checkout URL.

**Request Body**

| Field            | Type    | Required | Description                                                                                                    |
| :--------------- | :------ | :------- | :------------------------------------------------------------------------------------------------------------- |
| `amount`         | integer | Yes      | Amount in subunits (e.g., 50000 for ₹500.00). Min 100.                                                         |
| `currency`       | string  | Yes      | 3-letter ISO currency code. Default `INR`.                                                                     |
| `customer_email` | string  | Yes      | Email address of the customer.                                                                                 |
| `customer_phone` | string  | No       | Phone number of the customer.                                                                                  |
| `customer_name`  | string  | No       | Full name of the customer.                                                                                     |
| `reference_id`   | string  | No       | Your internal order/transaction ID.                                                                            |
| `success_url`    | string  | Yes      | URL to redirect to after successful payment. Supports `{CHECKOUT_SESSION_ID}` and `{PAYMENT_ID}` placeholders. |
| `cancel_url`     | string  | Yes      | URL to redirect to if the customer cancels.                                                                    |
| `metadata`       | object  | No       | Key-value pairs for your own tracking.                                                                         |

**Headers**

* `Authorization: Bearer <API_KEY>`
* `Idempotency-Key: <UNIQUE_STRING>` (Optional but recommended)

***

### Retrieve a Payment

`GET /payments/{payment_id}`

Get the current status and details of a payment.

***

### List Payments

`GET /payments`

List all payments for your merchant account.

**Query Parameters**

| Parameter | Type    | Default | Description                  |
| :-------- | :------ | :------ | :--------------------------- |
| `limit`   | integer | 20      | Number of results to return. |
| `cursor`  | string  | null    | Cursor for pagination.       |

***

## Refunds

### Create a Refund

`POST /payments/{payment_id}/refund`

Initiate a full or partial refund for a successful payment.

**Request Body**

| Field    | Type    | Required | Description                                               |
| :------- | :------ | :------- | :-------------------------------------------------------- |
| `amount` | integer | No       | Amount to refund. If omitted, a full refund is processed. |

***

## Webhook Endpoints

### Create Endpoint

`POST /webhooks/endpoints`

**Request Body**

| Field  | Type   | Required | Description                            |
| :----- | :----- | :------- | :------------------------------------- |
| `url`  | string | Yes      | The URL where fype should send events. |
| `mode` | string | Yes      | `test` or `live`.                      |

***

### List Endpoints

`GET /webhooks/endpoints`

***

### Delete Endpoint

`DELETE /webhooks/endpoints/{endpoint_id}`
