Rentals
.md

Rent a number

POST/v1/rentals

Charges one billing period from your wallet and assigns a number right away. Rentals created through the API never auto-renew: the number is yours until expires_at, then the rental ends on its own. Renewal is not available through the API yet.

Send Idempotency-Key: <uuid> to make retries safe — a replay with the same key returns the rental created by the first request instead of renting a second number.

Pass the price_cents you saw in GET /rentals/plans as max_price_cents: if the plan has been repriced above it since, you get 412 PRICE_CHANGED and nothing is charged — re-read the plans and retry.

tier is optional. When you omit it, the rental is created on whichever of the two tiers is cheaper for that country / service / duration — the same choice the dashboard makes by default. Note that the two tiers are not always the same product: a standard plan for a specific service may be fulfilled by a number rented for any service, while premium plans are dedicated to the requested service. Pass tier to pin one.

REQUEST
API Serverhttps://api.dogesms.com/v1
AuthenticationAuthorization: Bearer sk_live_… or X-API-Key
REQUEST BODY application/jsonRequired
OBJECT
{
country_code*: string
ISO 3166-1 alpha-2.
service_code: string
Optional. Omit (or send an empty string) to rent a number for any service, where a plan allows it.
duration_days*: integer
Billing period in days (1–365). Must match a plan from GET /rentals/plans; values outside 1–365 are rejected with VALIDATION_ERROR before any plan lookup.
max_price_cents: integer
Optional cap on what you are willing to pay for the first period, in cents. Send the plan price you saw; if the plan is now priced above it you get 412 PRICE_CHANGED and nothing is charged. Omitted = pay the current plan price.
tier: enum
Optional quality tier, as listed in GET /rentals/plans. Omitted = the cheaper of the two tiers available for that country / service / duration (on a tie, standard); pass it to pin a tier. Any other value is a 400 VALIDATION_ERROR; a tier with no plan for that country / service / duration is 404 RENTAL_PLAN_NOT_FOUND.
Allowed: standard | premium
}
REQUEST HEADERS
NameTypeRequiredDescription
Idempotency-Keystring (uuid)Optional—
Request examples
curl -X POST "https://api.dogesms.com/v1/rentals" \
  -H "Authorization: Bearer sk_live_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"country_code":"CA","service_code":"whatsapp","duration_days":30,"max_price_cents":1250,"tier":"standard"}'
RESPONSE

Rental created and number assigned.

application/json
OBJECT
{
data: {
id: string
status: enum
Rentals created through the API never auto-renew, so payment_pending only appears on rentals created in the dashboard.
Allowed: active | payment_pending | expired | refunded | force_released
phone_number: string
E.164 with the leading +. Present in every status, including after the rental ended.
country_code: string
service_code: stringnull
null = rented for any service.
duration_days: integer
tier: enum
Quality tier of the plan this rental was created from.
Allowed: standard | premium
price_cents: integer
Charged for the period at creation.
currency: string
auto_renew: boolean
Always false for rentals created through the API.
started_at: string
expires_at: string
The number is yours until this moment.
released_at: stringnull
Set once the rental has ended.
created_at: string
}
request_id: string
}
ERROR CODES
StatusCodeWhen
400
VALIDATION_ERROR
VALIDATION_ERROR — missing country_code, duration_days outside 1–365, non-positive max_price_cents, an unknown tier, or a malformed Idempotency-Key.
401
API_KEY_MISSING
API_KEY_INVALID_FORMAT
API_KEY_INVALID
API_KEY_REVOKED
Missing or invalid API key (API_KEY_MISSING, API_KEY_INVALID_FORMAT, API_KEY_INVALID, API_KEY_REVOKED). Emitted by the auth layer before the handler — flat shape, no request_id.
402
INSUFFICIENT_BALANCE
INSUFFICIENT_BALANCE — top up first; nothing was charged.
403
ACCOUNT_BANNED
EMAIL_NOT_VERIFIED
ACCOUNT_NOT_ACTIVE
Key is valid but the account is not eligible (ACCOUNT_BANNED, EMAIL_NOT_VERIFIED, ACCOUNT_NOT_ACTIVE). Emitted by the auth layer — flat shape.
404
RENTAL_PLAN_NOT_FOUND
RENTAL_PLAN_NOT_FOUND — no plan for that country / service / duration / tier; see GET /rentals/plans.
412
RENTAL_TOS_NOT_ACCEPTED
PRICE_CHANGED
RENTAL_TOS_NOT_ACCEPTED — call POST /rentals/tos-accept first. PRICE_CHANGED — the plan price is above your max_price_cents; nothing was charged, re-read the plans and retry.
503
RENTAL_NO_NUMBERS
RENTAL_NO_NUMBERS — no number available for that country / service right now; nothing was charged. Retry later.

Branch on code, not on the message. Full list: Errors.