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

345 lines
12 KiB
YAML

openapi: 3.1.0
info:
title: Android SMS Gateway API
version: 1.0.0
description: |
Direct HTTP API exposed by the Android SMS Gateway. Authentication is configurable
on the device and enabled by default. Plain HTTP must only be used on trusted networks.
servers:
- url: /
description: Gateway currently serving this documentation
- url: http://{device_ip}:{port}
description: Explicit gateway address for generated clients
variables:
device_ip:
default: 192.168.1.50
port:
default: '8080'
security:
- bearerAuth: []
- apiKeyAuth: []
tags:
- name: Gateway
- name: SMS
paths:
/docs:
get:
tags: [Gateway]
summary: Open interactive API documentation
description: Returns the locally bundled Swagger UI. This documentation page is public; API operations remain protected.
operationId: getApiDocumentation
security: []
responses:
'200':
description: Interactive Swagger UI page
content:
text/html:
schema:
type: string
/docs/openapi.yaml:
get:
tags: [Gateway]
summary: Download the OpenAPI contract
description: Returns the exact OpenAPI YAML document packaged with the installed app.
operationId: getOpenApiDocument
security: []
responses:
'200':
description: OpenAPI 3.1 YAML contract
content:
application/yaml:
schema:
type: string
/api/v1:
get:
tags: [Gateway]
summary: Get API information
operationId: getApiInfo
responses:
'200':
description: API capabilities and endpoints
content:
application/json:
schema: { $ref: '#/components/schemas/ApiInfo' }
'401': { $ref: '#/components/responses/Unauthorized' }
'403': { $ref: '#/components/responses/Forbidden' }
'503': { $ref: '#/components/responses/Unavailable' }
/api/v1/health:
get:
tags: [Gateway]
summary: Check gateway health
operationId: getHealth
responses:
'200':
description: Healthy gateway
content:
application/json:
schema: { $ref: '#/components/schemas/Health' }
example:
status: ok
device_id: 897d0bd6-e29d-4a65-a07a-e73f01b0056c
app_version: 0.1.0
android_version: '16'
device_model: Google Pixel
ip: 192.168.1.50
port: 8080
uptime: 12345
'401': { $ref: '#/components/responses/Unauthorized' }
'403': { $ref: '#/components/responses/Forbidden' }
'503': { $ref: '#/components/responses/Unavailable' }
/api/v1/status:
get:
tags: [Gateway]
summary: Get operational status and counters
operationId: getStatus
responses:
'200':
description: Current gateway status
content:
application/json:
schema: { $ref: '#/components/schemas/GatewayStatus' }
'401': { $ref: '#/components/responses/Unauthorized' }
'403': { $ref: '#/components/responses/Forbidden' }
'503': { $ref: '#/components/responses/Unavailable' }
/api/v1/sms/send:
post:
tags: [SMS]
summary: Submit an SMS
description: Accepts one message of at most 160 characters. HTTP 202 does not mean carrier delivery.
operationId: sendSms
requestBody:
required: true
content:
application/json:
schema: { $ref: '#/components/schemas/SendSmsRequest' }
example:
to: '+989121234567'
message: Hello
responses:
'202':
description: Accepted for Android submission
content:
application/json:
schema: { $ref: '#/components/schemas/SendSmsResponse' }
example:
success: true
id: 243fdc31-874a-4be1-823d-5c08575805ca
status: pending
'400': { $ref: '#/components/responses/BadRequest' }
'401': { $ref: '#/components/responses/Unauthorized' }
'403': { $ref: '#/components/responses/Forbidden' }
'411':
description: Content-Length header is required
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
'413':
description: Request exceeds 16 KiB
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
'422':
description: Invalid recipient or message
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
'503': { $ref: '#/components/responses/Unavailable' }
/api/v1/sms/messages:
get:
tags: [SMS]
summary: List persisted SMS messages
operationId: listMessages
parameters:
- name: page
in: query
schema: { type: integer, minimum: 1, default: 1 }
- name: page_size
in: query
schema: { type: integer, minimum: 1, maximum: 100, default: 50 }
- name: direction
in: query
schema: { type: string, enum: [all, incoming, outgoing], default: all }
- name: search
in: query
schema: { type: string, maxLength: 200 }
responses:
'200':
description: Message page ordered newest first
content:
application/json:
schema: { $ref: '#/components/schemas/MessagePage' }
'401': { $ref: '#/components/responses/Unauthorized' }
'403': { $ref: '#/components/responses/Forbidden' }
'422':
description: Invalid direction
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
'503': { $ref: '#/components/responses/Unavailable' }
/api/v1/sms/messages/{id}:
get:
tags: [SMS]
summary: Get a persisted message
operationId: getMessage
parameters:
- name: id
in: path
required: true
schema: { type: string, minLength: 1, maxLength: 100 }
responses:
'200':
description: Message details
content:
application/json:
schema: { $ref: '#/components/schemas/SmsMessage' }
'401': { $ref: '#/components/responses/Unauthorized' }
'403': { $ref: '#/components/responses/Forbidden' }
'404':
description: Message not found
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
'503': { $ref: '#/components/responses/Unavailable' }
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: API key
apiKeyAuth:
type: apiKey
in: header
name: X-API-Key
responses:
BadRequest:
description: Malformed JSON request
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
Unauthorized:
description: Missing or invalid API key
headers:
WWW-Authenticate:
schema: { type: string }
description: Authentication challenge may be omitted by the MVP transport
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
example:
success: false
error: { code: INVALID_API_KEY, message: API credentials are invalid }
Forbidden:
description: Client IP is outside the allowlist
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
Unavailable:
description: Gateway security or SMS subsystem is unavailable
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
schemas:
ApiInfo:
type: object
required: [api_version, gateway_version, capabilities, endpoints]
properties:
api_version: { type: string, const: v1 }
gateway_version: { type: string }
capabilities: { type: array, items: { type: string } }
endpoints: { type: array, items: { type: string } }
Health:
type: object
required: [status, device_id, app_version, android_version, device_model, ip, port, uptime]
properties:
status: { type: string, const: ok }
device_id: { type: string, format: uuid }
app_version: { type: string }
android_version: { type: string }
device_model: { type: string }
ip: { type: string }
port: { type: integer, minimum: 1024, maximum: 65535 }
uptime: { type: integer, minimum: 0, description: Seconds }
GatewayStatus:
type: object
required: [success, server_status, ip, port, uptime, requests, sent_sms, received_sms]
properties:
success: { type: boolean, const: true }
server_status: { type: string, enum: [stopped, starting, running, stopping, error] }
ip: { type: string }
port: { type: integer }
uptime: { type: integer, minimum: 0, description: Seconds }
requests: { type: integer, minimum: 0 }
sent_sms: { type: integer, minimum: 0, description: Total outgoing rows, including pending and failed }
received_sms: { type: integer, minimum: 0 }
SendSmsRequest:
type: object
additionalProperties: false
required: [to, message]
properties:
to:
type: string
pattern: '^\+?[0-9]{3,20}$'
message:
type: string
minLength: 1
maxLength: 160
SendSmsResponse:
type: object
required: [success, id, status]
properties:
success: { type: boolean, const: true }
id: { type: string, format: uuid }
status: { type: string, const: pending }
SmsMessage:
type: object
required: [id, direction, message, timestamp, status]
properties:
id: { type: string, format: uuid }
direction: { type: string, enum: [incoming, outgoing] }
sender: { type: [string, 'null'] }
recipient: { type: [string, 'null'] }
message: { type: string }
timestamp: { type: integer, description: Unix epoch milliseconds }
status: { type: string, enum: [received, pending, sent, failed] }
error_code: { type: [string, 'null'] }
MessagePage:
type: object
required: [success, page, page_size, messages]
properties:
success: { type: boolean, const: true }
page: { type: integer, minimum: 1 }
page_size: { type: integer, minimum: 1, maximum: 100 }
messages:
type: array
items: { $ref: '#/components/schemas/SmsMessage' }
ErrorResponse:
type: object
required: [success, error]
properties:
success: { type: boolean, const: false }
error:
type: object
required: [code, message]
properties:
code:
type: string
enum:
- INVALID_JSON
- INVALID_RECIPIENT
- EMPTY_MESSAGE
- MESSAGE_TOO_LONG
- INVALID_DIRECTION
- 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
message: { type: string }