---
title: "Send one of an agent's published SMS templates"
method: POST
path: "/v1/agents/{agent_id}/messages"
---

# Send one of an agent's published SMS templates

`POST /v1/agents/{agent_id}/messages`

## Request

- Base URL: `https://api.skysay.ai`
- URL: `https://api.skysay.ai/v1/agents/{agent_id}/messages`
- Auth: none declared

Project-scoped, unlike the organization-scoped POST /v1/messages: the agent's own project is the send's project. A foreign workspace's agent, another project, an unpublished agent and an unknown template are the same 404. The text is rendered from the published template with the variables and slots given, within 6 SMS segments, and authorized as POST /v1/messages is.

## Path parameters

- `agent_id` string, required

## Request body

- AgentTemplateMessage: Everything POST /v1/messages takes that names no resource, plus the template and what fills it. body, campaign_id, provider and segment_count are refused. The sending number, under any of its names, must belong to the agent's project.
  - `bulk` unknown
  - `categories` unknown
  - `country` unknown
  - `from_number_id` unknown
  - `from_phone_number_id` unknown
  - `idempotency_key` string
  - `language` string: The language to send in. Text is chosen from the call or request language, then its base language (et-EE -> et), then the agent's primary language, then, as a last resort, the template's texts in language-code order.
  - `message_class` unknown
  - `metadata` object
  - `number_id` unknown
  - `project_id` string: Optional. The agent's own project; any other answers 404 exactly as a foreign agent does.
  - `purpose` string: The message's purpose, authorized as on POST /v1/messages.
  - `recipient_type` unknown
  - `relationship` unknown
  - `slots` object: Values for the template's model slots, each within its max_length.
  - `template_id` string, required
  - `to` string: The recipient, E.164. to_phone_number is accepted as its alias.
  - `to_phone_number` unknown
  - `user_authorization` unknown
  - `user_requested` unknown
  - `variables` object: Values for the agent's declared variables the template references. A referenced required variable must be present; protected variables are refused (there is no confirmation to lean on).

## Response `201`

The message, as POST /v1/messages returns it. Body, provider metadata, error detail and idempotency key require sms:read, including on idempotent replays.

## Other responses

- `400`: A body beside a template, an unsupported field, a missing or invalid variable or slot, or a text over 6 segments.
- `404`: SMS template not found

---

[API](https://skmtc.dev/skysay/apis/skysay-api.md) · [All operations](https://skmtc.dev/skysay/apis/skysay-api/llms.txt) · [OpenAPI document](https://skmtc.dev/skysay/apis/skysay-api/revisions/95b8c66f99aa?raw)
