{
  "openapi": "3.0.3",
  "info": {
    "title": "SMS 3300 API",
    "version": "1.0.0",
    "description": "مستندات API سرویس پیامکی نگین ارتباط"
  },
  "servers": [
    {
      "url": "https://sms.3300.ir/api"
    }
  ],
  "tags": [
    {
      "name": "عملیات پیامکی",
      "description": "عملیات ارسال و دریافت پیامک"
    },
    {
      "name": "متفرقه",
      "description": "در این بخش api های مربوط به بررسی مقدار مانده اعتبار و وضعیت سرویس قرار دارد."
    }
  ],
  "paths": {
    "/wsSend.ashx": {
      "post": {
        "tags": [
          "عملیات پیامکی"
        ],
        "summary": "ارسال پیامک تکی",
        "description": "از این متد میتوانید برای ارسال یک پیامک به یک مخاطب استفاده کنید.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password",
                  "mobile",
                  "message"
                ],
                "properties": {
                  "username": {
                    "type": "string",
                    "description": "نام کاربری وب‌سرویس"
                  },
                  "password": {
                    "type": "string",
                    "description": "رمز عبور وب‌سرویس"
                  },
                  "mobile": {
                    "type": "string",
                    "description": "شماره موبایل گیرنده"
                  },
                  "message": {
                    "type": "string",
                    "description": "متن پیامک"
                  },
                  "line": {
                    "type": "string",
                    "description": "شماره خط ارسال"
                  },
                  "line2": {
                    "type": "string",
                    "description": "خط جایگزین در صورت fail شدن خط اصلی"
                  },
                  "type": {
                    "type": "integer",
                    "description": "نوع ارسال پیامک"
                  },
                  "template": {
                    "type": "integer",
                    "description": "شماره قالب (در حالت سرویس خدماتی)"
                  }
                }
              },
              "example": {
                "username": "USERNAME",
                "password": "PASSWORD",
                "mobile": "09123456789",
                "message": "Test",
                "line": "9830003300"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "موفق یا خطای منطقی (همیشه HTTP 200)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "message_id": {
                              "type": "string",
                              "description": "شناسه پیام یا کد خطای Provider (اگر < 1000 باشد)"
                            },
                            "line": {
                              "type": "string"
                            },
                            "mobile": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "integer",
                      "description": "وضعیت عملیات (موفق: -1، خطاهای منطقی: 2 و ...)"
                    },
                    "msg": {
                      "type": "string",
                      "description": "توضیح وضعیت عملیات"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "value": {
                      "data": {
                        "message_id": "66110",
                        "line": "9830003300",
                        "mobile": "989123456789"
                      },
                      "status": -1,
                      "msg": "success"
                    }
                  },
                  "provider_error": {
                    "value": {
                      "data": {
                        "message_id": "34",
                        "line": "9830003300",
                        "mobile": "989123456789"
                      },
                      "status": -1,
                      "msg": "success"
                    }
                  },
                  "validation_error": {
                    "value": {
                      "data": null,
                      "status": 2,
                      "msg": "line is not valid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "خطای احراز هویت",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "relogin": {
                      "type": "string",
                      "example": "1",
                      "description": "نیاز به ورود مجدد"
                    }
                  }
                },
                "example": {
                  "relogin": "1"
                }
              }
            }
          }
        }
      }
    },
    "/wsSendBatch.ashx": {
      "post": {
        "tags": [
          "عملیات پیامکی"
        ],
        "summary": "ارسال پیامک گروهی (Batch)",
        "description": "از این متد میتوانید برای ارسال چند پیامک به چند مخاطب و یا یک پیامک به چند مخاطب استفاده کنید. \r\n  مقادیر `mobiles` و `tempCheckIds` باید با هم متناظر باشند.\r\n  مقدار `messages` میواتد یا با مقدار `mobiles` متناظر باشد و یا فقط یک آیتم داشته باشد.\r\n  در صورتی که فقط یک آیتم داشته باشد :‌ همان پیام برای تمام شماره‌ها ارسال خواهد شد.\r\n  در صورتی که با آرایه `mobiles` متناظر باشد، برای هر شماره مخاطب، پیام متناظر با همان شماره ارسال خواهد شد.\n\nآرایه `tempCheckIds` به شما این قابلیت را میدهد که برای هر پیام به هر شماره، کلید پیگیری تولید کنید و تا ۲۴ ساعت بعد توسط متد [دریافت وضعیت پیامک](#tag/عملیات-پیامکی/POST/wsStates.ashx) وضعیت آن پیامک را بررسی کنید.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password",
                  "line",
                  "messages",
                  "mobiles",
                  "tempCheckIds"
                ],
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "line": {
                    "type": "string",
                    "description": "شماره خط ارسال"
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "لیست پیام‌ها"
                  },
                  "mobiles": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "لیست شماره موبایل‌ها"
                  },
                  "tempCheckIds": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "شناسه‌های موقت برای رهگیری پیام‌ها"
                  }
                }
              },
              "example": {
                "username": "USERNAME",
                "password": "PASSWORD",
                "line": "9830003300",
                "messages": [
                  "پیام اول",
                  "پیام دوم"
                ],
                "mobiles": [
                  "09123456789",
                  "09123456789"
                ],
                "tempCheckIds": [
                  1001,
                  1002
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "موفق یا خطای منطقی (همیشه HTTP 200)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "msgIds": {
                              "type": "array",
                              "items": {
                                "type": [
                                  "integer",
                                  "string"
                                ]
                              },
                              "description": "شناسه پیام‌ها (در صورت موفقیت)"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "integer",
                      "description": "وضعیت عملیات"
                    },
                    "msg": {
                      "type": "string",
                      "description": "توضیح نتیجه عملیات"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "value": {
                      "data": {
                        "msgIds": [
                          66110,
                          66111
                        ]
                      },
                      "status": -2,
                      "msg": "success"
                    }
                  },
                  "wrong_number": {
                    "value": {
                      "data": {
                        "msgIds": null
                      },
                      "status": 2,
                      "msg": "Wrong Number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "خطای احراز هویت",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "relogin": {
                      "type": "string",
                      "example": "1"
                    }
                  }
                },
                "example": {
                  "relogin": "1"
                }
              }
            }
          }
        }
      }
    },
    "/wsReceive.ashx": {
      "post": {
        "tags": [
          "عملیات پیامکی"
        ],
        "summary": "دریافت پیام‌های ورودی (Inbox)",
        "description": "دریافت پیامک‌های دریافتی. فقط پیام‌های یک روز اخیر بازگردانده می‌شود. در صورت عدم وجود پیام، آرایه خالی برمی‌گردد. خطای احراز هویت فقط با HTTP 401 برمی‌گردد.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password"
                ],
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "username": "USERNAME",
                "password": "PASSWORD"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "لیست پیام‌ها یا لیست خالی (همیشه HTTP 200)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "Id": {
                            "type": "integer"
                          },
                          "Date": {
                            "type": "string"
                          },
                          "Message": {
                            "type": "string"
                          },
                          "Mobile": {
                            "type": "string"
                          },
                          "Line": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "status": {
                      "type": "integer",
                      "description": "وضعیت عملیات (موفق: -1)"
                    },
                    "msg": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "has_messages": {
                    "value": {
                      "data": [
                        {
                          "Id": 17557845,
                          "Date": "2026-06-01 12:41",
                          "Message": "تست",
                          "Mobile": "989123456789",
                          "Line": "9830003300"
                        }
                      ],
                      "status": -1,
                      "msg": "success"
                    }
                  },
                  "empty": {
                    "value": {
                      "data": [],
                      "status": -1,
                      "msg": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "خطای احراز هویت",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "relogin": {
                      "type": "string",
                      "example": "1"
                    }
                  }
                },
                "example": {
                  "relogin": "1"
                }
              }
            }
          }
        }
      }
    },
    "/wsStates.ashx": {
      "post": {
        "tags": [
          "عملیات پیامکی"
        ],
        "summary": "دریافت وضعیت پیامک‌ها",
        "description": "دریافت وضعیت پیامک‌های ارسال شده بر اساس message_ids. فقط تا ۷ روز قابل بررسی است. در صورت ارسال شناسه‌های نامعتبر (< 1000) ممکن است خطای سرور رخ دهد. در حالت عادی همیشه HTTP 200 و در خطای احراز هویت HTTP 401 برمی‌گردد.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password",
                  "message_ids"
                ],
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "message_ids": {
                    "type": "string",
                    "description": "لیست شناسه پیام‌ها جدا شده با کاما"
                  }
                }
              },
              "example": {
                "username": "USERNAME",
                "password": "PASSWORD",
                "message_ids": "66110,66111,66112"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "وضعیت پیامک‌ها (موفق یا خطای منطقی)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "msgIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "states": {
                              "type": "array",
                              "items": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "msg": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "value": {
                      "data": {
                        "msgIds": [
                          "66110",
                          "66111",
                          "66112"
                        ],
                        "states": [
                          1,
                          1,
                          1
                        ]
                      },
                      "status": -1,
                      "msg": "success"
                    }
                  },
                  "empty_result": {
                    "value": {
                      "data": {
                        "msgIds": [],
                        "states": []
                      },
                      "status": -1,
                      "msg": "success"
                    }
                  },
                  "server_error_invalid_ids": {
                    "value": {
                      "data": null,
                      "status": 500,
                      "msg": "Value cannot be null.\r\nParameter name: source"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "خطای احراز هویت (نام کاربری یا رمز اشتباه / حساب منقضی / بسته شده)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "relogin": {
                      "type": "string",
                      "example": "1"
                    }
                  }
                },
                "example": {
                  "relogin": "1"
                }
              }
            }
          }
        }
      }
    },
    "/wsCredit.ashx": {
      "post": {
        "tags": [
          "متفرقه"
        ],
        "summary": "بررسی موجودی حساب",
        "description": "از این متد میتوانید برای دریافت مقدار باقیمانده شارژ و هزینه مصرف شده برای ارسال و دریافت‌ها و همچنین میزان شارژ کلی که داشتید استفاده کنید.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password"
                ],
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "username": "USERNAME",
                "password": "PASSWORD"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "دریافت موفق",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "credit": {
                          "type": "integer",
                          "description": "مقدار شارژ موجود"
                        },
                        "send": {
                          "type": "integer",
                          "description": "جمع هزینه ارسال‌ها"
                        },
                        "receive": {
                          "type": "integer",
                          "description": "جمع هزینه دریافت دریافت‌ها"
                        },
                        "charge": {
                          "type": "integer",
                          "description": "مقدار شارژ شده"
                        }
                      }
                    },
                    "status": {
                      "type": "integer",
                      "example": -1
                    },
                    "msg": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "value": {
                      "data": {
                        "credit": 36408,
                        "send": 96354,
                        "receive": 0,
                        "charge": 132762
                      },
                      "status": -1,
                      "msg": "success"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "خطای احراز هویت",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "relogin": {
                      "type": "string",
                      "example": "1"
                    }
                  }
                },
                "example": {
                  "relogin": "1"
                }
              }
            }
          }
        }
      }
    },
    "/ping.ashx": {
      "get": {
        "tags": [
          "متفرقه"
        ],
        "summary": "بررسی وضعیت سرویس",
        "description": "این سرویس فقط برای بررسی آنلاین بودن سرور استفاده می‌شود و هیچ احراز هویتی نیاز ندارد.",
        "responses": {
          "200": {
            "description": "سرویس در دسترس است",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "pong"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "components": {
      "schemas": {
        "AuthError": {
          "type": "object",
          "description": "خطای احراز هویت (فقط HTTP 401)",
          "properties": {
            "relogin": {
              "type": "string",
              "example": "1",
              "description": "نیاز به ورود مجدد (نام کاربری/رمز اشتباه یا حساب غیرفعال/منقضی)"
            }
          },
          "required": [
            "relogin"
          ]
        },
        "BaseResponse": {
          "type": "object",
          "description": "ساختار پایه پاسخ در حالت HTTP 200",
          "properties": {
            "data": {
              "description": "داده خروجی (بسته به هر endpoint متفاوت است)"
            },
            "status": {
              "type": "integer",
              "description": "وضعیت عملیات (موفق یا خطای منطقی)"
            },
            "msg": {
              "type": "string",
              "description": "پیام توضیحی نتیجه عملیات"
            }
          }
        },
        "SendSmsResponseData": {
          "type": "object",
          "properties": {
            "message_id": {
              "type": "string",
              "description": "شناسه پیام یا کد خطای Provider (اگر < 1000 باشد یعنی خطای اپراتور)"
            },
            "line": {
              "type": "string"
            },
            "mobile": {
              "type": "string"
            }
          }
        },
        "SendBatchResponseData": {
          "type": "object",
          "properties": {
            "msgIds": {
              "type": "array",
              "items": {
                "type": "integer"
              },
              "nullable": true,
              "description": "شناسه پیام‌های ارسال شده (در خطا ممکن است null باشد)"
            }
          }
        },
        "ReceiveMessageItem": {
          "type": "object",
          "properties": {
            "Id": {
              "type": "integer"
            },
            "Date": {
              "type": "string"
            },
            "Message": {
              "type": "string"
            },
            "Mobile": {
              "type": "string"
            },
            "Line": {
              "type": "string"
            }
          }
        },
        "ReceiveResponseData": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/ReceiveMessageItem"
          }
        },
        "StatesResponseData": {
          "type": "object",
          "properties": {
            "msgIds": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "لیست شناسه پیام‌ها"
            },
            "states": {
              "type": "array",
              "items": {
                "type": "integer"
              },
              "description": "وضعیت هر پیام متناظر با msgIds"
            }
          }
        },
        "CreditResponseData": {
          "type": "object",
          "properties": {
            "credit": {
              "type": "integer",
              "description": "اعتبار ریالی"
            },
            "send": {
              "type": "integer",
              "description": "هزینه ارسال"
            },
            "receive": {
              "type": "integer",
              "description": "هزینه دریافت"
            },
            "charge": {
              "type": "integer",
              "description": "مجموع شارژ"
            }
          }
        }
      },
      "responses": {
        "UnauthorizedError": {
          "description": "خطای احراز هویت",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthError"
              },
              "example": {
                "relogin": "1"
              }
            }
          }
        }
      }
    }
  }
}