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

# 认证

> Legitmark 集成的 API 密钥使用、速率限制和安全最佳实践。

## API 密钥认证

Legitmark 使用 API 密钥认证。您的 API 密钥标识您的平台并授权访问 Legitmark 服务。

<Note>
  需要 API 密钥？请参阅[入门指南](/cn/partner/getting-started)设置您的组织并在[开发者设置](https://app.legitmark.com/settings/developer)中创建密钥。
</Note>

在所有请求的 `Authorization` 标头中包含您的 API 密钥：

```javascript theme={null}
const headers = {
  'Authorization': 'Bearer leo_xxxxxxxxx',
  'Content-Type': 'application/json'
};
```

如果使用 [TypeScript SDK](https://github.com/legitmark-eng/legitmark-typescript)，认证将自动处理：

```typescript theme={null}
import { Legitmark } from 'legitmark';

const legitmark = new Legitmark('leo_your_api_key');
```

### 安全模型

所有 API 通信使用 API 密钥进行认证。个人信息永远不会在标头、URL 或查询参数中传输，符合严格的数据保护标准。

## 速率限制

为确保平台稳定性，可能会应用速率限制。如果收到 `429` 响应，请等待后重试。详情请参阅[速率限制](/api-reference/rate-limits)。

## 安全最佳实践

### API 密钥安全

* 仅限授权系统访问 API 密钥
* 使用环境变量存储 API 密钥
* 实施密钥轮换程序
* 监控 API 密钥使用异常

### 请求安全

* 始终使用 HTTPS 进行 API 通信
* 实施请求超时和重试逻辑
* 对所有认证请求使用安全标头

## 测试认证

### 验证 API 密钥

使用简单的请求测试您的 API 密钥：

```bash theme={null}
curl -X GET "https://api.legitmark.com/api/v2/categories?active_only=true" \
  -H "Authorization: Bearer leo_your_api_key"
```

### 使用 SDK 测试

```typescript theme={null}
import { Legitmark } from 'legitmark';

const legitmark = new Legitmark('leo_your_api_key', { debug: true });
const { data: categories } = await legitmark.taxonomy.getCategories();
console.log(`连接成功！发现 ${categories.length} 个类别`);
```

## 后续步骤

1. **查看** [分类体系](/cn/partner/taxonomy) 了解物品分类
2. **实施** [工作流程](/cn/partner/workflow) 用于服务请求
3. **设置** [Webhook](/cn/webhook-reference/introduction) 用于实时通知
