Files
android-sms-gateway/API.md
T
2026-08-25 02:18:50 +03:30

2.2 KiB
Raw Blame History

API Guide

The official machine-readable contract is openapi.yaml. All timestamps are Unix epoch milliseconds unless a field explicitly says seconds.

Base URL

http://<device-ip>:<configured-port>/api/v1

Authentication

When authentication is enabled, use either:

Authorization: Bearer YOUR_API_KEY

or:

X-API-Key: YOUR_API_KEY

Bearer authentication is recommended. Authentication applies to every /api/v1 endpoint. The app stores only the key hash. When the IP allowlist is enabled, both authentication and the allowlist must pass.

Endpoints

Method Path Purpose
GET /docs Open the locally bundled interactive Swagger UI
GET /docs/openapi.yaml Download the exact OpenAPI YAML packaged with the app
GET /api/v1 API version, capabilities, and endpoint discovery
GET /api/v1/health Basic device/server health
GET /api/v1/status Server state and counters
POST /api/v1/sms/send Submit one SMS of up to 160 characters
GET /api/v1/sms/messages Paginated incoming/outgoing history
GET /api/v1/sms/messages/{id} Message details

Message list parameters:

  • page: positive integer, default 1
  • page_size: 1–100, default 50
  • direction: all, incoming, or outgoing
  • search: sender, recipient, body, or outgoing status search

Send lifecycle

Successful submission returns HTTP 202 with status pending. Android later updates the local outgoing record to sent or failed. sent means Android's SMS service accepted the message; it is not a carrier delivery receipt.

Error format

{
  "success": false,
  "error": {
    "code": "INVALID_RECIPIENT",
    "message": "Recipient phone number is invalid"
  }
}

Stable codes include:

  • INVALID_JSON, INVALID_RECIPIENT, EMPTY_MESSAGE, MESSAGE_TOO_LONG
  • LENGTH_REQUIRED, PAYLOAD_TOO_LARGE
  • AUTHENTICATION_REQUIRED, INVALID_API_KEY, AUTHENTICATION_NOT_CONFIGURED
  • IP_NOT_ALLOWED
  • SMS_PERMISSION_DENIED, SMS_SEND_FAILED
  • MESSAGE_NOT_FOUND, NOT_FOUND, METHOD_NOT_ALLOWED, INTERNAL_ERROR

Clients must branch on error.code, not the human-readable message.