Rentals
Beta6 endpoints, each naming the scope its key must carry.
The rental object
Every endpoint below returns this shape, whole or in a list. Money is an integer number of cents with its currency; times are UTC instants.
objectstringidstringstatusstringserviceserviceidstringnamestringcountrystringphone_numberstringpriceapimoneyamountintegercurrencystringdurationstringclient_referencestringcreated_attimestampexpires_attimestampextended_attimestampcancel_available_untiltimestampmessages_countintegermessagesarray of messageobjectstringidstringreceived_attimestampfromstringtextstringcodestring
{
"object": "activation",
"id": "…",
"status": "…",
"service": {
"id": "…",
"name": "…"
},
"country": "…",
"phone_number": "…",
"price": {
"amount": 0,
"currency": "…"
},
"duration": "…",
"client_reference": "…",
"created_at": "2026-09-18T10:35:00Z",
"expires_at": "2026-09-18T10:35:00Z",
"extended_at": "2026-09-18T10:35:00Z",
"cancel_available_until": "2026-09-18T10:35:00Z",
"messages_count": 0,
"messages": [
{
"object": "activation",
"id": "…",
"received_at": "2026-09-18T10:35:00Z",
"from": "…",
"text": "…",
"code": "…"
}
]
}status, in order
waiting_for_codeLive and receiving. Messages accumulate for as long as the rental runs.code_receivedAt least one message has arrived. The rental keeps running.completedThe rental passed its expires_at. Terminal — nothing marks it earlier.refundedCancelled inside the refund window; the price went back. Terminal.
GET /v1/rentals
scoperentals:readList rentals, newest first
Query parameters
limitintegercursorstringclient_referencestring
Returns
objectstringdataarray of rentalobjectstringidstringstatusstringserviceservicecountrystringphone_numberstringpriceapimoneydurationstringclient_referencestringcreated_attimestampexpires_attimestampextended_attimestampcancel_available_untiltimestampmessages_countintegermessagesarray of messagehas_morebooleannext_cursorstring
curl https://api.ghostsms.io/v1/rentals \
-H "Authorization: Bearer $GHOSTSMS_KEY"{
"object": "activation",
"data": [
{
"object": "activation",
"id": "…",
"status": "…",
"service": "…",
"country": "…",
"phone_number": "…",
"price": "…",
"duration": "…",
"client_reference": "…",
"created_at": "2026-09-18T10:35:00Z",
"expires_at": "2026-09-18T10:35:00Z",
"extended_at": "2026-09-18T10:35:00Z",
"cancel_available_until": "2026-09-18T10:35:00Z",
"messages_count": 0,
"messages": []
}
],
"has_more": false,
"next_cursor": "…"
}POST /v1/rentals
scoperentals:writeRent a number. Requires an Idempotency-Key.
Headers
Idempotency-KeystringRequired- A key you generate per attempt. Retrying with the same key returns the first outcome instead of buying again.
Body
countrystringRequiredduration_hoursintegerRequiredclient_referencestringmax_priceinteger
What this refuses
- 402
insufficient_balance - The balance does not cover the price. Nothing was charged.
- 403
daily_spend_limit_reached - This purchase would take today's API spending over the account's daily limit. Nothing was charged.
- 409
price_above_maximum - The price is higher than the max_price sent with the request. Nothing was charged.
- 409
number_unavailable - No number could be bought for this right now. Nothing was charged; it may succeed if retried later.
- 400
idempotency_key_required - This request spends money or changes a number. Send an Idempotency-Key header, unique per operation, so a retry after a timeout cannot do it twice.
- 422
idempotency_key_reused - This Idempotency-Key was already used for a different request. Use a new key for a new operation.
- 409
idempotency_request_in_progress - The first request with this Idempotency-Key has not finished. Retry with the same key shortly.
Plus the refusals every endpoint shares — see Errors.
curl https://api.ghostsms.io/v1/rentals \
-X POST \
-H "Authorization: Bearer $GHOSTSMS_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"country":"your-country","duration_hours":0}'GET /v1/rentals/{id}
scoperentals:readRetrieve a rental with its most recent messages
Returns
objectstringidstringstatusstringserviceserviceidstringnamestringcountrystringphone_numberstringpriceapimoneyamountintegercurrencystringdurationstringclient_referencestringcreated_attimestampexpires_attimestampextended_attimestampcancel_available_untiltimestampmessages_countintegermessagesarray of messageobjectstringidstringreceived_attimestampfromstringtextstringcodestring
curl https://api.ghostsms.io/v1/rentals/{id} \
-H "Authorization: Bearer $GHOSTSMS_KEY"{
"object": "activation",
"id": "…",
"status": "…",
"service": {
"id": "…",
"name": "…"
},
"country": "…",
"phone_number": "…",
"price": {
"amount": 0,
"currency": "…"
},
"duration": "…",
"client_reference": "…",
"created_at": "2026-09-18T10:35:00Z",
"expires_at": "2026-09-18T10:35:00Z",
"extended_at": "2026-09-18T10:35:00Z",
"cancel_available_until": "2026-09-18T10:35:00Z",
"messages_count": 0,
"messages": [
{
"object": "activation",
"id": "…",
"received_at": "2026-09-18T10:35:00Z",
"from": "…",
"text": "…",
"code": "…"
}
]
}POST /v1/rentals/{id}/cancel
scoperentals:writeCancel a rental inside its refund window; the price is refunded
Headers
Idempotency-KeystringRequired- A key you generate per attempt. Retrying with the same key returns the first outcome instead of buying again.
What this refuses
- 409
cancel_window_closed - This rental can no longer be cancelled for a refund. It stays yours until it expires.
- 409
cancel_refused - The supplier refused to take the number back. It stays active and nothing was refunded.
- 409
not_active - This activation or rental has already ended.
- 409
request_conflict - The request conflicts with the current state of this activation or rental. Retrieve it and try again.
- 400
idempotency_key_required - This request spends money or changes a number. Send an Idempotency-Key header, unique per operation, so a retry after a timeout cannot do it twice.
Plus the refusals every endpoint shares — see Errors.
curl https://api.ghostsms.io/v1/rentals/{id}/cancel \
-X POST \
-H "Authorization: Bearer $GHOSTSMS_KEY" \
-H "Idempotency-Key: $(uuidgen)"POST /v1/rentals/{id}/extend
scoperentals:writeExtend a rental. Requires an Idempotency-Key.
Headers
Idempotency-KeystringRequired- A key you generate per attempt. Retrying with the same key returns the first outcome instead of buying again.
Body
duration_hoursintegerRequiredmax_priceinteger
What this refuses
- 402
insufficient_balance - The balance does not cover the price. Nothing was charged.
- 403
daily_spend_limit_reached - This purchase would take today's API spending over the account's daily limit. Nothing was charged.
- 409
not_active - This activation or rental has already ended.
- 409
request_conflict - The request conflicts with the current state of this activation or rental. Retrieve it and try again.
- 400
idempotency_key_required - This request spends money or changes a number. Send an Idempotency-Key header, unique per operation, so a retry after a timeout cannot do it twice.
Plus the refusals every endpoint shares — see Errors.
curl https://api.ghostsms.io/v1/rentals/{id}/extend \
-X POST \
-H "Authorization: Bearer $GHOSTSMS_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"duration_hours":0}'GET /v1/rentals/{id}/messages
scoperentals:readList a rental's messages, newest first
Query parameters
limitintegercursorstring
Returns
objectstringdataarray of messageobjectstringidstringreceived_attimestampfromstringtextstringcodestringhas_morebooleannext_cursorstring
curl https://api.ghostsms.io/v1/rentals/{id}/messages \
-H "Authorization: Bearer $GHOSTSMS_KEY"{
"object": "activation",
"data": [
{
"object": "activation",
"id": "…",
"received_at": "2026-09-18T10:35:00Z",
"from": "…",
"text": "…",
"code": "…"
}
],
"has_more": false,
"next_cursor": "…"
}