Docs menu

Refills — API reference

Restore a receiver’s USED energy or bandwidth now (it does not raise the limit). Bought from the cheapest venue whose size range covers the amount; you pay the venue price plus your routing fee (the same fee tiers as orders). Charged when created; once the venue reports, the part it did not restore is refunded at the charged unit price. Uses the orders.create / orders.read scopes. Answers 3033 refills_unavailable while no venue is enabled on the deployment.

MethodPathSummary
GET/v1/refillsList refills
POST/v1/refillsCreate a refill
GET/v1/refills/{refillId}Refill detail

Base URL https://api.tenergy.me/v1, or https://api-nile.tenergy.me/v1 on Nile (Environments). Every request below is signed as in Authentication unless its Auth line says otherwise.

List refills

GET /v1/refills · listRefills

Auth: API key (HMAC).

Newest first. Filters combine with AND.

Parameters

NameInTypeRequiredDescription
statusquerystringOne or more of paid, submitted, completed, failed, comma-separated or repeated.
resourcequeryenum: energy, bandwidth
receiverquerystring
client_order_idquerystring
limitqueryinteger
cursorquerystring

Responses

StatusMeaning
200OK
400Malformed request — bad JSON, unknown field, wrong type.
401Missing, malformed or rejected credentials.
429Too many requests.

Response fields (RefillList)

FieldTypeRequiredDescription
dataarray of object (Refill)yes
data[].idstringyes
data[].objectstringyes
data[].client_order_idstring | null
data[].statusenum: created, paid, submitted, completed, failedyes
data[].resourceenum: energy, bandwidthyes
data[].receiverstringyes
data[].requested_amountintegeryes
data[].restored_amountinteger | nullUnits the venue restored; set when completed.
data[].price_sun_per_unitnumber | nullCharged SUN per requested unit (venue price + fee).
data[].fee_bpsintegeryes
data[].fee_sourceenum: tier, promo
data[].total_sunintegeryesCharged when created.
data[].captured_suninteger | nullKept at settlement: restored x unit price, rounded down.
data[].refunded_sunintegeryes
data[].delegate_txidstring | null
data[].reclaim_txidstring | null
data[].error_codestring | null
data[].labelstring | null
data[].group_idstring | null
data[].created_atstring (date-time)yes
data[].updated_atstring (date-time)
data[].completed_atstring (date-time) | null
next_cursorstring | nullyes

Create a refill

POST /v1/refills · createRefill

Auth: API key (HMAC).

Quotes every enabled venue for amount, picks the lowest TOTAL cost (unit price x amount + the venue’s fixed fee) among venues whose size range covers amount, charges the balance and places the order. One refill is one venue; it is never split.

Refused before any charge: 2008 amount_out_of_range when amount is outside the accepted range for the resource (details.min_amount, details.max_amount, also published in GET /v1/prices under refills) or above what the receiver has used now (details.restorable_max); 3036 nothing_to_refill when the receiver has used nothing (or less than the smallest refill); 3035 no_base_resource when it has no limit at all; 3033 refills_unavailable when no venue is enabled or none answered.

status: paid (charged) -> submitted (venue order placed) -> completed (venue reported; restored_amount set, the unrestored part refunded in refunded_sun) | failed (fully refunded). Webhooks refill.completed, refill.failed. Idempotent on client_order_id / Idempotency-Key like orders: the same body returns 200 and the original.

Parameters

NameInTypeRequiredDescription
Idempotency-KeyheaderstringClient-chosen key making this mutating request safe to retry, 8–128 characters of A-Z a-z 0-9 . _ : -. A repeat with the same key and the same body returns the original result; the same key with a different body is rejected with 3010 idempotency_conflict. Records live for 24 hours.

Request body

JSON (RefillRequest), required.

FieldTypeRequiredDescription
client_order_idstring
receiverstringyesThe address whose used resource is restored.
resourceenum: energy, bandwidth
amountintegerUnits to restore. Required (or its alias energy).
energyintegerAlias of amount.
max_price_sunintegerRefuse with 3006 if the total is higher.
group_idstring
labelstring

Example request body, from the contract (illustrative values):

json
{
  "client_order_id": "acme-refill-000001",
  "receiver": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
  "resource": "energy",
  "amount": 300000
}

Responses

StatusMeaning
200Replay of an existing client_order_id; nothing charged.
201Refill created and charged.
400Malformed request — bad JSON, unknown field, wrong type.
401Missing, malformed or rejected credentials.
402Not enough balance to cover the order.
409The request contradicts the current state of the object.
422Syntactically valid but semantically impossible.
429Too many requests.
500Something broke on our side.
503Temporarily unable to serve. On order creation this is fail-secure: nothing was stored and nothing was charged, so retrying verbatim with the same client_order_id is safe.

Response fields (Refill)

FieldTypeRequiredDescription
idstringyes
objectstringyes
client_order_idstring | null
statusenum: created, paid, submitted, completed, failedyes
resourceenum: energy, bandwidthyes
receiverstringyes
requested_amountintegeryes
restored_amountinteger | nullUnits the venue restored; set when completed.
price_sun_per_unitnumber | nullCharged SUN per requested unit (venue price + fee).
fee_bpsintegeryes
fee_sourceenum: tier, promo
total_sunintegeryesCharged when created.
captured_suninteger | nullKept at settlement: restored x unit price, rounded down.
refunded_sunintegeryes
delegate_txidstring | null
reclaim_txidstring | null
error_codestring | null
labelstring | null
group_idstring | null
created_atstring (date-time)yes
updated_atstring (date-time)
completed_atstring (date-time) | null

Refill detail

GET /v1/refills/{refillId} · getRefill

Auth: API key (HMAC).

A submitted refill is brought up to date with its venue on every read.

Parameters

NameInTypeRequiredDescription
refillIdpathstringyesThe refill id (rfl_...) or cid:<client_order_id>.

Responses

StatusMeaning
200OK
401Missing, malformed or rejected credentials.
404No such object, or it belongs to another account. The two are not distinguished.
429Too many requests.

Response fields (Refill)

FieldTypeRequiredDescription
idstringyes
objectstringyes
client_order_idstring | null
statusenum: created, paid, submitted, completed, failedyes
resourceenum: energy, bandwidthyes
receiverstringyes
requested_amountintegeryes
restored_amountinteger | nullUnits the venue restored; set when completed.
price_sun_per_unitnumber | nullCharged SUN per requested unit (venue price + fee).
fee_bpsintegeryes
fee_sourceenum: tier, promo
total_sunintegeryesCharged when created.
captured_suninteger | nullKept at settlement: restored x unit price, rounded down.
refunded_sunintegeryes
delegate_txidstring | null
reclaim_txidstring | null
error_codestring | null
labelstring | null
group_idstring | null
created_atstring (date-time)yes
updated_atstring (date-time)
completed_atstring (date-time) | null

    ↑ ↓ to move · Enter to open · Esc to close