|
| 1 | +## moderation-api/sdk-php 1.0.0 |
| 2 | + |
| 3 | +The first stable version of the PHP SDK. Read the breaking changes before you upgrade. |
| 4 | + |
| 5 | +```bash |
| 6 | +composer require moderation-api/sdk-php:^1.0 |
| 7 | +``` |
| 8 | + |
| 9 | +### PHP-specific changes |
| 10 | + |
| 11 | +- Requires PHP 8.2 or later (was 8.1). |
| 12 | +- The namespace is `ModerationApi` (was `ModerationAPI`). Create the client with `ModerationApi\ModerationApi::builder()->setSecurity($key)->build()`. |
| 13 | +- Requests are typed objects, for example `new Operations\SubmitContentRequest(content: new Operations\TextRequest(text: '...'))`, and responses carry the result in `->object`. |
| 14 | +- Verify webhooks with `ModerationApi\WebhookSignature::constructEvent($payload, $signature)`. |
| 15 | +### What's new |
| 16 | + |
| 17 | +- **Covers the whole API**, including the management API (`projects`, `channels`), wordlists and the review queue. |
| 18 | +- **Automatic pagination.** List methods return an iterator that fetches the next page for you. |
| 19 | +- **Clear errors.** One error class per HTTP status (`BadRequestError`, `NotFoundError`, `RateLimitError`, ...). Every error has a specific `code` (for example `invalid_api_key`, `quota_exceeded` or `author_not_found`), a `request_id` and a `doc_url`. See [Errors](https://docs.moderationapi.com/api-reference/errors). |
| 20 | +- **Retries** with exponential backoff on `429` and `5xx`, and timeouts per client or per request. |
| 21 | +- **Webhook verification** that reads the secret from `MODAPI_WEBHOOK_SECRET`. |
| 22 | + |
| 23 | +### Breaking changes |
| 24 | + |
| 25 | +The SDK is now generated from our OpenAPI spec with a new generator. Most calls keep their names, but check these: |
| 26 | + |
| 27 | +- **List responses** are `{ data, pagination }` instead of a plain array or a resource-specific shape, and list methods take `page` and `pageSize`. |
| 28 | +- **Errors** have a new body: `code` is the specific error code, not the HTTP category. The old `data` field is gone. |
| 29 | +- **Renamed:** `account.list` is now `account.retrieve`, and `actions.execute.execute` is now `actions.execute`. |
| 30 | +- **Removed:** `actions.execute.executeByID` (use `actions.execute` with `actionId` or `actionKey`), `auth.*`, and `content.stream` (see [Real-time voice](https://docs.moderationapi.com/content-moderation/real-time-voice)). |
| 31 | +- **Organization keys** work only with `projects` and `channels`; project keys work with everything else. Use one client per key. See the README. |
| 32 | + |
| 33 | +The license is unchanged: Apache-2.0. |
0 commit comments