API Documentation
Download API docs (Markdown)kartesim gives partners real phone numbers and mobile IPs through two services: long-term number and proxy rentals and per-use OTP sessions. Both are available via the HANDLER_API protocol and the Native REST API.
Request a temporary number, wait for an SMS, receive the OTP code — in one API call cycle. Billed per session, refunded if you cancel before the code arrives.
Rent a dedicated phone number for daily, weekly, or monthly periods. All SMS received on that number is forwarded to your account in real time.
Rent an HTTP/SOCKS5 mobile proxy with a real carrier IP. Each proxy runs on a dedicated device (Android or 4G modem) with a live SIM card.
Authentication
All API requests require your partner API key. How you pass it depends on your protocol.
GET /api/stubs/handler_api.php ?api_key=YOUR_KEY &action=getBalance
curl https://www.kartesim.com/api/v1/otp/request \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"service": "telegram"}'Handler API Reference
Base URL: /api/stubs/handler_api.php — All requests use GET. All responses are plain text.
/api/stubs/handler_api.php?action=getBalanceReturns your current pre-paid balance in USD.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| api_key | string | required | Your API key |
| action | string | required | Must be "getBalance" |
Responses
45.00Your balance in USD999999Fixed sentinel returned for unlimited-balance accounts — not a real balance, and does not change with usageBAD_KEYInvalid or revoked API keycurl 'https://www.kartesim.com/api/stubs/handler_api.php ?api_key=YOUR_KEY&action=getBalance'
45.00
/api/stubs/handler_api.php?action=getCountriesList supported countries with their numeric codes.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| api_key | string | required | Your API key |
| action | string | required | Must be "getCountries" |
Responses
JSON array[{ "id": 7, "name": "Russia" }, ...]curl 'https://www.kartesim.com/api/stubs/handler_api.php ?api_key=YOUR_KEY&action=getCountries'
[
{ "id": 7, "name": "Russia" },
{ "id": 212, "name": "Morocco" }
]/api/stubs/handler_api.php?action=getPricesGet current pricing and available active stock per country and service.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| api_key | string | required | Your API key |
| action | string | required | Must be "getPrices" |
| country | number | optional | Filter by numeric country ID |
| hide_empty | integer | optional | Set to 1 to exclude countries with zero stock from the response |
Responses
JSON object{ "countryId": { "serviceId": { "cost": 0.1, "count": 10 } } }curl 'https://www.kartesim.com/api/stubs/handler_api.php ?api_key=YOUR_KEY&action=getPrices&hide_empty=1'
{
"212": {
"wa": { "cost": 0.15, "count": 12 },
"tg": { "cost": 0.15, "count": 12 }
}
}/api/stubs/handler_api.php?action=getNumberRequest a temporary phone number for OTP verification. Returns a session ID and the assigned number. The session expires after 10 minutes if no SMS arrives.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| api_key | string | required | Your API key |
| action | string | required | Must be "getNumber" |
| service | string | optional | Service name (e.g. "telegram", "whatsapp") — informational only |
| country | integer | optional | Country calling code (e.g. 212 for Morocco). Omit or use 0 for any country. |
Responses
ACCESS_NUMBER:id:numberSession created — id is used for getStatus/setStatus, number is the assigned phone numberNO_NUMBERSNo online ports available matching your requestNO_BALANCEInsufficient balance to cover the OTP feecurl 'https://www.kartesim.com/api/stubs/handler_api.php ?api_key=YOUR_KEY&action=getNumber&service=telegram&country=212'
ACCESS_NUMBER:cma4x9k3b0000abc123:212661234567
/api/stubs/handler_api.php?action=getStatusPoll for the OTP code on an active session. Poll every 5–10 seconds until you receive STATUS_OK or STATUS_CANCEL.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| api_key | string | required | Your API key |
| action | string | required | Must be "getStatus" |
| id | string | required | Session ID from ACCESS_NUMBER response |
Responses
STATUS_WAIT_CODESession is active — SMS not yet received. Keep polling.STATUS_OK:84729OTP received — the code follows the colonSTATUS_CANCELSession expired or was cancelledcurl 'https://www.kartesim.com/api/stubs/handler_api.php ?api_key=YOUR_KEY&action=getStatus&id=cma4x9k3b0000abc123'
STATUS_OK:84729
/api/stubs/handler_api.php?action=setStatusConfirm receipt of the OTP (status=1) or cancel the session for a full refund (status=8). Only PENDING sessions can be cancelled.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| api_key | string | required | Your API key |
| action | string | required | Must be "setStatus" |
| id | string | required | Session ID to act on |
| status | integer | required | 1 = confirm received, 8 = cancel and refund |
Responses
ACCESS_READYConfirmed — session acknowledgedACCESS_CANCELCancelled — balance refundedBAD_ACTIONSession not found or already completed# Cancel and refund curl 'https://www.kartesim.com/api/stubs/handler_api.php ?api_key=YOUR_KEY&action=setStatus&id=cma4x9k3b0000abc123&status=8'
ACCESS_CANCEL
Native REST API
For modern integrations, use our Native REST API instead of the legacy Handler API. Pass your API key using the x-api-key HTTP header.
OTP sessions
per useOTP sessions let you request a temporary phone number, receive a one-time code, and release the number — all via API. Each session is billed once on creation. If you cancel before the code arrives, the full fee is refunded.
/api/v1/otp/requestRequest a temporary phone number for OTP verification. Returns a sessionId and the assigned number. Charges the OTP_PER_USE fee immediately.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| country | integer | optional | Country calling code to filter by (e.g. 212). Omit for any. |
| service | string | optional | Service name e.g. "telegram" — stored on the session for your reference |
| webhookUrl | string | optional | HTTPS URL to POST to when the OTP arrives (instead of polling) |
| expiresIn | integer | optional | Session TTL in seconds (60–1800, default 600) |
Responses
200 OKSession created — body contains sessionId, number, and expiresAt402 Payment RequiredInsufficient balance503 Service UnavailableNo online numbers availablecurl -X POST https://www.kartesim.com/api/v1/otp/request \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"service": "telegram", "country": 212}'{ "sessionId": "cma4x9k3b0000abc123", "number": "212661234567", "status": "PENDING", "expiresAt": "2026-06-01T00:20:00.000Z" }/api/v1/otp/:sessionIdPoll for OTP session status and code. Returns the extracted OTP code once the SMS arrives. Poll every 5–10 seconds.
Responses
200 OK — PENDINGstatus: "PENDING", otp: null — still waiting200 OK — RECEIVEDstatus: "RECEIVED", otp: "84729" — code ready200 OK — EXPIREDstatus: "EXPIRED" — no SMS within the timeout window200 OK — CANCELLEDstatus: "CANCELLED" — you cancelled the sessioncurl -H "x-api-key: YOUR_KEY" https://www.kartesim.com/api/v1/otp/cma4x9k3b0000abc123
{ "sessionId": "cma4x9k3b0000abc123", "status": "RECEIVED", "number": "212661234567", "otp": "84729", "smsBody": "Your code is 84729" }/api/v1/otp/:sessionId/cancelCancel a PENDING session. Issues a full refund of the OTP fee. Sessions that already received an OTP cannot be cancelled.
Responses
200 OKstatus: "CANCELLED", refunded: 0.10 — balance credited409 ConflictSession is not in PENDING state — cannot cancel404 Not FoundSession not found or belongs to another accountcurl -X POST -H "x-api-key: YOUR_KEY" https://www.kartesim.com/api/v1/otp/cma4x9k3b0000abc123/cancel
{ "sessionId": "cma4x9k3b0000abc123", "status": "CANCELLED", "refunded": "0.1000" }When an OTP arrives, we POST to the webhookUrl you provided on session creation. This is an alternative to polling — your server receives the OTP automatically without needing to call getStatus.
Payload
{
"event": "otp.received",
"sessionId": "cma4x9k3b0000abc123",
"status": "RECEIVED",
"number": "212661234567",
"otp": "84729",
"smsBody": "Your Telegram code is 84729",
"receivedAt": "2026-06-21T12:00:00.000Z"
}Security
- Your webhook URL must be HTTPS in production — HTTP URLs are rejected.
- We send an
X-Webhook-Signature: sha256=...header (HMAC-SHA256). Verify it to confirm the request is genuine. - We retry once on 5xx after 2 seconds. Your endpoint should return
200quickly. - Your endpoint must be idempotent — duplicate delivery is possible on retry.
/api/partner/rentalsFetch all active number rentals for your account.
Responses
200 OKJSON array of active number rentals401 UnauthorizedInvalid or missing API keycurl -H "x-api-key: YOUR_KEY" https://www.kartesim.com/api/partner/rentals
[
{
"id": "cuid...",
"phoneNumber": "1234567890",
"countryCode": 1,
"expiresAt": "2026-06-25T10:00:00.000Z",
"daysRemaining": 26
}
]/api/partner/proxiesFetch all active proxy rentals for your account, including their current IP address and credentials.
Responses
200 OKJSON array of active proxy rentals401 UnauthorizedInvalid or missing API keycurl -H "x-api-key: YOUR_KEY" https://www.kartesim.com/api/partner/proxies
[
{
"id": "cuid...",
"port": "Port A",
"host": "192.168.1.10",
"socks5Port": 1080,
"username": "user",
"password": "pwd",
"expiresAt": "2026-06-25T10:00:00.000Z"
}
]/api/partner/sms?simNumber=1234567890Fetch the latest SMS messages received by your rented numbers. Optionally filter by a specific simNumber.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| simNumber | string | optional | Filter SMS for a specific rented number |
Responses
200 OKJSON array of recent SMS messages401 UnauthorizedInvalid or missing API keycurl -H "x-api-key: YOUR_KEY" https://www.kartesim.com/api/partner/sms
[
{
"id": "cuid...",
"simNumber": "1234567890",
"fromNumber": "Twilio",
"body": "Your verification code is 49201",
"receivedAt": "2026-05-29T15:30:00.000Z"
}
]Number rentals
Number rentals give you exclusive use of a real SIM card for a fixed rental period. Every SMS received on that number is delivered to your account in real time. You can rent numbers directly via the API or the partner portal.
| Period | Duration | Description |
|---|---|---|
| Daily | 24 hours | Best for short-term verification campaigns |
| Weekly | 7 days | Best for ongoing access to a stable number |
| Monthly | 30 days | Best for long-term dedicated number access |
How it works
- Call GET /api/v1/numbers/available to browse available numbers (masked).
- Choose a number and billing cycle, then call POST /api/v1/numbers/rent to rent it instantly.
- Your balance is debited immediately. The full unmasked phone number is returned in the response.
- All SMS received on your rented number appears under SMS Logs in real time.
- At expiry the number is automatically released. No refund is issued for unused time.
/api/v1/numbers/availableBrowse numbers available for rental. Numbers are masked (e.g. +212 6** *** **7) so you can see country and carrier before committing. Optionally filter by country code.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| country | number | optional | ITU country code (e.g. 212). Omit or use 0 for any country. |
Responses
200 OKJSON with available numbers list and total count401 UnauthorizedInvalid or missing API key429 Too Many RequestsRate limit exceeded (30 req/min)curl -H "x-api-key: YOUR_KEY" https://www.kartesim.com/api/v1/numbers/available?country=212
{
"available": [
{
"phoneId": "clx...",
"maskedNumber": "+212 6** *** **7",
"countryCode": 212,
"country": "Morocco",
"carrier": "Orange",
"pricing": { "daily": null, "weekly": 2.50, "monthly": 8.00 }
}
],
"total": 1
}/api/v1/numbers/rentSelf-rent a number. Atomically deducts your balance and creates an exclusive rental. Returns the full (unmasked) phone number on success.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| phoneId | string | required | Port ID from /api/v1/numbers/available |
| billingCycle | string | required | DAILY | WEEKLY | MONTHLY |
| cycles | number | optional | Number of billing cycles to pay upfront (1–12, default 1) |
| autoRenew | boolean | optional | Auto-renew on expiry (default false) |
Responses
200 OKRental created — full phone number in response402 Payment RequiredInsufficient balance or no pricing configured for that cycle409 ConflictNumber was just rented by another partner — retry with a different number401 UnauthorizedInvalid or missing API keycurl -X POST -H "x-api-key: YOUR_KEY" -H "Content-Type: application/json" \
-d '{"phoneId":"clx...","billingCycle":"MONTHLY","cycles":1}' \
https://www.kartesim.com/api/v1/numbers/rent{
"rentalId": "cly...",
"phoneNumber": "+212661234567",
"countryCode": 212,
"carrier": "Orange",
"billingCycle": "MONTHLY",
"pricePerCycle": 8.00,
"cycles": 1,
"totalCharged": 8.00,
"autoRenew": false,
"startedAt": "2026-06-21T20:00:00.000Z",
"expiresAt": "2026-07-21T20:00:00.000Z"
}/api/partner/rentalsFetch all active number rentals for your account.
Responses
200 OKJSON array of active number rentals401 UnauthorizedInvalid or missing API keycurl -H "x-api-key: YOUR_KEY" https://www.kartesim.com/api/partner/rentals
[
{
"id": "cuid...",
"phoneNumber": "+212661234567",
"maskedNumber": "+212 6** *** **7",
"countryCode": 212,
"expiresAt": "2026-06-25T10:00:00.000Z",
"daysRemaining": 26
}
]Proxy rentals
Each port in the fleet exposes an HTTP and SOCKS5 proxy over its mobile data connection. Partners can route traffic through these proxies to obtain a real mobile IP for a specific country.
| Protocol | Default port | Notes |
|---|---|---|
| HTTP | device-specific | HTTP CONNECT proxy — port shown in partner portal and /api/partner/proxies |
| SOCKS5 | 1080 | SOCKS5 proxy — supports TCP and UDP tunneling |
curl --proxy http://USER:PASS@PHONE_IP:8888 https://api.ipify.org
curl --proxy socks5://USER:PASS@PHONE_IP:1080 https://api.ipify.org
Viewing your active proxies
Your active proxy subscriptions — including the current IP, port, and expiry — are visible in the partner portal under Proxies. The IP field is updated live as the port reports its address.
Supported countries
Use getCountries to get the current list. Common country codes:
| Code | Country | Code | Country |
|---|---|---|---|
| 0 | Any (auto-assign) | 7 | Russia |
| 212 | Morocco | 33 | France |
| 1 | United States | 44 | United Kingdom |
| 49 | Germany | 34 | Spain |
| 966 | Saudi Arabia | 971 | United Arab Emirates |
| 20 | Egypt | 216 | Tunisia |
Error reference
| Response | Meaning |
|---|---|
| BAD_KEY | Invalid, revoked, or missing API key |
| BAD_ACTION | Unknown action or missing required parameters |
| TOO_MANY_REQUESTS | Rate limit exceeded — 120 requests per minute |
| NO_NUMBERS | No online ports available matching your OTP request |
| NO_BALANCE | Insufficient balance to create an OTP session |
| STATUS_WAIT_CODE | OTP not yet received — keep polling |
| STATUS_OK:code | OTP received — digit code follows the colon |
| STATUS_CANCEL | Session expired or was cancelled |
| ACCESS_NUMBER:id:num | OTP session created — session ID and phone number follow |
| ACCESS_CANCEL | Session cancelled, balance refunded |
| ACCESS_READY | Session acknowledged / confirmed |
kartesim Partner Documentation — For API key requests or rental enquiries, contact your account manager.