---
title: "服务端 API"
description: "快速上手 Adapty 服务端 API，管理订阅。"
---

:::tip
在使用 AI 编程助手？请查看[从后端检查并授予订阅访问权限](server-side-api-with-ai)，一页搞定完整流程。
:::

通过该 API，你可以：
1. 查看用户的订阅状态。
2. 通过访问等级激活用户的订阅。
3. 获取用户属性。
4. 设置用户属性。
5. 获取并更新付费墙配置。

  <img src="/assets/shared/img/server.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

<p> </p>

:::note

如需追踪订阅事件，请在 Adapty 中使用 [Webhook](webhook) 集成，或直接与您现有的服务进行集成。
:::

## 案例一：同步网页端与移动端的订阅用户 \{#case-1-sync-subscribers-between-web-and-mobile\}
如果你使用 Stripe、ChargeBee 或其他网页支付服务商，可以轻松同步订阅用户。操作步骤如下：
1. <InlineTooltip tooltip="为每位用户分配唯一 ID">[iOS](identifying-users)、[Android](android-identifying-users)、[React Native](react-native-identifying-users)、[Flutter](flutter-identifying-users)、[Unity](unity-identifying-users)</InlineTooltip>。
2. 通过 API [查询用户订阅状态](api-adapty/operations/getProfile)。
3. 如果用户处于免费增值计划，在你的网站上展示付费墙。
4. 支付成功后，通过 API 在 Adapty 中[更新订阅状态](api-adapty/operations/setTransaction)。
5. 订阅用户的状态将自动与移动端 App 保持同步。
## 案例 2：授予订阅 \{#case-2-grant-a-subscription\}

:::note
出于安全原因，您无法通过移动端 SDK 授予订阅。
:::

如果您通过自己的线上商店、Amazon Appstore、Microsoft Store 或 Google Play 和 App Store 以外的其他平台进行销售，则需要将这些交易同步到 Adapty，以便授予用户访问权限并在分析中追踪该交易。
1. <InlineTooltip tooltip="为每位用户分配唯一 ID">[iOS](identifying-users)、[Android](android-identifying-users)、[React Native](react-native-identifying-users)、[Flutter](flutter-identifying-users) 和 [Unity](unity-identifying-users)</InlineTooltip>。
2. [在 Adapty 看板中为你的产品设置自定义商店](custom-store)。
3. 使用 [Set transaction](api-adapty/operations/setTransaction) API 请求将交易同步到 Adapty。
## 情境 3：授予访问等级 \{#case-3-grant-an-access-level\}

假设你正在运行一个提供 7 天免费试用的促销活动，并希望跨平台保持一致的用户体验。要与移动应用同步，请按以下步骤操作：

1. <InlineTooltip tooltip="为每位用户分配唯一 ID">[iOS](identifying-users)、[Android](android-identifying-users)、[React Native](react-native-identifying-users)、[Flutter](flutter-identifying-users) 和 [Unity](unity-identifying-users)</InlineTooltip>。
2. 使用 API [授予高级访问等级](api-adapty/operations/grantAccessLevel)，有效期 7 天。
7 天后，未订阅的用户将被降级至免费套餐。
## 情形 4：同步用户属性和自定义特性 \{#case-4-sync-users-properties-and-custom-attributes\}

如果你的用户有自定义特性（例如语言学习应用中用户已学习的单词数量），同样可以进行同步。

1. <InlineTooltip tooltip="为每位用户分配唯一 ID">[iOS](identifying-users)、[Android](android-identifying-users)、[React Native](react-native-identifying-users)、[Flutter](flutter-identifying-users) 和 [Unity](unity-identifying-users)</InlineTooltip>。
2. 通过 API 或 SDK [更新属性](api-adapty/operations/updateProfile)。
这些自定义属性可用于创建市场细分和运行 A/B 测试。
## 案例 5：管理付费墙配置 \{#case-5-manage-paywall-configurations\}

你可以[更新付费墙中的远程配置](api-adapty/operations/updatePaywall)，无需重新发布应用即可动态调整付费墙的外观和行为。

---

**下一步：**
- 继续了解[服务端 API 授权](ss-authorization)
- 请求：
  - [获取用户画像](api-adapty/operations/getProfile)
  - [创建用户画像](api-adapty/operations/createProfile)
  - [更新用户画像](api-adapty/operations/updateProfile)
  - [删除用户画像](api-adapty/operations/deleteProfile)
  - [授予访问等级](api-adapty/operations/grantAccessLevel)
  - [撤销访问等级](api-adapty/operations/revokeAccessLevel)
  - [设置交易](api-adapty/operations/setTransaction)
  - [验证购买、向用户授予访问等级并导入其交易历史](api-adapty/operations/validateStripePurchase)
  - [添加集成标识符](api-adapty/operations/setIntegrationIdentifiers)
  - [获取付费墙](api-adapty/operations/getPaywall)
  - [列出付费墙](api-adapty/operations/listPaywalls)
  - [更新付费墙](api-adapty/operations/updatePaywall)