Skip to content

Commit 3a009aa

Browse files
feat(api): api update
1 parent cb91535 commit 3a009aa

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 27
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-a4934bf1e7f1348c021b48224f7a7110a6e41838253dda4fbcc720dd2d2ed6b7.yml
3-
openapi_spec_hash: 537542216811907b1d4ebf23a54dc669
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-c8e66e827fc2b1465b740a29e87da71c3b1ddca1a4bdb1023aa96c569b80e9be.yml
3+
openapi_spec_hash: 35fdc3e34feb56cafaf4de2834201978
44
config_hash: 0a024bca1710e3a3194925edfedc513c

‎src/moderation_api/types/content_submit_params.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict, Union, Iterable
66
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

8+
from .._types import SequenceNotStr
89
from .._utils import PropertyInfo
910

1011
__all__ = [
@@ -418,6 +419,19 @@ class PolicyURLRisk(TypedDict, total=False):
418419

419420
flag: Required[bool]
420421

422+
allowlist_wordlist_ids: Annotated[SequenceNotStr[str], PropertyInfo(alias="allowlistWordlistIds")]
423+
"""IDs of wordlists whose entries are treated as allowed URL domains.
424+
425+
Matches short-circuit the risk model and are never flagged.
426+
"""
427+
428+
blocklist_wordlist_ids: Annotated[SequenceNotStr[str], PropertyInfo(alias="blocklistWordlistIds")]
429+
"""IDs of wordlists whose entries are treated as blocked URL domains.
430+
431+
Matches short-circuit the risk model and are always flagged. Blocklists take
432+
precedence over allowlists.
433+
"""
434+
421435
threshold: float
422436

423437

‎src/moderation_api/types/content_submit_response.py‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"PolicyClassifierOutputLabel",
2727
"PolicyEntityMatcherOutput",
2828
"PolicyEntityMatcherOutputMatch",
29+
"PolicyEntityMatcherOutputMatchSignals",
30+
"PolicyEntityMatcherOutputMatchSignalsBrandImpersonation",
2931
"Recommendation",
3032
"Error",
3133
]
@@ -245,13 +247,60 @@ class PolicyClassifierOutput(BaseModel):
245247
labels: Optional[List[PolicyClassifierOutputLabel]] = None
246248

247249

250+
class PolicyEntityMatcherOutputMatchSignalsBrandImpersonation(BaseModel):
251+
brand: str
252+
253+
method: Literal["registered_domain_token", "subdomain_token"]
254+
255+
256+
class PolicyEntityMatcherOutputMatchSignals(BaseModel):
257+
"""Observable properties of a URL (URL Risk only).
258+
259+
Absent for allow/block list matches.
260+
"""
261+
262+
bot_protection: Optional[bool] = None
263+
264+
brand_impersonation: Optional[PolicyEntityMatcherOutputMatchSignalsBrandImpersonation] = None
265+
266+
domain_age_days: Optional[int] = None
267+
268+
final_url: Optional[str] = None
269+
270+
has_email_setup: Optional[bool] = None
271+
272+
has_suspicious_characters: bool
273+
274+
is_link_shortener: bool
275+
276+
is_reported: bool
277+
278+
redirect_count: Optional[int] = None
279+
280+
248281
class PolicyEntityMatcherOutputMatch(BaseModel):
249282
match: str
250283

251284
probability: float
252285

253286
span: List[int]
254287

288+
entity_type: Optional[str] = None
289+
"""Sub-type of the entity match — e.g.
290+
291+
the NER key (email, phone, name, …) for PII matches. Absent for URL Risk and
292+
wordlist matches where the type is already encoded in the parent label.
293+
"""
294+
295+
reasons: Optional[List[str]] = None
296+
"""Stable codes explaining why a URL was flagged (URL Risk only)."""
297+
298+
signals: Optional[PolicyEntityMatcherOutputMatchSignals] = None
299+
"""Observable properties of a URL (URL Risk only).
300+
301+
Absent for allow/block list matches.
302+
"""
303+
255304

256305
class PolicyEntityMatcherOutput(BaseModel):
257306
"""Entity matcher policy."""

0 commit comments

Comments
 (0)