{
  "openapi": "3.0.3",
  "info": {
    "title": "SMSTProxy API",
    "version": "1.1.0",
    "description": "API de clientes diretos. HTTPS e Bearer token. Consultas GET /activations/{id}: 3600 chamadas/minuto por cliente, permitindo 1 consulta por segundo para ate 60 ativacoes. Outros metodos: 120 chamadas/minuto, em limite separado. Respeite Retry-After em HTTP 429. Sem saldo ou cobranca automatica nesta versao."
  },
  "servers": [
    {
      "url": "https://api.smstproxy.com/v1"
    }
  ],
  "paths": {
    "/services": {
      "get": {
        "summary": "Listar serviços autorizados, preços em USD e estoque",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Solicitação concluída",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Chave inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Cliente desativado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Não encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflito ou sem estoque",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limite excedido. Respeite Retry-After; consultas SMS e demais operacoes possuem limites separados.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Segundos para aguardar antes de repetir.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Reinicio do limite em segundos Unix.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "sms-poll",
                    "general"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Vendas desativadas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/activations": {
      "post": {
        "summary": "Reservar número para um serviço",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Ativação do próprio cliente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Activation"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Chave inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Cliente desativado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Não encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "NO_NUMBERS: sem estoque; IDEMPOTENCY_CONFLICT: a mesma chave foi usada para outro pedido. Consulte o campo code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limite excedido. Respeite Retry-After; consultas SMS e demais operacoes possuem limites separados.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Segundos para aguardar antes de repetir.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Reinicio do limite em segundos Unix.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "sms-poll",
                    "general"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Vendas desativadas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "service"
                ],
                "properties": {
                  "country": {
                    "type": "string",
                    "enum": [
                      "BR"
                    ],
                    "default": "BR"
                  },
                  "service": {
                    "type": "string",
                    "example": "wa"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ]
      }
    },
    "/activations/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer",
            "minimum": 1
          }
        }
      ],
      "get": {
        "summary": "Consultar ativação e SMS",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Ativação do próprio cliente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Activation"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Chave inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Cliente desativado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Não encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflito ou sem estoque",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limite excedido. Respeite Retry-After; consultas SMS e demais operacoes possuem limites separados.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Segundos para aguardar antes de repetir.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Reinicio do limite em segundos Unix.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "sms-poll",
                    "general"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Vendas desativadas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Consulte a cada 1 segundo por ativacao usando o ID retornado pela reserva, respeitando 3600 consultas por minuto por cliente."
      }
    },
    "/activations/{id}/finish": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer",
            "minimum": 1
          }
        }
      ],
      "post": {
        "summary": "Finalizar ativação",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Ativação do próprio cliente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Activation"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Chave inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Cliente desativado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Não encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflito ou sem estoque",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limite excedido. Respeite Retry-After; consultas SMS e demais operacoes possuem limites separados.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Segundos para aguardar antes de repetir.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Reinicio do limite em segundos Unix.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "sms-poll",
                    "general"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Vendas desativadas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "completed",
                      "cancelled"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "Codigo estavel quando disponivel.",
            "enum": [
              "NO_NUMBERS",
              "IDEMPOTENCY_CONFLICT",
              "RATE_LIMIT_EXCEEDED",
              "SALES_PAUSED",
              "RESERVATION_FAILED"
            ]
          }
        }
      },
      "Activation": {
        "type": "object",
        "required": [
          "id",
          "number",
          "service",
          "country",
          "status",
          "price",
          "currency",
          "created_at",
          "messages"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "number": {
            "type": "string",
            "example": "+5547999990000"
          },
          "service": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "enum": [
              "BR"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "completed",
              "cancelled"
            ]
          },
          "price": {
            "type": "string",
            "description": "Preço registrado em USD"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "sender": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                },
                "created": {
                  "type": "number",
                  "description": "Segundos Unix"
                }
              }
            }
          }
        }
      }
    }
  }
}
