> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.claw-ops.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.claw-ops.com/_mcp/server.

# 메시지 발송

POST https://api.claw-ops.com/v1/accounts/{accountId}/messages
Content-Type: application/json

SMS/LMS/MMS 메시지를 발송합니다. From 번호는 계정에 등록된 번호여야 합니다.

KCT 통합메시징 Agent를 통해 실제 발송되며, 발송 결과는 webhook으로 비동기 수신합니다.

### 메시지 타입별 사용법

**SMS** (단문, 200byte 이하):

```json
{ "To": "010...", "From": "070...", "Body": "안녕하세요" }
```

**LMS** (장문, 2000자 이하, 첨부 없음):

```json
{ "To": "010...", "From": "070...", "Body": "긴 내용...", "Type": "lms", "Subject": "제목" }
```

**MMS** (이미지 첨부, 최대 3개):

```json
{ "To": "010...", "From": "070...", "Body": "사진", "Type": "mms", "MediaUrl": ["https://example.com/photo.jpg"] }
```

Reference: https://docs.claw-ops.com/api-레퍼런스/claw-ops-api/messages/send-message

## Authentication

- `Authorization` header (bearer token, required) — API Key를 Bearer 토큰으로 전달

## Request

### Path parameters

- `accountId` (string, required) — 계정 ID

### Body (application/json)

- `To` (string, required) — 수신 번호. 국내 표기(`010-1234-5678`·`01012345678`)와 `+82` E.164 를 모두 받아 국내 표기로 정규화해 저장합니다. 국내 이동전화·지역번호·050X 안심번호·대표번호 (`1[5-9]XX-XXXX`)만 지원하며, 그 밖의 값(앞 0 이 빠진 `1012345678`, `+` 없는 `8210…`, 폐지된 015·018 등)은 `400 invalid_phone` 입니다.
- `From` (string, required) — 발신 번호 (계정에 등록된 번호)
- `Body` (string, required) — 메시지 본문
- `Type` (enum, optional, default: sms) — 메시지 유형 (기본: sms)
  - Allowed values: `sms`, `lms`, `mms`
- `Subject` (string, optional) — 메시지 제목 (LMS/MMS에서 사용)
- `MediaUrl` (list of string, optional) — MMS 첨부 이미지 URL (최대 3개). jpg, jpeg, png, bmp만 지원. 장당 300KB 이하. - Type이 sms일 때는 사용 불가 - Type이 mms이고 MediaUrl이 없으면 LMS로 전송 - Type이 mms이고 MediaUrl이 있으면 MMS로 전송

## Response

### 201

발송 요청 성공

- `messageId` (string, optional)
- `status` (enum, optional)
  - Allowed values: `queued`, `sent`, `failed`, `received`
- `type` (enum, optional)
  - Allowed values: `sms`, `lms`, `mms`, `rcs`, `kakao`
- `subject` (string, optional, nullable) — 메시지 제목 (LMS/MMS)
- `to` (string, optional)
- `from` (string, optional)
- `body` (string, optional, nullable)
- `numMedia` (integer, optional) — 첨부 이미지 수
- `mediaUrl` (list of string, optional) — 첨부 이미지 URL 목록
- `direction` (enum, optional)
  - Allowed values: `outbound`, `inbound`
- `accountId` (string, optional)
- `dateCreated` (datetime, optional)
- `dateUpdated` (datetime, optional, nullable)

## Examples

**Request**

```json
{
  "To": "01012345678",
  "From": "07052358010",
  "Body": "안녕하세요"
}
```

**Response**

```json
{
  "messageId": "MGabcdef1234567890",
  "status": "queued",
  "type": "sms",
  "subject": "string",
  "to": "01012345678",
  "from": "07052358010",
  "body": "안녕하세요",
  "numMedia": 0,
  "mediaUrl": [],
  "direction": "outbound",
  "accountId": "AC1a2b3c4d",
  "dateCreated": "2024-01-15T09:30:00Z",
  "dateUpdated": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages"

payload = {
    "To": "01012345678",
    "From": "07052358010",
    "Body": "안녕하세요"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"To":"01012345678","From":"07052358010","Body":"안녕하세요"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages"

	payload := strings.NewReader("{\n  \"To\": \"01012345678\",\n  \"From\": \"07052358010\",\n  \"Body\": \"안녕하세요\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"To\": \"01012345678\",\n  \"From\": \"07052358010\",\n  \"Body\": \"안녕하세요\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"To\": \"01012345678\",\n  \"From\": \"07052358010\",\n  \"Body\": \"안녕하세요\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages', [
  'body' => '{
  "To": "01012345678",
  "From": "07052358010",
  "Body": "안녕하세요"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"To\": \"01012345678\",\n  \"From\": \"07052358010\",\n  \"Body\": \"안녕하세요\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "To": "01012345678",
  "From": "07052358010",
  "Body": "안녕하세요"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.claw-ops.com/v1/accounts/AC1a2b3c4d/messages")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```