> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ycloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# YCloud API

> 使用 YCloud API 构建消息传递、验证、联系人和事件工作流。

YCloud 为客户沟通和互动工作流提供统一的 API。您可以发送 WhatsApp、SMS、电子邮件和语音消息。您还可以验证用户、管理联系人、跟踪自定义事件，并通过 Webhook 接收状态更新。

## 请求工作原理

所有服务端请求均使用此基础 URL：

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
https://api.ycloud.com/v2
```

在 `X-API-Key` 请求头中使用 API 密钥对请求进行身份验证。请将密钥保存在您的服务器上，切勿在浏览器或移动应用代码中暴露该密钥。

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl https://api.ycloud.com/v2/balance \
  --header "X-API-Key: $YCLOUD_API_KEY" \
  --header "Accept: application/json"
```

<CardGroup cols={2}>
  <Card title="快速入门" icon="rocket" href="/zh/api-reference/getting-started/quickstart">
    配置您的 API 密钥并发出第一个经过身份验证的请求。
  </Card>

  <Card title="身份验证" icon="key" href="/zh/api-reference/guides/api-fundamentals/authentication">
    安全存储并使用您的 YCloud API 密钥。
  </Card>

  <Card title="Webhook" icon="webhook" href="/zh/api-reference/guides/api-fundamentals/configure-webhooks">
    接收消息状态更新和入站消息。
  </Card>

  <Card title="指南" icon="book-open" href="/zh/api-reference/guides/overview">
    按照实用指南了解常见集成工作流。
  </Card>
</CardGroup>

## 您可以构建的内容

<CardGroup cols={2}>
  <Card title="WhatsApp 体验" icon="whatsapp" href="/zh/api-reference/guides/whatsapp-platform/send-whatsapp-message">
    发送模板、文本、媒体、交互式消息等。
  </Card>

  <Card title="SMS 与语音" icon="comment-sms" href="/zh/api-reference/guides/messaging/send-sms">
    发送全球 SMS 消息和自动语音验证码。
  </Card>

  <Card title="电子邮件" icon="envelope" href="/zh/api-reference/guides/messaging/send-email">
    从已激活的域名发送 HTML 或纯文本电子邮件。
  </Card>

  <Card title="WhatsApp 平台" icon="building" href="/zh/api-reference/guides/whatsapp-platform/manage-whatsapp-business-accounts">
    管理 WABA、电话号码、模板、Flows、媒体和呼叫。
  </Card>

  <Card title="客户数据" icon="address-card" href="/zh/api-reference/guides/customer-data-and-operations/manage-contacts">
    管理联系人、自定义事件和渠道退订。
  </Card>
</CardGroup>

## 请求

通过 `Content-Type: application/json` 发送 JSON 请求体。路径和查询参数已在各个端点页面中记录。

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request POST https://api.ycloud.com/v2/sms \
  --header "X-API-Key: $YCLOUD_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "to": "+16315551234",
    "text": "Your order has shipped."
  }'
```

当您需要完整的请求架构、枚举值或交互式请求构建器时，请参考 API 参考文档。

## 响应

成功响应使用 JSON 格式。创建或发送响应确认 YCloud 已接受该请求。它并不总是代表最终送达或完成。请存储返回的资源 ID，并将其与检索结果或 Webhook 事件进行关联。

错误信息包括机器可读的 `code`、面向开发人员的 `message` 以及可提供给 YCloud 支持团队的 `requestId`。

<Note>
  某些产品需要先激活账户、获得批准的发送方或连接 WhatsApp 商业账户，然后才能发送消息。
</Note>

## 从指南到 API 参考

<CardGroup cols={2}>
  <Card title="WhatsApp 指南" icon="whatsapp" href="/zh/api-reference/guides/whatsapp-platform/send-whatsapp-message">
    了解消息窗口、发送模式、请求字段和送达状态。
  </Card>

  <Card title="WhatsApp 端点" icon="code" href="/api-reference/whatsapp-messages/send-a-message-directly">
    查看完整的直发请求和响应架构。
  </Card>

  <Card title="SMS 指南" icon="comment-sms" href="/zh/api-reference/guides/messaging/send-sms">
    了解 SMS 请求和送达状态更新的工作原理。
  </Card>

  <Card title="SMS 端点" icon="code" href="/api-reference/sms/send-an-sms">
    查看完整的 SMS 请求和响应架构。
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.