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

# Purchase Data

> Learn how to fetch data plans and purchase mobile data bundles.

## Overview

The Data Purchase API allows you to fetch available data plans for a specific network provider and complete a data purchase for a customer.

To begin, retrieve the list of available plans using the **Get Data Plans** endpoint. Once the customer selects a preferred plan, you can complete the purchase using the **Purchase Data** endpoint.

<Info>
  Each mobile network provider has a unique `serviceId`. Always pass the correct one to ensure successful transactions.
</Info>

## Get Data Plans

Use this endpoint `api/v1/BillsPayment/dataplans?serviceId=string` to retrieve all available data plans for a specific network provider. Don't forget to retrieve the service providers for data purchase [here](/docs/make-payment/bills/retrieve-bills-service-providers)
You’ll need to include the provider’s `serviceId` in your query parameters.

```bash Request theme={null}
curl --request GET \
  --url https://integrations.novacpayment.com/api/v1/BillsPayment/dataplans?serviceId=string\
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
```

```json expandable Response theme={null}
{
    "code": 200,
    "status": "success",
    "message": "Successful",
    "data": {
        "serviceId": "D04D",
        "dataPlans": [
            {
                "amount": 100,
                "databundle": "110MB",
                "productId": "MTN-110MB-11",
                "validity": "1 Day"
            },
            {
                "amount": 200,
                "databundle": "230MB",
                "productId": "MTN-200MB-2",
                "validity": "1 Day"
            }
        ],
        "isSuccessful": true,
        "message": "Successful",
        "processingProvider": ""
    }
}
```

The response includes a list of available plans with their amount, bundle size, and validity period.
Each plan also includes a `productId`, which is required for completing the purchase.

## Purchase Data

After retrieving the available data plans, use this endpoint to purchase a selected plan for a customer.

You’ll need to include the `serviceId`, `productId`, `amount`, and the customer’s `phoneNumber`.
If you don’t provide a `reference`, Novac Payment will automatically generate one for you.

<Note>
  Novac uses a reference to track transactions, so it's important to include it; if you don't, we will generate one.
</Note>

```bash expandable Request theme={null}
curl --request POST \
  --url https://integrations.novacpayment.com/api/v1/BillsPayment/initiatedatapurchase \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "serviceId":"D04D",
    "productId":"MTN-200MB-2",
    "amount": 200,
    "phoneNumber":"09011111222",
    "reference": ""
  }'
```

```json expandable Response theme={null}
{
    "code": 200,
    "status": "success",
    "message": "Your transaction is in progress.",
    "data": {
        "status": "pending",
        "message": "Your transaction is in progress.",
        "reference": "reference",
        "amount": 200,
        "fee": 0.00.
        "Domain": “test”
    }
}
```

A successful request returns the transaction status and reference details.
You can track the transaction using the reference or display a “Transaction in progress” message to your customer while awaiting confirmation.
