Skip to content

Commit 0d8014a

Browse files
feat(api): Add card/account/business account signals endpoints and behavioral rule attributes
1 parent 8434d72 commit 0d8014a

5 files changed

Lines changed: 163 additions & 5 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: 190
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-28c9b43d3182bf0e1c9635f6100e4995a744724db1edd635cfd3fc7702ced68c.yml
3-
openapi_spec_hash: aba00a65f877c5095499d9d1a66b5e5f
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-d29b68bb85936070878d8badaa8a7c5991313285e70a990bc812c838eba85373.yml
3+
openapi_spec_hash: 54b44da68df22eb0ea99f2bc564667a2
44
config_hash: ac8326134e692f3f3bdec82396bbec80

src/lithic/types/auth_rules/conditional_authorization_action_parameters.py

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List
3+
from typing import List, Optional
44
from typing_extensions import Literal
55

66
from ..._models import BaseModel
77
from .conditional_value import ConditionalValue
88
from .conditional_operation import ConditionalOperation
99

10-
__all__ = ["ConditionalAuthorizationActionParameters", "Condition"]
10+
__all__ = ["ConditionalAuthorizationActionParameters", "Condition", "ConditionParameters"]
11+
12+
13+
class ConditionParameters(BaseModel):
14+
"""Additional parameters required for transaction history signal attributes.
15+
16+
Required when
17+
`attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
18+
`STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`,
19+
`CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT`.
20+
Not used for other attributes.
21+
"""
22+
23+
interval: Optional[Literal["LIFETIME", "7D", "30D", "90D"]] = None
24+
"""
25+
The time window for statistical attributes (`AMOUNT_Z_SCORE`,
26+
`AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`). Use `LIFETIME` for
27+
all-time history or a specific window (`7D`, `30D`, `90D`).
28+
"""
29+
30+
scope: Optional[Literal["CARD", "ACCOUNT", "BUSINESS_ACCOUNT"]] = None
31+
"""The entity scope to evaluate the attribute against."""
1132

1233

1334
class Condition(BaseModel):
@@ -38,6 +59,16 @@ class Condition(BaseModel):
3859
"SERVICE_LOCATION_POSTAL_CODE",
3960
"CARD_AGE",
4061
"ACCOUNT_AGE",
62+
"AMOUNT_Z_SCORE",
63+
"AVG_TRANSACTION_AMOUNT",
64+
"STDEV_TRANSACTION_AMOUNT",
65+
"IS_NEW_COUNTRY",
66+
"IS_NEW_MCC",
67+
"IS_FIRST_TRANSACTION",
68+
"CONSECUTIVE_DECLINES",
69+
"TIME_SINCE_LAST_TRANSACTION",
70+
"DISTINCT_COUNTRY_COUNT",
71+
"THREE_DS_SUCCESS_RATE",
4172
]
4273
"""The attribute to target.
4374
@@ -110,6 +141,33 @@ class Condition(BaseModel):
110141
- `CARD_AGE`: The age of the card in seconds at the time of the authorization.
111142
- `ACCOUNT_AGE`: The age of the account holder's account in seconds at the time
112143
of the authorization.
144+
- `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the
145+
entity's transaction history. Null if fewer than 30 approved transactions in
146+
the specified window. Requires `parameters.scope` and `parameters.interval`.
147+
- `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the
148+
entity over the specified window, in cents. Requires `parameters.scope` and
149+
`parameters.interval`.
150+
- `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction
151+
amounts for the entity over the specified window, in cents. Null if fewer than
152+
30 approved transactions in the specified window. Requires `parameters.scope`
153+
and `parameters.interval`.
154+
- `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen
155+
in the entity's transaction history. Valid values are `TRUE`, `FALSE`.
156+
Requires `parameters.scope`.
157+
- `IS_NEW_MCC`: Whether the transaction's MCC has not been seen in the entity's
158+
transaction history. Valid values are `TRUE`, `FALSE`. Requires
159+
`parameters.scope`.
160+
- `IS_FIRST_TRANSACTION`: Whether this is the first transaction for the entity.
161+
Valid values are `TRUE`, `FALSE`. Requires `parameters.scope`.
162+
- `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for
163+
the entity over the last 30 days (rolling). Requires `parameters.scope`. Not
164+
supported for `BUSINESS_ACCOUNT` scope.
165+
- `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved
166+
transaction for the entity. Requires `parameters.scope`.
167+
- `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in
168+
the entity's transaction history. Requires `parameters.scope`.
169+
- `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as
170+
a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required.
113171
"""
114172

115173
operation: ConditionalOperation
@@ -118,6 +176,15 @@ class Condition(BaseModel):
118176
value: ConditionalValue
119177
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""
120178

179+
parameters: Optional[ConditionParameters] = None
180+
"""Additional parameters required for transaction history signal attributes.
181+
182+
Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
183+
`STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`,
184+
`IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`,
185+
or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes.
186+
"""
187+
121188

122189
class ConditionalAuthorizationActionParameters(BaseModel):
123190
action: Literal["DECLINE", "CHALLENGE"]

src/lithic/types/auth_rules/conditional_authorization_action_parameters_param.py

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,28 @@
99
from .conditional_operation import ConditionalOperation
1010
from .conditional_value_param import ConditionalValueParam
1111

12-
__all__ = ["ConditionalAuthorizationActionParametersParam", "Condition"]
12+
__all__ = ["ConditionalAuthorizationActionParametersParam", "Condition", "ConditionParameters"]
13+
14+
15+
class ConditionParameters(TypedDict, total=False):
16+
"""Additional parameters required for transaction history signal attributes.
17+
18+
Required when
19+
`attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
20+
`STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`,
21+
`CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT`.
22+
Not used for other attributes.
23+
"""
24+
25+
interval: Literal["LIFETIME", "7D", "30D", "90D"]
26+
"""
27+
The time window for statistical attributes (`AMOUNT_Z_SCORE`,
28+
`AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`). Use `LIFETIME` for
29+
all-time history or a specific window (`7D`, `30D`, `90D`).
30+
"""
31+
32+
scope: Literal["CARD", "ACCOUNT", "BUSINESS_ACCOUNT"]
33+
"""The entity scope to evaluate the attribute against."""
1334

1435

1536
class Condition(TypedDict, total=False):
@@ -41,6 +62,16 @@ class Condition(TypedDict, total=False):
4162
"SERVICE_LOCATION_POSTAL_CODE",
4263
"CARD_AGE",
4364
"ACCOUNT_AGE",
65+
"AMOUNT_Z_SCORE",
66+
"AVG_TRANSACTION_AMOUNT",
67+
"STDEV_TRANSACTION_AMOUNT",
68+
"IS_NEW_COUNTRY",
69+
"IS_NEW_MCC",
70+
"IS_FIRST_TRANSACTION",
71+
"CONSECUTIVE_DECLINES",
72+
"TIME_SINCE_LAST_TRANSACTION",
73+
"DISTINCT_COUNTRY_COUNT",
74+
"THREE_DS_SUCCESS_RATE",
4475
]
4576
]
4677
"""The attribute to target.
@@ -114,6 +145,33 @@ class Condition(TypedDict, total=False):
114145
- `CARD_AGE`: The age of the card in seconds at the time of the authorization.
115146
- `ACCOUNT_AGE`: The age of the account holder's account in seconds at the time
116147
of the authorization.
148+
- `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the
149+
entity's transaction history. Null if fewer than 30 approved transactions in
150+
the specified window. Requires `parameters.scope` and `parameters.interval`.
151+
- `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the
152+
entity over the specified window, in cents. Requires `parameters.scope` and
153+
`parameters.interval`.
154+
- `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction
155+
amounts for the entity over the specified window, in cents. Null if fewer than
156+
30 approved transactions in the specified window. Requires `parameters.scope`
157+
and `parameters.interval`.
158+
- `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen
159+
in the entity's transaction history. Valid values are `TRUE`, `FALSE`.
160+
Requires `parameters.scope`.
161+
- `IS_NEW_MCC`: Whether the transaction's MCC has not been seen in the entity's
162+
transaction history. Valid values are `TRUE`, `FALSE`. Requires
163+
`parameters.scope`.
164+
- `IS_FIRST_TRANSACTION`: Whether this is the first transaction for the entity.
165+
Valid values are `TRUE`, `FALSE`. Requires `parameters.scope`.
166+
- `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for
167+
the entity over the last 30 days (rolling). Requires `parameters.scope`. Not
168+
supported for `BUSINESS_ACCOUNT` scope.
169+
- `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved
170+
transaction for the entity. Requires `parameters.scope`.
171+
- `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in
172+
the entity's transaction history. Requires `parameters.scope`.
173+
- `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as
174+
a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required.
117175
"""
118176

119177
operation: Required[ConditionalOperation]
@@ -122,6 +180,15 @@ class Condition(TypedDict, total=False):
122180
value: Required[Annotated[ConditionalValueParam, PropertyInfo(format="iso8601")]]
123181
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""
124182

183+
parameters: ConditionParameters
184+
"""Additional parameters required for transaction history signal attributes.
185+
186+
Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
187+
`STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`,
188+
`IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`,
189+
or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes.
190+
"""
191+
125192

126193
class ConditionalAuthorizationActionParametersParam(TypedDict, total=False):
127194
action: Required[Literal["DECLINE", "CHALLENGE"]]

src/lithic/types/auth_rules/rule_feature.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"AccountHolderFeature",
1818
"IPMetadataFeature",
1919
"SpendVelocityFeature",
20+
"TransactionHistorySignalsFeature",
2021
]
2122

2223

@@ -84,6 +85,16 @@ class SpendVelocityFeature(BaseModel):
8485
"""The variable name for this feature in the rule function signature"""
8586

8687

88+
class TransactionHistorySignalsFeature(BaseModel):
89+
scope: Literal["CARD", "ACCOUNT", "BUSINESS_ACCOUNT"]
90+
"""The entity scope to load transaction history signals for."""
91+
92+
type: Literal["TRANSACTION_HISTORY_SIGNALS"]
93+
94+
name: Optional[str] = None
95+
"""The variable name for this feature in the rule function signature"""
96+
97+
8798
RuleFeature: TypeAlias = Union[
8899
AuthorizationFeature,
89100
AuthenticationFeature,
@@ -93,4 +104,5 @@ class SpendVelocityFeature(BaseModel):
93104
AccountHolderFeature,
94105
IPMetadataFeature,
95106
SpendVelocityFeature,
107+
TransactionHistorySignalsFeature,
96108
]

src/lithic/types/auth_rules/rule_feature_param.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"AccountHolderFeature",
1919
"IPMetadataFeature",
2020
"SpendVelocityFeature",
21+
"TransactionHistorySignalsFeature",
2122
]
2223

2324

@@ -85,6 +86,16 @@ class SpendVelocityFeature(TypedDict, total=False):
8586
"""The variable name for this feature in the rule function signature"""
8687

8788

89+
class TransactionHistorySignalsFeature(TypedDict, total=False):
90+
scope: Required[Literal["CARD", "ACCOUNT", "BUSINESS_ACCOUNT"]]
91+
"""The entity scope to load transaction history signals for."""
92+
93+
type: Required[Literal["TRANSACTION_HISTORY_SIGNALS"]]
94+
95+
name: str
96+
"""The variable name for this feature in the rule function signature"""
97+
98+
8899
RuleFeatureParam: TypeAlias = Union[
89100
AuthorizationFeature,
90101
AuthenticationFeature,
@@ -94,4 +105,5 @@ class SpendVelocityFeature(TypedDict, total=False):
94105
AccountHolderFeature,
95106
IPMetadataFeature,
96107
SpendVelocityFeature,
108+
TransactionHistorySignalsFeature,
97109
]

0 commit comments

Comments
 (0)