Skip to main content
POST
/
v1
/
customers
/
{id}
/
credits
/
{productId}
/
topup
Topup credits
curl --request POST \
  --url https://api.hyperline.co/v1/customers/{id}/credits/{productId}/topup \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "credit_count": 32,
  "expires_at": "2024-12-20T16:04:11Z"
}
'
import requests

url = "https://api.hyperline.co/v1/customers/{id}/credits/{productId}/topup"

payload = {
    "credit_count": 32,
    "expires_at": "2024-12-20T16:04:11Z"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({credit_count: 32, expires_at: '2024-12-20T16:04:11Z'})
};

fetch('https://api.hyperline.co/v1/customers/{id}/credits/{productId}/topup', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.hyperline.co/v1/customers/{id}/credits/{productId}/topup",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'credit_count' => 32,
    'expires_at' => '2024-12-20T16:04:11Z'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.hyperline.co/v1/customers/{id}/credits/{productId}/topup"

	payload := strings.NewReader("{\n  \"credit_count\": 32,\n  \"expires_at\": \"2024-12-20T16:04:11Z\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.hyperline.co/v1/customers/{id}/credits/{productId}/topup")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"credit_count\": 32,\n  \"expires_at\": \"2024-12-20T16:04:11Z\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.hyperline.co/v1/customers/{id}/credits/{productId}/topup")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"credit_count\": 32,\n  \"expires_at\": \"2024-12-20T16:04:11Z\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "cdt_BPZ19obsBS2qyo",
  "product_id": "itm_3kXODDF42QXtnL",
  "price": {
    "id": "pri_0Jv8EbMDOGsHcn",
    "amount": 20000,
    "pack_size": 120
  },
  "customer_id": "cus_Typ0px2W0aiEtl",
  "payment_method_id": "pm_1xMpj5bwRqN7LM",
  "invoice_id": "inv_1eTaiytfA0i2Va",
  "event_id": null,
  "aggregator_id": null,
  "expires_at": null,
  "type": "topup",
  "source": "system",
  "amount_excluding_tax": 123,
  "credit_count": 32,
  "balance_after": 2000,
  "created_at": "2024-10-13T07:00:01.860Z",
  "updated_at": "2024-10-13T07:00:01.860Z"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required
productId
string
required

Body

application/json

Credit topup payload

credit_count
number
required

Value indicating a number of credits to add. If price_id is defined, this value must correspond to a full credit pack for the price.

Example:

32

expires_at
string<date-time>

Expiration date for credits linked to this transaction. UTC date time string in the ISO 8601 format.

Example:

"2024-12-20T16:04:11Z"

Response

201 - application/json

The created credit transaction

id
string
required

Credit transaction ID.

Example:

"cdt_BPZ19obsBS2qyo"

product_id
string | null
required

ID of the product related to the transaction.

Example:

"itm_3kXODDF42QXtnL"

price
object | null
required

Price details related to the transaction.

Example:
{
  "id": "pri_0Jv8EbMDOGsHcn",
  "amount": 20000,
  "pack_size": 120
}
customer_id
string
required

ID of the customer related to the transaction.

Example:

"cus_Typ0px2W0aiEtl"

payment_method_id
string | null
required

ID of the payment method related to the transaction.

Example:

"pm_1xMpj5bwRqN7LM"

invoice_id
string | null
required

ID of the invoice related to the transaction.

Example:

"inv_1eTaiytfA0i2Va"

event_id
string | null
required

ID of the event related to the credit consumption.

Example:

null

aggregator_id
string | null
required

ID of the aggregator that triggered this usage (for multi-aggregator credits).

Example:

null

expires_at
string<date> | null
required

Expiration date for credits linked to this transaction

Example:

null

type
enum<string>
required

Type of credit transaction.

Available options:
topup,
usage,
expiration
Example:

"topup"

source
enum<string>
required
deprecated

Deprecated field, we recommend no longer using it.

Available options:
app,
portal,
api,
system
Example:

"system"

amount_excluding_tax
number | null
required

Monetary amount. Expressed in currency's smallest unit.

credit_count
number
required

Value of credits related to the transaction.

Example:

32

balance_after
number
required

Credit balance after the transaction.

Example:

2000

created_at
string<date-time>
required

Credit transaction creation date. UTC date time string in the ISO 8601 format.

Example:

"2024-10-13T07:00:01.860Z"

updated_at
string<date-time>
required

Credit transaction last edition date. UTC date time string in the ISO 8601 format.

Example:

"2024-10-13T07:00:01.860Z"