# Airtime Purchase

## Airtime&#x20;

<mark style="color:green;">`POST`</mark> `{{base_url}}/airtime`

Network ID - MTN = 2,  GLO = 1, AIRTEL = 3, 9MOBILE = 4

#### Headers

| Name                                            | Type       | Description                      |
| ----------------------------------------------- | ---------- | -------------------------------- |
| authorization<mark style="color:red;">\*</mark> | SECRET KEY | Set value to `Bearer SECRET_KEY` |

#### Request Body

| Name                                          | Type   | Description                                |
| --------------------------------------------- | ------ | ------------------------------------------ |
| phoneno<mark style="color:red;">\*</mark>     | String |                                            |
| network\_id<mark style="color:red;">\*</mark> | String | Network id for each network as shown above |
| amount<mark style="color:red;">\*</mark>      | String |                                            |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": true,
    "message": "Success",
    "txref": "API665023309a400",
    "charged": 4900.5,
    "newbal": 570004.3
}
```

{% endtab %}
{% endtabs %}

Take a look at how you might do this:

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request POST 'https://api.oneappgo.com/v1/airtime' \
--header 'Authorization: Bearer SECRET_KEY' \
--form 'phoneno="07012345678"' \
--form 'network_id="2"' \
--form 'reference="O4I3U8SRNYOIYT"' \
--form 'amount="5000"'
```

{% endtab %}

{% tab title="NodeJs" %}

```
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.oneappgo.com/v1/airtime',
  'headers': {
    'Authorization': 'Bearer SECRET_KEY'
  },
  formData: {
    'phoneno': '07012345678',
    'network_id': '2',
    'reference': 'O4I3U8SRNYOIYT',
    'amount': '5000'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endtab %}

{% tab title="PHP - cURL" %}

<pre><code><strong>$curl = curl_init();
</strong>
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.oneappgo.com/v1/airtime',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('phoneno' => '07012345678','network_id' => '2','reference' => 'O4I3U8SRNYOIYT','amount' => '5000'),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer SECRET_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

</code></pre>

{% endtab %}

{% tab title="Python" %}

```
import requests

url = "https://api.oneappgo.com/v1/airtime"

payload={'phoneno': '07012345678',
'network_id': '2',
'reference': 'O4I3U8SRNYOIYT',
'amount': '5000'}
files=[

]
headers = {
  'Authorization': 'Bearer SECRET_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}

{% tab title="Dart" %}

```
var headers = {
  'Authorization': 'Bearer SECRET_KEY'
};
var request = http.MultipartRequest('POST', Uri.parse('https://api.oneappgo.com/v1/airtime'));
request.fields.addAll({
  'phoneno': '07012345678',
  'network_id': '2',
  'reference': 'O4I3U8SRNYOIYT',
  'amount': '5000'
});

request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
}
else {
  print(response.reasonPhrase);
}

```

{% endtab %}
{% endtabs %}

### Sample Response

```json
{
    "status": true,
    "message": "Success",
    "txref": "API665023309a400",
    "charged": 4900.5,
    "newbal": 570004.3
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.1app.online/v1-1/airtime-purchase.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
