Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.11.3"
".": "0.12.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-a4934bf1e7f1348c021b48224f7a7110a6e41838253dda4fbcc720dd2d2ed6b7.yml
openapi_spec_hash: 537542216811907b1d4ebf23a54dc669
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-c8e66e827fc2b1465b740a29e87da71c3b1ddca1a4bdb1023aa96c569b80e9be.yml
openapi_spec_hash: 35fdc3e34feb56cafaf4de2834201978
config_hash: 0a024bca1710e3a3194925edfedc513c
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.12.0 (2026-04-24)

Full Changelog: [v0.11.3...v0.12.0](https://github.com/moderation-api/sdk-php/compare/v0.11.3...v0.12.0)

### Features

* **api:** api update ([7ac5a57](https://github.com/moderation-api/sdk-php/commit/7ac5a5735852a169496b45c37438aa49a3fa7551))

## 0.11.3 (2026-04-18)

Full Changelog: [v0.11.2...v0.11.3](https://github.com/moderation-api/sdk-php/compare/v0.11.2...v0.11.3)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The REST API documentation can be found on [docs.moderationapi.com](https://docs
<!-- x-release-please-start-version -->

```
composer require "moderation-api/sdk-php 0.11.3"
composer require "moderation-api/sdk-php 0.12.0"
```

<!-- x-release-please-end -->
Expand Down
61 changes: 58 additions & 3 deletions src/Content/ContentSubmitParams/Policy/URLRisk.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

/**
* @phpstan-type URLRiskShape = array{
* id: 'url_risk', flag: bool, threshold?: float|null
* id: 'url_risk',
* flag: bool,
* allowlistWordlistIDs?: list<string>|null,
* blocklistWordlistIDs?: list<string>|null,
* threshold?: float|null,
* }
*/
final class URLRisk implements BaseModel
Expand All @@ -26,6 +30,22 @@ final class URLRisk implements BaseModel
#[Required]
public bool $flag;

/**
* IDs of wordlists whose entries are treated as allowed URL domains. Matches short-circuit the risk model and are never flagged.
*
* @var list<string>|null $allowlistWordlistIDs
*/
#[Optional('allowlistWordlistIds', list: 'string')]
public ?array $allowlistWordlistIDs;

/**
* IDs of wordlists whose entries are treated as blocked URL domains. Matches short-circuit the risk model and are always flagged. Blocklists take precedence over allowlists.
*
* @var list<string>|null $blocklistWordlistIDs
*/
#[Optional('blocklistWordlistIds', list: 'string')]
public ?array $blocklistWordlistIDs;

#[Optional]
public ?float $threshold;

Expand All @@ -52,13 +72,22 @@ public function __construct()
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param list<string>|null $allowlistWordlistIDs
* @param list<string>|null $blocklistWordlistIDs
*/
public static function with(bool $flag, ?float $threshold = null): self
{
public static function with(
bool $flag,
?array $allowlistWordlistIDs = null,
?array $blocklistWordlistIDs = null,
?float $threshold = null,
): self {
$self = new self;

$self['flag'] = $flag;

null !== $allowlistWordlistIDs && $self['allowlistWordlistIDs'] = $allowlistWordlistIDs;
null !== $blocklistWordlistIDs && $self['blocklistWordlistIDs'] = $blocklistWordlistIDs;
null !== $threshold && $self['threshold'] = $threshold;

return $self;
Expand All @@ -83,6 +112,32 @@ public function withFlag(bool $flag): self
return $self;
}

/**
* IDs of wordlists whose entries are treated as allowed URL domains. Matches short-circuit the risk model and are never flagged.
*
* @param list<string> $allowlistWordlistIDs
*/
public function withAllowlistWordlistIDs(array $allowlistWordlistIDs): self
{
$self = clone $this;
$self['allowlistWordlistIDs'] = $allowlistWordlistIDs;

return $self;
}

/**
* IDs of wordlists whose entries are treated as blocked URL domains. Matches short-circuit the risk model and are always flagged. Blocklists take precedence over allowlists.
*
* @param list<string> $blocklistWordlistIDs
*/
public function withBlocklistWordlistIDs(array $blocklistWordlistIDs): self
{
$self = clone $this;
$self['blocklistWordlistIDs'] = $blocklistWordlistIDs;

return $self;
}

public function withThreshold(float $threshold): self
{
$self = clone $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@

namespace ModerationAPI\Content\ContentSubmitResponse\Policy\EntityMatcherOutput;

use ModerationAPI\Content\ContentSubmitResponse\Policy\EntityMatcherOutput\Match_\Signals;
use ModerationAPI\Core\Attributes\Optional;
use ModerationAPI\Core\Attributes\Required;
use ModerationAPI\Core\Concerns\SdkModel;
use ModerationAPI\Core\Contracts\BaseModel;

/**
* @phpstan-import-type SignalsShape from \ModerationAPI\Content\ContentSubmitResponse\Policy\EntityMatcherOutput\Match_\Signals
*
* @phpstan-type MatchShape = array{
* match: string, probability: float, span: list<int>
* match: string,
* probability: float,
* span: list<int>,
* entityType?: string|null,
* reasons?: list<string>|null,
* signals?: null|Signals|SignalsShape,
* }
*/
final class Match_ implements BaseModel
Expand All @@ -28,6 +37,26 @@ final class Match_ implements BaseModel
#[Required(list: 'int')]
public array $span;

/**
* Sub-type of the entity match — e.g. the NER key (email, phone, name, …) for PII matches. Absent for URL Risk and wordlist matches where the type is already encoded in the parent label.
*/
#[Optional('entity_type')]
public ?string $entityType;

/**
* Stable codes explaining why a URL was flagged (URL Risk only).
*
* @var list<string>|null $reasons
*/
#[Optional(list: 'string')]
public ?array $reasons;

/**
* Observable properties of a URL (URL Risk only). Absent for allow/block list matches.
*/
#[Optional]
public ?Signals $signals;

/**
* `new Match_()` is missing required properties by the API.
*
Expand All @@ -53,18 +82,27 @@ public function __construct()
* You must use named parameters to construct any parameters with a default value.
*
* @param list<int> $span
* @param list<string>|null $reasons
* @param Signals|SignalsShape|null $signals
*/
public static function with(
string $match,
float $probability,
array $span
array $span,
?string $entityType = null,
?array $reasons = null,
Signals|array|null $signals = null,
): self {
$self = new self;

$self['match'] = $match;
$self['probability'] = $probability;
$self['span'] = $span;

null !== $entityType && $self['entityType'] = $entityType;
null !== $reasons && $self['reasons'] = $reasons;
null !== $signals && $self['signals'] = $signals;

return $self;
}

Expand Down Expand Up @@ -94,4 +132,41 @@ public function withSpan(array $span): self

return $self;
}

/**
* Sub-type of the entity match — e.g. the NER key (email, phone, name, …) for PII matches. Absent for URL Risk and wordlist matches where the type is already encoded in the parent label.
*/
public function withEntityType(string $entityType): self
{
$self = clone $this;
$self['entityType'] = $entityType;

return $self;
}

/**
* Stable codes explaining why a URL was flagged (URL Risk only).
*
* @param list<string> $reasons
*/
public function withReasons(array $reasons): self
{
$self = clone $this;
$self['reasons'] = $reasons;

return $self;
}

/**
* Observable properties of a URL (URL Risk only). Absent for allow/block list matches.
*
* @param Signals|SignalsShape $signals
*/
public function withSignals(Signals|array $signals): self
{
$self = clone $this;
$self['signals'] = $signals;

return $self;
}
}
Loading