From 1311591773a961cc928674cca8948d9a8da7c87a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Nov 2026 10:10:17 +0000 Subject: [PATCH] feat(spec): sync API spec 2026-11-24 Synced openapi/verification.json from the published API contract (docs/DESIGN.md section 3.1). Operations: 24 added, 0 removed, 0 renamed, 0 moved, 0 changed. Regenerated the SDK. --- lib/didit/resources/messages.rb | 42 + lib/didit/resources/phone.rb | 804 +++++++ lib/didit/types.rb | 60 + lib/didit/types/components.rb | 227 ++ lib/didit/types/messages.rb | 20 + lib/didit/types/phone.rb | 309 +++ openapi/SOURCE.json | 4 +- openapi/verification.json | 3707 ++++++++++++++++++++++++++++++ sig/didit/resources/messages.rbs | 4 + sig/didit/resources/phone.rbs | 45 + sig/didit/types/components.rbs | 212 ++ sig/didit/types/messages.rbs | 22 + sig/didit/types/phone.rbs | 312 +++ spec/generated/messages_spec.rb | 41 + spec/generated/phone_spec.rb | 878 +++++++ 15 files changed, 6685 insertions(+), 2 deletions(-) diff --git a/lib/didit/resources/messages.rb b/lib/didit/resources/messages.rb index e9e4696..3aa5f3f 100644 --- a/lib/didit/resources/messages.rb +++ b/lib/didit/resources/messages.rb @@ -5,6 +5,11 @@ module Didit module Resources # The +messages+ resource. class Messages < Didit::Resource + # @return [Didit::Resources::Messages::Rules] + def rules + @rules ||= Rules.new(@client) + end + # Cancel a scheduled message # # Cancel a message scheduled with `schedule_at`, before its time: only a `scheduled` message can be cancelled, @@ -294,6 +299,43 @@ def update_settings(retention_days:, request_options: nil) request_options: request_options ) end + + # The +messages.rules+ resource. + class Rules < Didit::Resource + # Create a messaging rule + # + # Add a messaging rule that allows or blocks by country, prefix or number. Send exactly one of `match.country` + # (an ISO country code), `match.prefix` or `match.number`; `direction` is `outbound` (the default) or + # `inbound`, and `channels` limits the rule to the channels it names. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/messages/rules/+ + # + # @param action [String] allow or block + # @param match [Hash] Exactly one of `country`, `prefix` or `number`. + # @param direction [String] outbound (default) or inbound + # @param channels [Array] The channels it covers, for example `sms`, `whatsapp` or `voice`; all + # channels when you send none + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::MessagesRulesCreateResponse] + def create(action:, match:, direction: OMIT, channels: OMIT, idempotency_key: OMIT, request_options: nil) + @client.request( + :post, + "/v3/messages/rules/", + body: { + "action" => action, + "match" => match, + "direction" => direction, + "channels" => channels + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::MessagesRulesCreateResponse, + request_options: request_options + ) + end + end end end end diff --git a/lib/didit/resources/phone.rb b/lib/didit/resources/phone.rb index 707bebe..948d6dc 100644 --- a/lib/didit/resources/phone.rb +++ b/lib/didit/resources/phone.rb @@ -5,6 +5,26 @@ module Didit module Resources # The +phone+ resource. class Phone < Didit::Resource + # @return [Didit::Resources::Phone::Fraud] + def fraud + @fraud ||= Fraud.new(@client) + end + + # @return [Didit::Resources::Phone::LineTypeOverrides] + def line_type_overrides + @line_type_overrides ||= LineTypeOverrides.new(@client) + end + + # @return [Didit::Resources::Phone::Lists] + def lists + @lists ||= Lists.new(@client) + end + + # @return [Didit::Resources::Phone::RateLimits] + def rate_limits + @rate_limits ||= RateLimits.new(@client) + end + # Risk-score a phone number # # Resolve a phone number and return carrier, line-type, porting, disposable-number, cross-session match, and @@ -84,6 +104,47 @@ def assess_risk( ) end + # Start a bulk lookup + # + # Look up a CSV of numbers as one job: one number per line, up to 100,000 numbers, with `fields` naming the + # signals to return for each number. The call answers `202` with the job (`status` `queued`, `processed` 0, + # `results_url` `null`). Read it with `GET /v3/phone/risk/bulk/{job_id}/`; when it is done, download the CSV + # from `results_url`. `callback_url`, a public HTTPS URL, receives `{job_id, status, total, results_url}` when + # the job finishes (described by `PhoneRiskBulkCallback`). + # + # Billing follows Phone Risk API pricing for each number in the file; a number that is not valid is not charged. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/risk/bulk/+ + # + # @param file [Pathname, IO, String, Didit::FilePart] A CSV of numbers, one number per line, up to 100,000. + # @param fields [Array] The signals to return, one CSV column each, in this order; all of them when you + # send none. `format`, `line_type` and `network` are answered. `reachability`, `sim_swap`, `sms_pumping_risk`, + # `prefill`, `scam_signal` and `identity_match` are accepted and their columns come back empty: a file that asks + # for those alone looks up nothing and is not charged for lookups. + # @param callback_url [String] A public HTTPS URL Didit posts to when the job is done: `{job_id, status, total, + # results_url}`, with `results_url` the same relative path as on the job. Any other URL answers `400`. + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneRiskBulkJob] + def assess_risk_bulk(file:, fields: OMIT, callback_url: OMIT, idempotency_key: OMIT, request_options: nil) + @client.request( + :post, + "/v3/phone/risk/bulk/", + body: { + "file" => file, + "fields" => fields, + "callback_url" => callback_url + }, + encoding: :multipart, + file_fields: %w[file], + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneRiskBulkJob, + request_options: request_options + ) + end + # Check Phone Code # # Verify the OTP delivered by [`POST /v3/phone/send/`](/standalone-apis/phone-send) and get the final @@ -215,6 +276,53 @@ def check_code( ) end + # Download bulk lookup results + # + # Download the CSV of a bulk risk job: the column `phone_number` plus one column per requested signal, one row + # per number in the order of the uploaded file. A failed job still has the rows it answered. While no result + # file exists the answer is `409 results_not_ready`. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +GET /v3/phone/risk/bulk/{job_id}/results/+ + # + # @param job_id [String] The job, as returned when it was started. + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [String, nil] the body bytes, or nil when a block receives the chunks + def download_risk_bulk_results(job_id, request_options: nil, &block) + @client.request( + :get, + "/v3/phone/risk/bulk/{job_id}/results/", + path_params: { "job_id" => job_id }, + response: :binary, + accept: "text/csv, application/json", + request_options: request_options, &block + ) + end + + # Get a bulk lookup job + # + # Read a bulk risk job of your application: its `status`, how many numbers it has `processed` of its `total`, + # and the `results_url` of the CSV once a result file exists. An unknown job, or one of another application, + # answers `404`. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +GET /v3/phone/risk/bulk/{job_id}/+ + # + # @param job_id [String] The job, as returned when it was started. + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneRiskBulkJob] + def retrieve_risk_bulk(job_id, request_options: nil) + @client.request( + :get, + "/v3/phone/risk/bulk/{job_id}/", + path_params: { "job_id" => job_id }, + response: Types::PhoneRiskBulkJob, + request_options: request_options + ) + end + # Send Phone Code # # Send a one-time passcode (OTP) to a phone number over WhatsApp, SMS, or another supported channel, then verify @@ -307,6 +415,702 @@ def send_code( request_options: request_options ) end + + # The +phone.fraud+ resource. + class Fraud < Didit::Resource + # @return [Didit::Resources::Phone::Fraud::Events] + def events + @events ||= Events.new(@client) + end + + # @return [Didit::Resources::Phone::Fraud::Policies] + def policies + @policies ||= Policies.new(@client) + end + + # Score a number, an email address or both against your fraud rules + # + # Score a request before a code is sent: the number, the email address or both are evaluated against your + # fraud rules and the weighted policy of the flow in `action` (`signup`, `login`, `payment` or a flow of your + # own). Send `phone_number`, `email`, or both; a request with neither answers `400 target_required`. + # + # The answer carries the `decision` (`allow`, `review`, `challenge` or `block`), a `score` from 0 to 100, the + # rules that decided, the flow policy's score and the conditions that met it, and an email block when an + # address was scored. `challenge_channels` lists where a challenged verification may continue: SMS and voice + # are withheld. + # + # Send `ip_address` and `device_signals` when you have them; the `existing_user` flag tells the scoring a + # returning user is asking. `trusted_user` with a `fraud_override` signed for this one request takes it past + # your fraud rules, and a block list still stops the number. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/fraud/evaluate/+ + # + # @param phone_number [String] The number; or leave it out and send email alone + # @param email [String] An email address to score before a code is sent, alone or with the number + # @param action [String] The flow being scored: `signup` (the default), `login`, `payment` or a flow of your + # own, at most 64 characters. + # @param ip_address [String] Your user's IP address + # @param device_signals [String] The signed token from the SDK + # @param existing_user [Boolean] true: the number belongs to a user who has signed in before; the fraud + # scoring weighs returning users and new sign-ups differently + # @param trusted_user [Boolean] Evaluate as a trusted-user exception: with a fraud_override signed for this + # number, the decision is allow unless a block list matches + # @param fraud_override [String] The signed token for this number, as on send + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneFraudEvaluateResponse] + def evaluate( + phone_number: OMIT, + email: OMIT, + action: OMIT, + ip_address: OMIT, + device_signals: OMIT, + existing_user: OMIT, + trusted_user: OMIT, + fraud_override: OMIT, + idempotency_key: OMIT, + request_options: nil + ) + @client.request( + :post, + "/v3/phone/fraud/evaluate/", + body: { + "phone_number" => phone_number, + "email" => email, + "action" => action, + "ip_address" => ip_address, + "device_signals" => device_signals, + "existing_user" => existing_user, + "trusted_user" => trusted_user, + "fraud_override" => fraud_override + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneFraudEvaluateResponse, + request_options: request_options + ) + end + + # Update fraud settings + # + # Change the application's fraud protection: the level, the rules and where each rule applies. `level` is + # `standard` or `strict`, or `custom` when your own rules decide. + # + # A rule names a `key` - `velocity`, `pumping`, `risk_score`, `sim_swap`, `device` or `country` - and its + # `action`: `allow`, `review`, `require_code` or `block`, and `challenge`, which continues the verification + # only on the channels in `challenge_channels`. A rule applies only to the `countries` and `platforms` you + # name, and to verification codes: `scope` is `codes`, the only value, and any other value answers `400`. + # + # `sim_swap_within` is the window, in hours, after a SIM change in which a code is required instead of a + # silent check, or the number is blocked. `daily_cap` stops new codes at this spend per day, in USD. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +PATCH /v3/phone/fraud/+ + # + # @param level [String] standard, strict or custom + # @param rules [Array] + # @param challenge_channels [Array] Where a challenged verification may continue; SMS and voice are + # withheld + # @param sim_swap_within [Integer] Hours: after a SIM change in this window, ask for a code instead of silent, + # or block + # @param daily_cap [String, nil] New codes stop at this spend per day, in USD, as a decimal string with at + # most two decimals; `null` removes the cap + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneFraudUpdateResponse] + def update( + level: OMIT, + rules: OMIT, + challenge_channels: OMIT, + sim_swap_within: OMIT, + daily_cap: OMIT, + idempotency_key: OMIT, + request_options: nil + ) + @client.request( + :patch, + "/v3/phone/fraud/", + body: { + "level" => level, + "rules" => rules, + "challenge_channels" => challenge_channels, + "sim_swap_within" => sim_swap_within, + "daily_cap" => daily_cap + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneFraudUpdateResponse, + request_options: request_options + ) + end + + # The +phone.fraud.events+ resource. + class Events < Didit::Resource + # Send fraud events in a batch + # + # Send up to 1,000 of your own events - a `signup`, a `login`, a `payment`, a `password_reset`, an + # `account_change` or a type of your own - to the fraud scoring, with the number, the email address, the IP + # address and the device signals of each one. + # + # The answer is `207 Multi-Status`: `accepted` counts the events the scoring uses from the next request, and + # `results` gives each event's place in `events`, its id, whether it was accepted and, when it was rejected, + # why. An event with no `type` or `occurred_at` is rejected on its own as `invalid_event` in `results` while + # the valid events of the same batch are accepted: the answer is still `207`. A request whose `events` is + # not a list of objects with correctly typed fields is a malformed request. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/fraud/events/batch/+ + # + # @param events [Array] Up to 1,000 events, each with the number, the address and what happened. + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneFraudEventsCreateBatchResponse] + def create_batch(events:, idempotency_key: OMIT, request_options: nil) + @client.request( + :post, + "/v3/phone/fraud/events/batch/", + body: { + "events" => events + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneFraudEventsCreateBatchResponse, + request_options: request_options + ) + end + end + + # The +phone.fraud.policies+ resource. + class Policies < Didit::Resource + # Create a fraud policy + # + # Create a weighted fraud policy for one flow. Each condition names a `signal` (`risk_score`, `sim_swap`, + # `line_type`, `country`, `velocity`, `ip_risk`, `device`, `email_risk` or `existing_user`), an `operator` + # (`eq`, `neq`, `gt`, `lt`, `in` or `within_hours`), the `value` to compare with and the `weight` its points + # add to the score (0 to 100). The weights of the conditions that hold add up to a score, and `threshold` is + # the score at which `action` applies (`allow`, `review`, `challenge` or `block`). + # + # A flow has one policy: a second one answers `409 flow_has_policy`, and the existing policy is changed + # instead. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/fraud/policies/+ + # + # @param name [String] Its name + # @param flow [String] The flow it scores: `signup`, `login`, `payment` or a flow of your own, as sent in + # `action` on evaluate and send. + # @param conditions [Array] + # @param threshold [Integer] The score at which action applies + # @param action [String] allow, review, challenge or block + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneFraudPolicy] + def create( + name: OMIT, + flow: OMIT, + conditions: OMIT, + threshold: OMIT, + action: OMIT, + idempotency_key: OMIT, + request_options: nil + ) + @client.request( + :post, + "/v3/phone/fraud/policies/", + body: { + "name" => name, + "flow" => flow, + "conditions" => conditions, + "threshold" => threshold, + "action" => action + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneFraudPolicy, + request_options: request_options + ) + end + + # Delete a fraud policy + # + # Delete a fraud policy. The flow it scored falls back to the fraud level and the rules in the fraud + # settings. Deletion is irreversible. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +DELETE /v3/phone/fraud/policies/{policy_id}/+ + # + # @param policy_id [String] The policy + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [nil] + def delete(policy_id, idempotency_key: OMIT, request_options: nil) + @client.request( + :delete, + "/v3/phone/fraud/policies/{policy_id}/", + path_params: { "policy_id" => policy_id }, + headers: { "Idempotency-Key" => idempotency_key }, + request_options: request_options + ) + end + + # List fraud policies + # + # List the application's weighted fraud policies, one per flow, each with its conditions, weights, threshold + # and action. Filter by `flow`. They are listed oldest first. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +GET /v3/phone/fraud/policies/+ + # + # @param flow [String] One flow + # @param limit [Integer] 20 by default, 100 at most + # @param offset [Integer] Where the page starts + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Page] + def list(flow: OMIT, limit: OMIT, offset: OMIT, request_options: nil) + @client.request( + :get, + "/v3/phone/fraud/policies/", + query: { + "flow" => flow, + "limit" => limit, + "offset" => offset + }, + page: Types::PhoneFraudPolicy, + request_options: request_options + ) + end + + # Retrieve a fraud policy + # + # Read one weighted fraud policy of your application: its flow, conditions, weights, threshold and action. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +GET /v3/phone/fraud/policies/{policy_id}/+ + # + # @param policy_id [String] The policy + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneFraudPolicy] + def retrieve(policy_id, request_options: nil) + @client.request( + :get, + "/v3/phone/fraud/policies/{policy_id}/", + path_params: { "policy_id" => policy_id }, + response: Types::PhoneFraudPolicy, + request_options: request_options + ) + end + + # Update a fraud policy + # + # Change a fraud policy: its conditions, their weights, its threshold or its action. A field you leave out + # stays as it is. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +PATCH /v3/phone/fraud/policies/{policy_id}/+ + # + # @param policy_id [String] The policy + # @param name [String] Its name + # @param flow [String] The flow it scores: `signup`, `login`, `payment` or a flow of your own, as sent in + # `action` on evaluate and send. + # @param conditions [Array] + # @param threshold [Integer] The score at which action applies + # @param action [String] allow, review, challenge or block + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneFraudPolicy] + def update( + policy_id, + name: OMIT, + flow: OMIT, + conditions: OMIT, + threshold: OMIT, + action: OMIT, + idempotency_key: OMIT, + request_options: nil + ) + @client.request( + :patch, + "/v3/phone/fraud/policies/{policy_id}/", + path_params: { "policy_id" => policy_id }, + body: { + "name" => name, + "flow" => flow, + "conditions" => conditions, + "threshold" => threshold, + "action" => action + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneFraudPolicy, + request_options: request_options + ) + end + end + end + + # The +phone.line_type_overrides+ resource. + class LineTypeOverrides < Didit::Resource + # Correct the line type of a number + # + # Correct the line type of a number for your future lookups: later lookups of that number report the corrected + # type (`mobile`, `landline`, `fixed_voip`, `non_fixed_voip`, `toll_free`, `premium` or `pager`) instead of + # the one the network gives, A second correction for the same number replaces the first and answers `201` too. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/line-type-overrides/+ + # + # @param phone_number [String] The number + # @param line_type [String] mobile, landline, fixed_voip, non_fixed_voip, toll_free, premium or pager + # @param note [String] Why it is corrected + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneLineTypeOverridesCreateResponse] + def create(phone_number:, line_type:, note: OMIT, idempotency_key: OMIT, request_options: nil) + @client.request( + :post, + "/v3/phone/line-type-overrides/", + body: { + "phone_number" => phone_number, + "line_type" => line_type, + "note" => note + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneLineTypeOverridesCreateResponse, + request_options: request_options + ) + end + + # Delete a line-type correction + # + # Delete a line-type correction so lookups report the type the network gives again. Deletion is irreversible. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +DELETE /v3/phone/line-type-overrides/{override_id}/+ + # + # @param override_id [String] The override + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [nil] + def delete(override_id, idempotency_key: OMIT, request_options: nil) + @client.request( + :delete, + "/v3/phone/line-type-overrides/{override_id}/", + path_params: { "override_id" => override_id }, + headers: { "Idempotency-Key" => idempotency_key }, + request_options: request_options + ) + end + end + + # The +phone.lists+ resource. + class Lists < Didit::Resource + # Add an entry to an allow or block list + # + # Add an entry to one of the application's phone lists. `list_id` is `allow` or `block`, and `value` is a + # number, a prefix, a country code or a network, which `type` names (`number`, `prefix`, `country` or + # `network`). + # + # An `expires_at` makes a temporary entry that ends on its own; `note` records why it was listed. `POST + # /v3/phone/lists/check/` answers with the entries that match a number, and the fraud rules read both lists. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/lists/{list_id}/entries/+ + # + # @param list_id [String] The list: `allow` or `block`. Any other value answers `404`. + # @param value [String] A number in E.164, a prefix, an ISO country code or a mobile network, as `type` says. + # @param type [String] number, prefix, country or network + # @param expires_at [Time, String] A temporary entry ends on its own + # @param note [String] Why it is listed + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneListEntry] + def add(list_id, value:, type: OMIT, expires_at: OMIT, note: OMIT, idempotency_key: OMIT, request_options: nil) + @client.request( + :post, + "/v3/phone/lists/{list_id}/entries/", + path_params: { "list_id" => list_id }, + body: { + "value" => value, + "type" => type, + "expires_at" => expires_at, + "note" => note + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneListEntry, + request_options: request_options + ) + end + + # Check a number against your allow and block lists + # + # Answer whether a number is on the allow or the block list, and which entries match it: a number, a prefix, + # the country or the number's network. A match on the block list answers `blocked`. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/lists/check/+ + # + # @param phone_number [String] The number to check + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneListsCheckResponse] + def check(phone_number:, idempotency_key: OMIT, request_options: nil) + @client.request( + :post, + "/v3/phone/lists/check/", + body: { + "phone_number" => phone_number + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneListsCheckResponse, + request_options: request_options + ) + end + + # List the entries of an allow or block list + # + # Read one of the application's lists: its entries, their type and the source that added each one (`manual`, + # `api` or `alert`). Filter by `type` or by part of a `value` or a `note`; `format=csv` exports every row of + # the filtered list instead of a page. Only the application's own phone and country lists are covered: + # `number`, `prefix` and `network` entries are in the phone list and `country` entries in the country list. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +GET /v3/phone/lists/{list_id}/entries/+ + # + # @param list_id [String] The list: `allow` or `block`. Any other value answers `404`. + # @param type [String] number, prefix, country or network + # @param search [String] Part of a value or a note + # @param limit [Integer] 20 by default, 100 at most + # @param offset [Integer] Where the page starts + # @param format [String] json, or csv to export every row of the filtered list + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Page] + def list_entries( + list_id, + type: OMIT, + search: OMIT, + limit: OMIT, + offset: OMIT, + format: OMIT, + request_options: nil + ) + @client.request( + :get, + "/v3/phone/lists/{list_id}/entries/", + path_params: { "list_id" => list_id }, + query: { + "type" => type, + "search" => search, + "limit" => limit, + "offset" => offset, + "format" => format + }, + page: Types::PhoneListEntry, + request_options: request_options + ) + end + + # Delete an entry from an allow or block list + # + # Delete an entry from an allow or block list, for example to unblock a network. Deletion is irreversible: the + # number, prefix, country or network is no longer listed from the next request. Only the application's own + # phone and country lists are covered: `number`, `prefix` and `network` entries are in the phone list and + # `country` entries in the country list. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +DELETE /v3/phone/lists/{list_id}/entries/{entry_id}/+ + # + # @param list_id [String] The list: `allow` or `block`. Any other value answers `404`. + # @param entry_id [String] The entry + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [nil] + def remove(list_id, entry_id, idempotency_key: OMIT, request_options: nil) + @client.request( + :delete, + "/v3/phone/lists/{list_id}/entries/{entry_id}/", + path_params: { "list_id" => list_id, "entry_id" => entry_id }, + headers: { "Idempotency-Key" => idempotency_key }, + request_options: request_options + ) + end + end + + # The +phone.rate_limits+ resource. + class RateLimits < Didit::Resource + # @return [Didit::Resources::Phone::RateLimits::Buckets] + def buckets + @buckets ||= Buckets.new(@client) + end + + # Create a velocity limit + # + # Create a velocity limit of your own. A limit is keyed by the name of the value your sends are counted by, + # for example `user_id`, and each of its `buckets` allows `max` starts in `interval` seconds, at most 30 days + # (2,592,000 seconds). Send history is kept for that longest window, so every bucket counts the starts of its + # whole interval. + # + # A request over a bucket answers `429` with `Retry-After`, and the key is refused until the interval ends. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +POST /v3/phone/rate-limits/+ + # + # @param key [String] The name of the value the limit counts, for example `user_id`. + # @param buckets [Array] + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneRateLimit] + def create(key:, buckets:, idempotency_key: OMIT, request_options: nil) + @client.request( + :post, + "/v3/phone/rate-limits/", + body: { + "key" => key, + "buckets" => buckets + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneRateLimit, + request_options: request_options + ) + end + + # Delete a velocity limit + # + # Delete a velocity limit and every bucket in it. The key it was created for no longer limits sends. Deletion + # is irreversible. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +DELETE /v3/phone/rate-limits/{rate_limit_id}/+ + # + # @param rate_limit_id [String] The limit + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [nil] + def delete(rate_limit_id, idempotency_key: OMIT, request_options: nil) + @client.request( + :delete, + "/v3/phone/rate-limits/{rate_limit_id}/", + path_params: { "rate_limit_id" => rate_limit_id }, + headers: { "Idempotency-Key" => idempotency_key }, + request_options: request_options + ) + end + + # List velocity limits + # + # List the application's velocity limits, oldest first, each with its key and its buckets. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +GET /v3/phone/rate-limits/+ + # + # @param limit [Integer] 20 by default, 100 at most + # @param offset [Integer] Where the page starts + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Page] + def list(limit: OMIT, offset: OMIT, request_options: nil) + @client.request( + :get, + "/v3/phone/rate-limits/", + query: { + "limit" => limit, + "offset" => offset + }, + page: Types::PhoneRateLimit, + request_options: request_options + ) + end + + # Retrieve a velocity limit + # + # One velocity limit with its buckets, each bucket's `max`, `interval` and the starts already counted in the + # current interval as `in_use`. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +GET /v3/phone/rate-limits/{rate_limit_id}/+ + # + # @param rate_limit_id [String] The limit + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneRateLimit] + def retrieve(rate_limit_id, request_options: nil) + @client.request( + :get, + "/v3/phone/rate-limits/{rate_limit_id}/", + path_params: { "rate_limit_id" => rate_limit_id }, + response: Types::PhoneRateLimit, + request_options: request_options + ) + end + + # Update a velocity limit + # + # Change a velocity limit's buckets: send a `bucket_id` to change that bucket, or leave it out to add one. + # `max` and `interval` must be positive, and `interval` at most 30 days (2,592,000 seconds), or the answer is + # `400`. A `bucket_id` that is not a bucket of this limit answers `404` and nothing is changed; a bucket can + # be removed with Delete a bucket of a velocity limit. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +PATCH /v3/phone/rate-limits/{rate_limit_id}/+ + # + # @param rate_limit_id [String] The limit + # @param buckets [Array] + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [Didit::Types::PhoneRateLimit] + def update(rate_limit_id, buckets:, idempotency_key: OMIT, request_options: nil) + @client.request( + :patch, + "/v3/phone/rate-limits/{rate_limit_id}/", + path_params: { "rate_limit_id" => rate_limit_id }, + body: { + "buckets" => buckets + }, + headers: { "Idempotency-Key" => idempotency_key }, + response: Types::PhoneRateLimit, + request_options: request_options + ) + end + + # The +phone.rate_limits.buckets+ resource. + class Buckets < Didit::Resource + # Delete a bucket of a velocity limit + # + # Delete one bucket of a velocity limit. A limit keeps at least one bucket, so the last one answers `409 + # last_bucket`: delete the limit instead. Deletion is irreversible. + # + # **Authentication.** Send your application's API key in `x-api-key`. + # + # +DELETE /v3/phone/rate-limits/{rate_limit_id}/buckets/{bucket_id}/+ + # + # @param rate_limit_id [String] The limit + # @param bucket_id [String] The bucket + # @param idempotency_key [String] sent as the Idempotency-Key header + # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body + # @return [nil] + def delete(rate_limit_id, bucket_id, idempotency_key: OMIT, request_options: nil) + @client.request( + :delete, + "/v3/phone/rate-limits/{rate_limit_id}/buckets/{bucket_id}/", + path_params: { "rate_limit_id" => rate_limit_id, "bucket_id" => bucket_id }, + headers: { "Idempotency-Key" => idempotency_key }, + request_options: request_options + ) + end + end + end end end end diff --git a/lib/didit/types.rb b/lib/didit/types.rb index b811607..a696f91 100644 --- a/lib/didit/types.rb +++ b/lib/didit/types.rb @@ -960,6 +960,9 @@ module Types autoload :MessageStatus, "didit/types/components" autoload :MessagesListParamsChannel, "didit/types/messages" autoload :MessagesListParamsStatus, "didit/types/messages" + autoload :MessagesRulesCreateParamsAction, "didit/types/messages" + autoload :MessagesRulesCreateParamsDirection, "didit/types/messages" + autoload :MessagesRulesCreateResponse, "didit/types/messages" autoload :MessagesSendParamsChannels, "didit/types/messages" autoload :MessagesSettings, "didit/types/components" autoload :MonitoringEvent, "didit/types/components" @@ -1098,6 +1101,7 @@ module Types autoload :PassiveLivenessCheckResponseLivenessWarningsFeature, "didit/types/passive_liveness" autoload :PassiveLivenessCheckResponseLivenessWarningsLogType, "didit/types/passive_liveness" autoload :PassiveLivenessCheckResponseLivenessWarningsRisk, "didit/types/passive_liveness" + autoload :PhoneAssessRiskBulkParamsFields, "didit/types/phone" autoload :PhoneCheckCodeParamsDisposableNumberAction, "didit/types/phone" autoload :PhoneCheckCodeParamsDuplicatedPhoneNumberAction, "didit/types/phone" autoload :PhoneCheckCodeParamsLowPhoneTrustAction, "didit/types/phone" @@ -1106,10 +1110,66 @@ module Types autoload :PhoneCheckCodeParamsPhoneTypeRiskAction, "didit/types/phone" autoload :PhoneCheckCodeParamsRecentPortAction, "didit/types/phone" autoload :PhoneCheckCodeParamsVoipNumberAction, "didit/types/phone" + autoload :PhoneFraudEvaluateResponse, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseChallengeChannels, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseDecision, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseEmail, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseEmailReasons, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseEmailRisk, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseException, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseMatchedRules, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseMatchedRulesAction, "didit/types/phone" + autoload :PhoneFraudEvaluateResponseMatchedRulesKey, "didit/types/phone" + autoload :PhoneFraudEvaluateResponsePolicy, "didit/types/phone" + autoload :PhoneFraudEventResult, "didit/types/components" + autoload :PhoneFraudEventResultError, "didit/types/components" + autoload :PhoneFraudEventResultStatus, "didit/types/components" + autoload :PhoneFraudEventsCreateBatchResponse, "didit/types/phone" + autoload :PhoneFraudPoliciesListResponse, "didit/types/phone" + autoload :PhoneFraudPolicy, "didit/types/components" + autoload :PhoneFraudPolicyAction, "didit/types/components" + autoload :PhoneFraudPolicyCondition, "didit/types/components" + autoload :PhoneFraudPolicyConditionOperator, "didit/types/components" + autoload :PhoneFraudPolicyConditionSignal, "didit/types/components" + autoload :PhoneFraudPolicyInputAction, "didit/types/components" + autoload :PhoneFraudRule, "didit/types/components" + autoload :PhoneFraudRuleAction, "didit/types/components" + autoload :PhoneFraudRuleKey, "didit/types/components" + autoload :PhoneFraudRulePlatforms, "didit/types/components" + autoload :PhoneFraudRuleScope, "didit/types/components" + autoload :PhoneFraudUpdateParamsChallengeChannels, "didit/types/phone" + autoload :PhoneFraudUpdateParamsLevel, "didit/types/phone" + autoload :PhoneFraudUpdateParamsRulesAction, "didit/types/phone" + autoload :PhoneFraudUpdateParamsRulesKey, "didit/types/phone" + autoload :PhoneFraudUpdateParamsRulesPlatforms, "didit/types/phone" + autoload :PhoneFraudUpdateParamsRulesScope, "didit/types/phone" + autoload :PhoneFraudUpdateResponse, "didit/types/phone" + autoload :PhoneFraudUpdateResponseChallengeChannels, "didit/types/phone" + autoload :PhoneFraudUpdateResponseLevel, "didit/types/phone" autoload :PhoneIntelligence, "didit/types/components" autoload :PhoneIntelligenceReasonCodes, "didit/types/components" autoload :PhoneIntelligenceReasonCodesDirection, "didit/types/components" + autoload :PhoneLineTypeOverridesCreateParamsLineType, "didit/types/phone" + autoload :PhoneLineTypeOverridesCreateResponse, "didit/types/phone" + autoload :PhoneLineTypeOverridesCreateResponseLineType, "didit/types/phone" + autoload :PhoneListEntry, "didit/types/components" + autoload :PhoneListEntryListId, "didit/types/components" + autoload :PhoneListEntrySource, "didit/types/components" + autoload :PhoneListEntryType, "didit/types/components" + autoload :PhoneListMatch, "didit/types/components" + autoload :PhoneListMatchListId, "didit/types/components" + autoload :PhoneListMatchType, "didit/types/components" + autoload :PhoneListsAddParamsType, "didit/types/phone" + autoload :PhoneListsCheckResponse, "didit/types/phone" + autoload :PhoneListsListEntriesParamsFormat, "didit/types/phone" + autoload :PhoneListsListEntriesParamsType, "didit/types/phone" + autoload :PhoneListsListEntriesResponse, "didit/types/phone" autoload :PhoneMatchItem, "didit/types/components" + autoload :PhoneRateLimit, "didit/types/components" + autoload :PhoneRateLimitBucket, "didit/types/components" + autoload :PhoneRateLimitsListResponse, "didit/types/phone" + autoload :PhoneRiskBulkJob, "didit/types/components" + autoload :PhoneRiskBulkJobStatus, "didit/types/components" autoload :PhoneRiskResponse, "didit/types/components" autoload :PhoneRiskResponsePhone, "didit/types/components" autoload :PhoneRiskResponsePhoneCarrier, "didit/types/components" diff --git a/lib/didit/types/components.rb b/lib/didit/types/components.rb index 91333b4..4c4509b 100644 --- a/lib/didit/types/components.rb +++ b/lib/didit/types/components.rb @@ -3431,6 +3431,107 @@ module OngoingMonitoringToggleResultStatus VALUES = [PENDING, PROCESSING, COMPLETED, FAILED].freeze end + # Why it was rejected: `invalid_event`; `null` for an accepted event + module PhoneFraudEventResultError + INVALID_EVENT = "invalid_event" + + VALUES = [INVALID_EVENT].freeze + end + + # accepted or rejected + module PhoneFraudEventResultStatus + ACCEPTED = "accepted" + REJECTED = "rejected" + + VALUES = [ACCEPTED, REJECTED].freeze + end + + # allow, review, challenge or block + module PhoneFraudPolicyAction + ALLOW = "allow" + REVIEW = "review" + CHALLENGE = "challenge" + BLOCK = "block" + + VALUES = [ALLOW, REVIEW, CHALLENGE, BLOCK].freeze + end + + # eq, neq, gt, lt, in or within_hours + module PhoneFraudPolicyConditionOperator + EQ = "eq" + NEQ = "neq" + GT = "gt" + LT = "lt" + IN = "in" + WITHIN_HOURS = "within_hours" + + VALUES = [EQ, NEQ, GT, LT, IN, WITHIN_HOURS].freeze + end + + # risk_score, sim_swap, line_type, country, velocity, ip_risk, device, email_risk or existing_user + module PhoneFraudPolicyConditionSignal + RISK_SCORE = "risk_score" + SIM_SWAP = "sim_swap" + LINE_TYPE = "line_type" + COUNTRY = "country" + VELOCITY = "velocity" + IP_RISK = "ip_risk" + DEVICE = "device" + EMAIL_RISK = "email_risk" + EXISTING_USER = "existing_user" + + VALUES = [RISK_SCORE, SIM_SWAP, LINE_TYPE, COUNTRY, VELOCITY, IP_RISK, DEVICE, EMAIL_RISK, EXISTING_USER].freeze + end + + # allow, review, challenge or block + module PhoneFraudPolicyInputAction + ALLOW = "allow" + REVIEW = "review" + CHALLENGE = "challenge" + BLOCK = "block" + + VALUES = [ALLOW, REVIEW, CHALLENGE, BLOCK].freeze + end + + # allow, review, require_code, challenge or block: challenge continues the verification on challenge_channels only + module PhoneFraudRuleAction + ALLOW = "allow" + REVIEW = "review" + REQUIRE_CODE = "require_code" + CHALLENGE = "challenge" + BLOCK = "block" + + VALUES = [ALLOW, REVIEW, REQUIRE_CODE, CHALLENGE, BLOCK].freeze + end + + # velocity, pumping, risk_score, sim_swap, device or country + module PhoneFraudRuleKey + VELOCITY = "velocity" + PUMPING = "pumping" + RISK_SCORE = "risk_score" + SIM_SWAP = "sim_swap" + DEVICE = "device" + COUNTRY = "country" + + VALUES = [VELOCITY, PUMPING, RISK_SCORE, SIM_SWAP, DEVICE, COUNTRY].freeze + end + + # Known values of an open enum: the API may send others. + module PhoneFraudRulePlatforms + WEB = "web" + IOS = "ios" + ANDROID = "android" + + VALUES = [WEB, IOS, ANDROID].freeze + end + + # codes (the only value): the rule applies to verification codes + module PhoneFraudRuleScope + CODES = "codes" + + VALUES = [CODES].freeze + end + # Whether the signal raised the risk or added trust. module PhoneIntelligenceReasonCodesDirection RISK = "risk" @@ -3439,6 +3540,62 @@ module PhoneIntelligenceReasonCodesDirection VALUES = [RISK, TRUST].freeze end + # The list it is on + module PhoneListEntryListId + ALLOW = "allow" + BLOCK = "block" + + VALUES = [ALLOW, BLOCK].freeze + end + + # Who added it: `manual` in the console, `api` through this API or `alert` + module PhoneListEntrySource + MANUAL = "manual" + API = "api" + ALERT = "alert" + + VALUES = [MANUAL, API, ALERT].freeze + end + + # Its type + module PhoneListEntryType + NUMBER = "number" + PREFIX = "prefix" + COUNTRY = "country" + NETWORK = "network" + + VALUES = [NUMBER, PREFIX, COUNTRY, NETWORK].freeze + end + + # allow or block + module PhoneListMatchListId + ALLOW = "allow" + BLOCK = "block" + + VALUES = [ALLOW, BLOCK].freeze + end + + # number, prefix, country or network + module PhoneListMatchType + NUMBER = "number" + PREFIX = "prefix" + COUNTRY = "country" + NETWORK = "network" + + VALUES = [NUMBER, PREFIX, COUNTRY, NETWORK].freeze + end + + # `queued`, `running`, `done`, or `failed`. A job fails when your organization balance cannot pay for the next + # paid lookup (the rows already answered stay downloadable) or after 3 failed retries. + module PhoneRiskBulkJobStatus + QUEUED = "queued" + RUNNING = "running" + DONE = "done" + FAILED = "failed" + + VALUES = [QUEUED, RUNNING, DONE, FAILED].freeze + end + # Decision for this phone number. Mirrors the top-level `status`. module PhoneRiskResponsePhoneStatus APPROVED = "Approved" @@ -11612,6 +11769,39 @@ class OngoingMonitoringToggleResultOutcomes < Didit::Model field :failed_insufficient_balance, "failed_insufficient_balance", :integer end + class PhoneFraudEventResult < Didit::Model + field :index, "index", :integer + field :event_id, "event_id", :string + field :status, "status", :string + field :error, "error", :string + end + + class PhoneFraudPolicy < Didit::Model + field :policy_id, "policy_id", :string + field :name, "name", :string + field :flow, "flow", :string + field :threshold, "threshold", :integer + field :action, "action", :string + field :updated_at, "updated_at", :datetime + field :conditions, "conditions", [:array, "PhoneFraudPolicyCondition"] + end + + class PhoneFraudPolicyCondition < Didit::Model + field :signal, "signal", :string + field :operator, "operator", :string + field :value, "value", :string + field :weight, "weight", :integer + end + + # One fraud rule: the signal it reads, the action it takes and where it applies. + class PhoneFraudRule < Didit::Model + field :key, "key", :string + field :action, "action", :string + field :countries, "countries", [:array, :string] + field :platforms, "platforms", [:array, :string] + field :scope, "scope", :string + end + # Normalized phone-intelligence block. Present only when the intelligence add-on ran for this lookup; when present # it is also exposed under the `enrichment` alias with identical values. class PhoneIntelligence < Didit::Model @@ -11634,6 +11824,21 @@ class PhoneIntelligenceReasonCodes < Didit::Model field :impact_level, "impact_level", :string end + class PhoneListEntry < Didit::Model + field :entry_id, "entry_id", :string + field :list_id, "list_id", :string + field :value, "value", :string + field :type, "type", :string + field :expires_at, "expires_at", :datetime + field :source, "source", :string + end + + class PhoneListMatch < Didit::Model + field :list_id, "list_id", :string + field :entry_id, "entry_id", :string + field :type, "type", :string + end + # Another session of your application that used the same phone number with a different `vendor_data`. class PhoneMatchItem < Didit::Model field :session_id, "session_id", :string @@ -11647,6 +11852,28 @@ class PhoneMatchItem < Didit::Model field :source, "source", :string end + class PhoneRateLimit < Didit::Model + field :rate_limit_id, "rate_limit_id", :string + field :key, "key", :string + field :buckets, "buckets", [:array, "PhoneRateLimitBucket"] + end + + class PhoneRateLimitBucket < Didit::Model + field :bucket_id, "bucket_id", :string + field :max, "max", :integer + field :interval, "interval", :integer + field :in_use, "in_use", :integer + end + + # A bulk risk job. + class PhoneRiskBulkJob < Didit::Model + field :job_id, "job_id", :string + field :status, "status", :string + field :total, "total", :integer + field :processed, "processed", :integer + field :results_url, "results_url", :string + end + class PhoneRiskResponse < Didit::Model field :request_id, "request_id", :string field :status, "status", :string diff --git a/lib/didit/types/messages.rb b/lib/didit/types/messages.rb index d5730a7..deab0b8 100644 --- a/lib/didit/types/messages.rb +++ b/lib/didit/types/messages.rb @@ -26,6 +26,22 @@ module MessagesListParamsStatus VALUES = [SCHEDULED, QUEUED, SENDING, SENT, DELIVERED, READ, FAILED, CANCELLED].freeze end + # allow or block + module MessagesRulesCreateParamsAction + ALLOW = "allow" + BLOCK = "block" + + VALUES = [ALLOW, BLOCK].freeze + end + + # outbound (default) or inbound + module MessagesRulesCreateParamsDirection + OUTBOUND = "outbound" + INBOUND = "inbound" + + VALUES = [OUTBOUND, INBOUND].freeze + end + # Known values of an open enum: the API may send others. module MessagesSendParamsChannels SMS = "sms" @@ -34,5 +50,9 @@ module MessagesSendParamsChannels VALUES = [SMS, WHATSAPP, EMAIL].freeze end + + class MessagesRulesCreateResponse < Didit::Model + field :rule_id, "rule_id", :string + end end end diff --git a/lib/didit/types/phone.rb b/lib/didit/types/phone.rb index b86c02b..dffc22f 100644 --- a/lib/didit/types/phone.rb +++ b/lib/didit/types/phone.rb @@ -3,6 +3,21 @@ module Didit module Types + # Known values of an open enum: the API may send others. + module PhoneAssessRiskBulkParamsFields + FORMAT = "format" + LINE_TYPE = "line_type" + NETWORK = "network" + REACHABILITY = "reachability" + SIM_SWAP = "sim_swap" + SMS_PUMPING_RISK = "sms_pumping_risk" + PREFILL = "prefill" + SCAM_SIGNAL = "scam_signal" + IDENTITY_MATCH = "identity_match" + + VALUES = [FORMAT, LINE_TYPE, NETWORK, REACHABILITY, SIM_SWAP, SMS_PUMPING_RISK, PREFILL, SCAM_SIGNAL, IDENTITY_MATCH].freeze + end + # What to do when the carrier lookup flags the number as a temporary/burner line (`phone.is_disposable`). # `DECLINE` flips the final `status` to `Declined`; `NO_ACTION` records the risk in `phone.warnings`. module PhoneCheckCodeParamsDisposableNumberAction @@ -79,6 +94,220 @@ module PhoneCheckCodeParamsVoipNumberAction VALUES = [NO_ACTION, DECLINE].freeze end + # Known values of an open enum: the API may send others. + module PhoneFraudEvaluateResponseChallengeChannels + SILENT = "silent" + WHATSAPP = "whatsapp" + TELEGRAM = "telegram" + RCS = "rcs" + VIBER = "viber" + ZALO = "zalo" + EMAIL = "email" + PUSH = "push" + TOTP = "totp" + PASSKEY = "passkey" + + VALUES = [SILENT, WHATSAPP, TELEGRAM, RCS, VIBER, ZALO, EMAIL, PUSH, TOTP, PASSKEY].freeze + end + + # allow, review, challenge or block + module PhoneFraudEvaluateResponseDecision + ALLOW = "allow" + REVIEW = "review" + CHALLENGE = "challenge" + BLOCK = "block" + + VALUES = [ALLOW, REVIEW, CHALLENGE, BLOCK].freeze + end + + # Known values of an open enum: the API may send others. + module PhoneFraudEvaluateResponseEmailReasons + DISPOSABLE_DOMAIN = "disposable_domain" + + VALUES = [DISPOSABLE_DOMAIN].freeze + end + + # `high` for a disposable mailbox, otherwise `low` + module PhoneFraudEvaluateResponseEmailRisk + LOW = "low" + HIGH = "high" + + VALUES = [LOW, HIGH].freeze + end + + # `trusted_user` when this request went past your fraud rules as a trusted user; `null` otherwise. + module PhoneFraudEvaluateResponseException + TRUSTED_USER = "trusted_user" + + VALUES = [TRUSTED_USER].freeze + end + + # What the rule asked for + module PhoneFraudEvaluateResponseMatchedRulesAction + ALLOW = "allow" + REVIEW = "review" + REQUIRE_CODE = "require_code" + CHALLENGE = "challenge" + BLOCK = "block" + + VALUES = [ALLOW, REVIEW, REQUIRE_CODE, CHALLENGE, BLOCK].freeze + end + + # The rule + module PhoneFraudEvaluateResponseMatchedRulesKey + VELOCITY = "velocity" + PUMPING = "pumping" + RISK_SCORE = "risk_score" + SIM_SWAP = "sim_swap" + DEVICE = "device" + COUNTRY = "country" + + VALUES = [VELOCITY, PUMPING, RISK_SCORE, SIM_SWAP, DEVICE, COUNTRY].freeze + end + + # Known values of an open enum: the API may send others. + module PhoneFraudUpdateParamsChallengeChannels + SILENT = "silent" + WHATSAPP = "whatsapp" + TELEGRAM = "telegram" + RCS = "rcs" + VIBER = "viber" + ZALO = "zalo" + EMAIL = "email" + PUSH = "push" + TOTP = "totp" + PASSKEY = "passkey" + + VALUES = [SILENT, WHATSAPP, TELEGRAM, RCS, VIBER, ZALO, EMAIL, PUSH, TOTP, PASSKEY].freeze + end + + # standard, strict or custom + module PhoneFraudUpdateParamsLevel + STANDARD = "standard" + STRICT = "strict" + CUSTOM = "custom" + + VALUES = [STANDARD, STRICT, CUSTOM].freeze + end + + # allow, review, require_code, challenge or block: challenge continues the verification on challenge_channels only + module PhoneFraudUpdateParamsRulesAction + ALLOW = "allow" + REVIEW = "review" + REQUIRE_CODE = "require_code" + CHALLENGE = "challenge" + BLOCK = "block" + + VALUES = [ALLOW, REVIEW, REQUIRE_CODE, CHALLENGE, BLOCK].freeze + end + + # velocity, pumping, risk_score, sim_swap, device or country + module PhoneFraudUpdateParamsRulesKey + VELOCITY = "velocity" + PUMPING = "pumping" + RISK_SCORE = "risk_score" + SIM_SWAP = "sim_swap" + DEVICE = "device" + COUNTRY = "country" + + VALUES = [VELOCITY, PUMPING, RISK_SCORE, SIM_SWAP, DEVICE, COUNTRY].freeze + end + + # Known values of an open enum: the API may send others. + module PhoneFraudUpdateParamsRulesPlatforms + WEB = "web" + IOS = "ios" + ANDROID = "android" + + VALUES = [WEB, IOS, ANDROID].freeze + end + + # codes (the default and the only value): the rule applies to verification codes + module PhoneFraudUpdateParamsRulesScope + CODES = "codes" + + VALUES = [CODES].freeze + end + + # Known values of an open enum: the API may send others. + module PhoneFraudUpdateResponseChallengeChannels + SILENT = "silent" + WHATSAPP = "whatsapp" + TELEGRAM = "telegram" + RCS = "rcs" + VIBER = "viber" + ZALO = "zalo" + EMAIL = "email" + PUSH = "push" + TOTP = "totp" + PASSKEY = "passkey" + + VALUES = [SILENT, WHATSAPP, TELEGRAM, RCS, VIBER, ZALO, EMAIL, PUSH, TOTP, PASSKEY].freeze + end + + # The level now + module PhoneFraudUpdateResponseLevel + STANDARD = "standard" + STRICT = "strict" + CUSTOM = "custom" + + VALUES = [STANDARD, STRICT, CUSTOM].freeze + end + + # mobile, landline, fixed_voip, non_fixed_voip, toll_free, premium or pager + module PhoneLineTypeOverridesCreateParamsLineType + MOBILE = "mobile" + LANDLINE = "landline" + FIXED_VOIP = "fixed_voip" + NON_FIXED_VOIP = "non_fixed_voip" + TOLL_FREE = "toll_free" + PREMIUM = "premium" + PAGER = "pager" + + VALUES = [MOBILE, LANDLINE, FIXED_VOIP, NON_FIXED_VOIP, TOLL_FREE, PREMIUM, PAGER].freeze + end + + # What lookups return from now on + module PhoneLineTypeOverridesCreateResponseLineType + MOBILE = "mobile" + LANDLINE = "landline" + FIXED_VOIP = "fixed_voip" + NON_FIXED_VOIP = "non_fixed_voip" + TOLL_FREE = "toll_free" + PREMIUM = "premium" + PAGER = "pager" + + VALUES = [MOBILE, LANDLINE, FIXED_VOIP, NON_FIXED_VOIP, TOLL_FREE, PREMIUM, PAGER].freeze + end + + # number, prefix, country or network + module PhoneListsAddParamsType + NUMBER = "number" + PREFIX = "prefix" + COUNTRY = "country" + NETWORK = "network" + + VALUES = [NUMBER, PREFIX, COUNTRY, NETWORK].freeze + end + + # Known values of an open enum: the API may send others. + module PhoneListsListEntriesParamsFormat + JSON = "json" + CSV = "csv" + + VALUES = [JSON, CSV].freeze + end + + # Known values of an open enum: the API may send others. + module PhoneListsListEntriesParamsType + NUMBER = "number" + PREFIX = "prefix" + COUNTRY = "country" + NETWORK = "network" + + VALUES = [NUMBER, PREFIX, COUNTRY, NETWORK].freeze + end + # Preferred delivery channel. If the channel is unavailable for the destination country or number, the message # automatically falls back to SMS - the send still reports `Success`. module PhoneSendCodeParamsOptionsPreferredChannel @@ -103,5 +332,85 @@ module PhoneSendCodeParamsSignalsDevicePlatform VALUES = [ANDROID, IOS, IPADOS, TVOS, WEB].freeze end + + class PhoneFraudEvaluateResponse < Didit::Model + field :decision, "decision", :string + field :score, "score", :integer + field :matched_rules, "matched_rules", [:array, "PhoneFraudEvaluateResponseMatchedRules"] + field :policy, "policy", "PhoneFraudEvaluateResponsePolicy" + field :challenge_channels, "challenge_channels", [:array, :string] + field :email, "email", "PhoneFraudEvaluateResponseEmail" + field :existing_user, "existing_user", :boolean + field :exception, "exception", :string + end + + # The email check; `null` when no `email` was sent + class PhoneFraudEvaluateResponseEmail < Didit::Model + field :risk, "risk", :string + field :disposable, "disposable", :boolean + field :domain_age_days, "domain_age_days", :integer + field :reasons, "reasons", [:array, :string] + field :email, "email", :string + end + + class PhoneFraudEvaluateResponseMatchedRules < Didit::Model + field :key, "key", :string + field :action, "action", :string + end + + # The weighted policy of the flow in `action`; `null` when the flow has none + class PhoneFraudEvaluateResponsePolicy < Didit::Model + field :policy_id, "policy_id", :string + field :score, "score", :integer + field :conditions_met, "conditions_met", [:array, :string] + end + + class PhoneFraudEventsCreateBatchResponse < Didit::Model + field :accepted, "accepted", :integer + field :results, "results", [:array, "PhoneFraudEventResult"] + end + + class PhoneFraudPoliciesListResponse < Didit::Model + field :count, "count", :integer + field :next, "next", :string + field :previous, "previous", :string + field :results, "results", [:array, "PhoneFraudPolicy"] + end + + class PhoneFraudUpdateResponse < Didit::Model + field :level, "level", :string + field :rules, "rules", [:array, "PhoneFraudRule"] + field :updated_at, "updated_at", :datetime + field :challenge_channels, "challenge_channels", [:array, :string] + field :sim_swap_within, "sim_swap_within", :integer + field :daily_cap, "daily_cap", :string + end + + class PhoneLineTypeOverridesCreateResponse < Didit::Model + field :override_id, "override_id", :string + field :phone_number, "phone_number", :string + field :line_type, "line_type", :string + field :created_at, "created_at", :datetime + end + + class PhoneListsCheckResponse < Didit::Model + field :allowed, "allowed", :boolean + field :blocked, "blocked", :boolean + field :matches, "matches", [:array, "PhoneListMatch"] + end + + class PhoneListsListEntriesResponse < Didit::Model + field :count, "count", :integer + field :next, "next", :string + field :previous, "previous", :string + field :results, "results", [:array, "PhoneListEntry"] + end + + class PhoneRateLimitsListResponse < Didit::Model + field :count, "count", :integer + field :next, "next", :string + field :previous, "previous", :string + field :results, "results", [:array, "PhoneRateLimit"] + end end end diff --git a/openapi/SOURCE.json b/openapi/SOURCE.json index dd5b52b..74c8af7 100644 --- a/openapi/SOURCE.json +++ b/openapi/SOURCE.json @@ -1,8 +1,8 @@ { "verification.json": { "url": "https://docs.didit.me/openapi-25.json", - "sha256": "73a976a5c370ba2aaedf56a16da8837748b5163b1affeafed597a7a95d02bcfe", - "fetched_at": "2026-11-24T07:54:35Z" + "sha256": "378460a962de204591425c7dbeae0501dbfceed28c9745c01a79643135d2fb1f", + "fetched_at": "2026-11-24T10:09:11Z" }, "account.json": { "url": "https://docs.didit.me/openapi-auth.json", diff --git a/openapi/verification.json b/openapi/verification.json index 213f05b..67d4b62 100644 --- a/openapi/verification.json +++ b/openapi/verification.json @@ -17471,6 +17471,3181 @@ ] } }, + "/v3/phone/risk/bulk/": { + "post": { + "summary": "Start a bulk lookup", + "description": "Look up a CSV of numbers as one job: one number per line, up to 100,000 numbers, with `fields` naming the signals to return for each number. The call answers `202` with the job (`status` `queued`, `processed` 0, `results_url` `null`). Read it with `GET /v3/phone/risk/bulk/{job_id}/`; when it is done, download the CSV from `results_url`. `callback_url`, a public HTTPS URL, receives `{job_id, status, total, results_url}` when the job finishes (described by `PhoneRiskBulkCallback`).\n\nBilling follows Phone Risk API pricing for each number in the file; a number that is not valid is not charged.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "create_phone_risk_bulk", + "x-didit-sdk": { + "resource": "phone", + "method": "assess_risk_bulk", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "A CSV of numbers, one number per line, up to 100,000.", + "format": "binary" + }, + "fields": { + "type": "array", + "description": "The signals to return, one CSV column each, in this order; all of them when you send none. `format`, `line_type` and `network` are answered. `reachability`, `sim_swap`, `sms_pumping_risk`, `prefill`, `scam_signal` and `identity_match` are accepted and their columns come back empty: a file that asks for those alone looks up nothing and is not charged for lookups.", + "items": { + "type": "string", + "enum": [ + "format", + "line_type", + "network", + "reachability", + "sim_swap", + "sms_pumping_risk", + "prefill", + "scam_signal", + "identity_match" + ] + } + }, + "callback_url": { + "type": "string", + "description": "A public HTTPS URL Didit posts to when the job is done: `{job_id, status, total, results_url}`, with `results_url` the same relative path as on the job. Any other URL answers `400`.", + "format": "uri" + } + }, + "required": [ + "file" + ] + }, + "encoding": { + "file": { + "contentType": "text/csv" + } + }, + "examples": { + "A CSV of numbers": { + "summary": "Upload the file and choose the signals", + "description": "A multipart upload: `file` is the CSV, `fields` selects the signals and `callback_url` is called when the job is done.", + "value": { + "file": "phone_number\n+34600000012\n+14155552671\n", + "fields": [ + "line_type", + "sim_swap" + ] + } + } + } + } + } + }, + "responses": { + "202": { + "description": "The bulk lookup job.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRiskBulkJob" + }, + "examples": { + "Queued": { + "value": { + "job_id": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55", + "status": "queued", + "total": 2400, + "processed": 0, + "results_url": null + } + } + } + } + } + }, + "400": { + "description": "`invalid_file` - Not a CSV of numbers: the file is not UTF-8 text, is empty or has more than 100,000 numbers. A `callback_url` that is not a public HTTPS address, or a missing `file`, answers a field error that names the field." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/risk/bulk/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -F 'file=@numbers.csv'" + } + ], + "callbacks": { + "bulkRiskFinished": { + "{$request.body#/callback_url}": { + "post": { + "summary": "The bulk job finished", + "description": "Didit posts the finished job to your `callback_url`: once, with no credential and no signature, a 10 second timeout, and no redirect followed. Treat it as a hint and read the job with `GET /v3/phone/risk/bulk/{job_id}/` and your API key before you rely on it.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRiskBulkCallback" + } + } + } + }, + "responses": { + "2XX": { + "description": "Any 2xx answer acknowledges the callback." + } + }, + "security": [ + {} + ] + } + } + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, + "/v3/phone/risk/bulk/{job_id}/": { + "get": { + "summary": "Get a bulk lookup job", + "description": "Read a bulk risk job of your application: its `status`, how many numbers it has `processed` of its `total`, and the `results_url` of the CSV once a result file exists. An unknown job, or one of another application, answers `404`.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "get_phone_risk_bulk", + "x-didit-sdk": { + "resource": "phone", + "method": "retrieve_risk_bulk", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "job_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + }, + "description": "The job, as returned when it was started.", + "example": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55" + } + ], + "responses": { + "200": { + "description": "The job.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRiskBulkJob" + }, + "examples": { + "Done": { + "value": { + "job_id": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55", + "status": "done", + "total": 2400, + "processed": 2400, + "results_url": "/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/results/" + } + } + } + } + } + }, + "404": { + "description": "No job with this id in your application, or one of another application (never `403`).", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRiskBulkError" + }, + "examples": { + "Unknown job": { + "value": { + "detail": "Not found.", + "code": "not_found" + } + } + } + } + } + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedRead" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "cURL", + "source": "curl 'https://verification.didit.me/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/phone/risk/bulk/{job_id}/results/": { + "get": { + "summary": "Download bulk lookup results", + "description": "Download the CSV of a bulk risk job: the column `phone_number` plus one column per requested signal, one row per number in the order of the uploaded file. A failed job still has the rows it answered. While no result file exists the answer is `409 results_not_ready`.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "download_phone_risk_bulk_results", + "x-didit-sdk": { + "resource": "phone", + "method": "download_risk_bulk_results", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "job_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + }, + "description": "The job, as returned when it was started.", + "example": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55" + } + ], + "responses": { + "200": { + "description": "The results as a CSV.", + "headers": { + "Content-Disposition": { + "description": "`attachment; filename=\"phone-risk-{job_id}.csv\"`.", + "schema": { + "type": "string" + }, + "example": "attachment; filename=\"phone-risk-8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55.csv\"" + } + }, + "content": { + "text/csv": { + "schema": { + "type": "string", + "format": "binary" + }, + "example": "phone_number,line_type,sim_swap\n+34600000012,mobile,\n+14155552671,mobile,\n" + } + } + }, + "404": { + "description": "No job with this id in your application, or one of another application (never `403`).", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRiskBulkError" + }, + "examples": { + "Unknown job": { + "value": { + "detail": "Not found.", + "code": "not_found" + } + } + } + } + } + }, + "409": { + "description": "No result file exists yet.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRiskBulkError" + }, + "examples": { + "Not ready": { + "value": { + "detail": "The results are not ready.", + "code": "results_not_ready" + } + } + } + } + } + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedRead" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "cURL", + "source": "curl 'https://verification.didit.me/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/results/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -o phone-risk-8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55.csv" + } + ] + } + }, + "/v3/phone/fraud/": { + "patch": { + "summary": "Update fraud settings", + "description": "Change the application's fraud protection: the level, the rules and where each rule applies. `level` is `standard` or `strict`, or `custom` when your own rules decide.\n\nA rule names a `key` - `velocity`, `pumping`, `risk_score`, `sim_swap`, `device` or `country` - and its `action`: `allow`, `review`, `require_code` or `block`, and `challenge`, which continues the verification only on the channels in `challenge_channels`. A rule applies only to the `countries` and `platforms` you name, and to verification codes: `scope` is `codes`, the only value, and any other value answers `400`.\n\n`sim_swap_within` is the window, in hours, after a SIM change in which a code is required instead of a silent check, or the number is blocked. `daily_cap` stops new codes at this spend per day, in USD.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "update_phone_fraud_settings", + "x-didit-sdk": { + "resource": "phone.fraud", + "method": "update", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "level": { + "type": "string", + "description": "standard, strict or custom", + "example": "custom", + "enum": [ + "standard", + "strict", + "custom" + ] + }, + "rules": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string", + "description": "velocity, pumping, risk_score, sim_swap, device or country", + "example": "sim_swap", + "enum": [ + "velocity", + "pumping", + "risk_score", + "sim_swap", + "device", + "country" + ] + }, + "action": { + "type": "string", + "description": "allow, review, require_code, challenge or block: challenge continues the verification on challenge_channels only", + "example": "require_code", + "enum": [ + "allow", + "review", + "require_code", + "challenge", + "block" + ] + }, + "countries": { + "type": "array", + "description": "The rule applies only to these countries", + "example": [ + "GB", + "ES" + ], + "items": { + "type": "string", + "minLength": 2, + "maxLength": 2, + "description": "An ISO 3166-1 alpha-2 country code" + } + }, + "platforms": { + "type": "array", + "description": "The rule applies only to web, ios or android", + "items": { + "type": "string", + "enum": [ + "web", + "ios", + "android" + ] + } + }, + "scope": { + "type": "string", + "description": "codes (the default and the only value): the rule applies to verification codes", + "enum": [ + "codes" + ] + } + }, + "required": [ + "key", + "action" + ] + } + }, + "challenge_channels": { + "type": "array", + "description": "Where a challenged verification may continue; SMS and voice are withheld", + "example": [ + "silent", + "whatsapp", + "passkey" + ], + "items": { + "type": "string", + "enum": [ + "silent", + "whatsapp", + "telegram", + "rcs", + "viber", + "zalo", + "email", + "push", + "totp", + "passkey" + ] + } + }, + "sim_swap_within": { + "type": "integer", + "description": "Hours: after a SIM change in this window, ask for a code instead of silent, or block", + "example": 72, + "minimum": 0, + "maximum": 8760 + }, + "daily_cap": { + "type": "string", + "description": "New codes stop at this spend per day, in USD, as a decimal string with at most two decimals; `null` removes the cap", + "nullable": true, + "example": "50.00" + } + }, + "description": "Every field is optional: a field you leave out stays as it is." + }, + "examples": { + "Example": { + "value": { + "level": "custom", + "rules": [ + { + "key": "sim_swap", + "action": "require_code", + "countries": [ + "GB", + "ES" + ] + } + ], + "challenge_channels": [ + "silent", + "whatsapp", + "passkey" + ], + "sim_swap_within": 72 + } + } + } + } + } + }, + "responses": { + "200": { + "description": "The fraud settings as they now stand.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "level": { + "type": "string", + "description": "The level now", + "example": "custom", + "enum": [ + "standard", + "strict", + "custom" + ] + }, + "rules": { + "type": "array", + "description": "The rules now, in order", + "items": { + "$ref": "#/components/schemas/PhoneFraudRule" + } + }, + "updated_at": { + "type": "string", + "description": "When it changed", + "example": "2026-11-21T10:00:00Z", + "format": "date-time" + }, + "challenge_channels": { + "type": "array", + "description": "The fraud-resistant channels now used", + "example": [ + "silent", + "whatsapp", + "passkey" + ], + "items": { + "type": "string", + "enum": [ + "silent", + "whatsapp", + "telegram", + "rcs", + "viber", + "zalo", + "email", + "push", + "totp", + "passkey" + ] + } + }, + "sim_swap_within": { + "type": "integer", + "description": "The window in hours after a SIM change, now", + "example": 72, + "minimum": 0, + "maximum": 8760 + }, + "daily_cap": { + "type": "string", + "nullable": true, + "description": "The daily spend at which new codes stop, in USD, as a decimal string; `null` when there is no cap", + "example": "50.00" + } + }, + "required": [ + "level", + "rules", + "sim_swap_within", + "daily_cap", + "challenge_channels", + "updated_at" + ] + }, + "examples": { + "Example": { + "value": { + "level": "custom", + "rules": [ + { + "key": "sim_swap", + "action": "require_code", + "countries": [ + "GB", + "ES" + ] + } + ], + "challenge_channels": [ + "silent", + "whatsapp", + "passkey" + ], + "updated_at": "2026-11-21T10:00:00Z", + "sim_swap_within": 72, + "daily_cap": null + } + } + } + } + } + }, + "400": { + "description": "A field is not valid: the answer names the field (`level`, `rules`, `challenge_channels`, `sim_swap_within` or `daily_cap`) with the reason, for example a rule `key`, `action` or `scope` outside the values listed, or a `scope` other than `codes`." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X PATCH 'https://verification.didit.me/v3/phone/fraud/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"level\": \"custom\", \"rules\": [{\"key\": \"sim_swap\", \"action\": \"require_code\", \"countries\": [\"GB\", \"ES\"]}], \"challenge_channels\": [\"silent\", \"whatsapp\", \"passkey\"], \"sim_swap_within\": 72}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, + "/v3/phone/fraud/evaluate/": { + "post": { + "summary": "Score a number, an email address or both against your fraud rules", + "description": "Score a request before a code is sent: the number, the email address or both are evaluated against your fraud rules and the weighted policy of the flow in `action` (`signup`, `login`, `payment` or a flow of your own). Send `phone_number`, `email`, or both; a request with neither answers `400 target_required`.\n\nThe answer carries the `decision` (`allow`, `review`, `challenge` or `block`), a `score` from 0 to 100, the rules that decided, the flow policy's score and the conditions that met it, and an email block when an address was scored. `challenge_channels` lists where a challenged verification may continue: SMS and voice are withheld.\n\nSend `ip_address` and `device_signals` when you have them; the `existing_user` flag tells the scoring a returning user is asking. `trusted_user` with a `fraud_override` signed for this one request takes it past your fraud rules, and a block list still stops the number.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "evaluate_phone_fraud", + "x-didit-sdk": { + "resource": "phone.fraud", + "method": "evaluate", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "phone_number": { + "type": "string", + "description": "The number; or leave it out and send email alone", + "example": "+34600000012", + "pattern": "^\\+[1-9]\\d{6,14}$", + "maxLength": 20 + }, + "email": { + "type": "string", + "description": "An email address to score before a code is sent, alone or with the number", + "format": "email" + }, + "action": { + "type": "string", + "description": "The flow being scored: `signup` (the default), `login`, `payment` or a flow of your own, at most 64 characters.", + "example": "signup", + "maxLength": 64, + "default": "signup" + }, + "ip_address": { + "type": "string", + "description": "Your user's IP address" + }, + "device_signals": { + "type": "string", + "description": "The signed token from the SDK" + }, + "existing_user": { + "type": "boolean", + "description": "true: the number belongs to a user who has signed in before; the fraud scoring weighs returning users and new sign-ups differently", + "example": false + }, + "trusted_user": { + "type": "boolean", + "description": "Evaluate as a trusted-user exception: with a fraud_override signed for this number, the decision is allow unless a block list matches", + "example": false + }, + "fraud_override": { + "type": "string", + "description": "The signed token for this number, as on send" + } + }, + "description": "Send `phone_number`, `email`, or both.", + "anyOf": [ + { + "required": [ + "phone_number" + ] + }, + { + "required": [ + "email" + ] + } + ] + }, + "examples": { + "Example": { + "value": { + "phone_number": "+34600000012", + "action": "signup", + "existing_user": false, + "trusted_user": false + } + } + } + } + } + }, + "responses": { + "200": { + "description": "The decision, the score and the rules and policy that produced it.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "decision": { + "type": "string", + "description": "allow, review, challenge or block", + "example": "allow", + "enum": [ + "allow", + "review", + "challenge", + "block" + ] + }, + "score": { + "type": "integer", + "description": "Risk from 0 to 100", + "example": 12, + "minimum": 0, + "maximum": 100 + }, + "matched_rules": { + "type": "array", + "description": "The rules that decided", + "example": [], + "items": { + "type": "object", + "properties": { + "key": { + "type": "string", + "enum": [ + "velocity", + "pumping", + "risk_score", + "sim_swap", + "device", + "country" + ], + "description": "The rule" + }, + "action": { + "type": "string", + "enum": [ + "allow", + "review", + "require_code", + "challenge", + "block" + ], + "description": "What the rule asked for" + } + }, + "required": [ + "key", + "action" + ] + } + }, + "policy": { + "type": "object", + "properties": { + "policy_id": { + "type": "string", + "description": "The flow policy that scored the request.", + "example": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "format": "uuid" + }, + "score": { + "type": "integer", + "description": "The weighted score, 0 to 100", + "example": 40, + "minimum": 0, + "maximum": 100 + }, + "conditions_met": { + "type": "array", + "description": "The conditions that added points", + "example": [ + "sim_swap" + ], + "items": { + "type": "string" + } + } + }, + "nullable": true, + "description": "The weighted policy of the flow in `action`; `null` when the flow has none", + "required": [ + "policy_id", + "score", + "conditions_met" + ] + }, + "challenge_channels": { + "type": "array", + "description": "When `decision` is `challenge`: the channels the verification may continue on, the `challenge_channels` of your fraud settings or `silent`, `whatsapp` and `passkey` when you set none. Empty for any other decision", + "example": [ + "silent", + "whatsapp" + ], + "items": { + "type": "string", + "enum": [ + "silent", + "whatsapp", + "telegram", + "rcs", + "viber", + "zalo", + "email", + "push", + "totp", + "passkey" + ] + } + }, + "email": { + "type": "object", + "properties": { + "risk": { + "type": "string", + "description": "`high` for a disposable mailbox, otherwise `low`", + "example": "low", + "enum": [ + "low", + "high" + ] + }, + "disposable": { + "type": "boolean", + "description": "The address is a disposable mailbox.", + "example": false + }, + "domain_age_days": { + "type": "integer", + "nullable": true, + "minimum": 0, + "description": "Always `null` for now" + }, + "reasons": { + "type": "array", + "description": "Why the address is risky: `disposable_domain`", + "example": [], + "items": { + "type": "string", + "enum": [ + "disposable_domain" + ] + } + }, + "email": { + "type": "string", + "format": "email", + "description": "The address that was checked", + "example": "ana@example.com" + } + }, + "nullable": true, + "description": "The email check; `null` when no `email` was sent", + "required": [ + "email", + "risk", + "disposable", + "domain_age_days", + "reasons" + ] + }, + "existing_user": { + "type": "boolean", + "description": "As sent, and counted in the score", + "example": false + }, + "exception": { + "type": "string", + "nullable": true, + "enum": [ + "trusted_user", + null + ], + "description": "`trusted_user` when this request went past your fraud rules as a trusted user; `null` otherwise." + } + }, + "required": [ + "decision", + "score", + "matched_rules", + "policy", + "email", + "existing_user", + "challenge_channels", + "exception" + ] + }, + "examples": { + "Example": { + "value": { + "decision": "allow", + "score": 12, + "matched_rules": [], + "policy": { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "score": 40, + "conditions_met": [ + "sim_swap" + ] + }, + "challenge_channels": [], + "email": null, + "existing_user": false, + "exception": null + } + } + } + } + } + }, + "400": { + "description": "`target_required` - Neither `phone_number` nor `email` was sent. A `phone_number` that is not a valid number, or a value that is not valid for another field, answers a field error that names the field." + }, + "403": { + "description": "`invalid_fraud_override` - `trusted_user` was sent without a `fraud_override` signed for this number and flow, or the token is expired or forged. Otherwise the `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`.", + "content": { + "application/json": { + "examples": { + "Unsigned override": { + "value": { + "detail": "trusted_user needs a fraud_override signed for this number and flow.", + "code": "invalid_fraud_override" + } + } + } + } + } + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/fraud/evaluate/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"phone_number\": \"+34600000012\", \"action\": \"signup\", \"existing_user\": false, \"trusted_user\": false}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, + "/v3/phone/fraud/policies/": { + "get": { + "summary": "List fraud policies", + "description": "List the application's weighted fraud policies, one per flow, each with its conditions, weights, threshold and action. Filter by `flow`. They are listed oldest first.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "list_phone_fraud_policies", + "x-didit-sdk": { + "resource": "phone.fraud.policies", + "method": "list", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "flow", + "in": "query", + "required": false, + "description": "One flow", + "schema": { + "type": "string", + "description": "One flow" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "20 by default, 100 at most", + "schema": { + "type": "integer", + "default": 20, + "minimum": 1, + "maximum": 100 + } + }, + { + "name": "offset", + "in": "query", + "required": false, + "description": "Where the page starts", + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + } + ], + "responses": { + "200": { + "description": "A page of fraud policies.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "count": { + "type": "integer", + "description": "The number of policies that match the filters", + "example": 1, + "minimum": 0 + }, + "next": { + "type": "string", + "description": "The next page, or null", + "format": "uri", + "nullable": true + }, + "previous": { + "type": "string", + "description": "The previous page, or null", + "format": "uri", + "nullable": true + }, + "results": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneFraudPolicy" + } + } + } + }, + "examples": { + "Example": { + "value": { + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + ] + } + } + } + } + } + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedRead" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X GET 'https://verification.didit.me/v3/phone/fraud/policies/?flow=payment&limit=20' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + }, + "post": { + "summary": "Create a fraud policy", + "description": "Create a weighted fraud policy for one flow. Each condition names a `signal` (`risk_score`, `sim_swap`, `line_type`, `country`, `velocity`, `ip_risk`, `device`, `email_risk` or `existing_user`), an `operator` (`eq`, `neq`, `gt`, `lt`, `in` or `within_hours`), the `value` to compare with and the `weight` its points add to the score (0 to 100). The weights of the conditions that hold add up to a score, and `threshold` is the score at which `action` applies (`allow`, `review`, `challenge` or `block`).\n\nA flow has one policy: a second one answers `409 flow_has_policy`, and the existing policy is changed instead.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "create_phone_fraud_policy", + "x-didit-sdk": { + "resource": "phone.fraud.policies", + "method": "create", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PhoneFraudPolicyInput" + } + ], + "required": [ + "name", + "flow" + ], + "description": "Create a policy: `name` and `flow` are required; `threshold` defaults to 60 and `action` to `review`." + }, + "examples": { + "Example": { + "value": { + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + } + ], + "threshold": 60, + "action": "challenge" + } + } + } + } + } + }, + "responses": { + "201": { + "description": "The new fraud policy.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneFraudPolicy" + }, + "examples": { + "Example": { + "value": { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + } + } + } + } + }, + "400": { + "description": "`invalid_policy` - `name` or `flow` is missing. A condition whose `signal`, `operator`, `value` or `weight` is not valid, or another invalid field, answers a field error that names the field." + }, + "409": { + "description": "`flow_has_policy` - This flow already has a policy: change it instead." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/fraud/policies/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"name\": \"Payment check\", \"flow\": \"payment\", \"conditions\": [{\"signal\": \"sim_swap\", \"operator\": \"within_hours\", \"value\": \"72\", \"weight\": 40}], \"threshold\": 60, \"action\": \"challenge\"}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, + "/v3/phone/fraud/policies/{policy_id}/": { + "get": { + "summary": "Retrieve a fraud policy", + "description": "Read one weighted fraud policy of your application: its flow, conditions, weights, threshold and action.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "retrieve_phone_fraud_policy", + "x-didit-sdk": { + "resource": "phone.fraud.policies", + "method": "retrieve", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "policy_id", + "in": "path", + "required": true, + "description": "The policy", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44" + } + ], + "responses": { + "200": { + "description": "The fraud policy.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneFraudPolicy" + }, + "examples": { + "Example": { + "value": { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + }, + { + "signal": "email_risk", + "operator": "eq", + "value": "high", + "weight": 30 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + } + } + } + } + }, + "404": { + "description": "`not_found` - No policy with this id in your application." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedRead" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X GET 'https://verification.didit.me/v3/phone/fraud/policies/9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + }, + "patch": { + "summary": "Update a fraud policy", + "description": "Change a fraud policy: its conditions, their weights, its threshold or its action. A field you leave out stays as it is.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "update_phone_fraud_policy", + "x-didit-sdk": { + "resource": "phone.fraud.policies", + "method": "update", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "policy_id", + "in": "path", + "required": true, + "description": "The policy", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PhoneFraudPolicyInput" + } + ], + "description": "Every field is optional: a field you leave out stays as it is." + }, + "examples": { + "Example": { + "value": { + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + } + ], + "threshold": 60, + "action": "challenge" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "The fraud policy as it now stands.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneFraudPolicy" + }, + "examples": { + "Example": { + "value": { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + }, + { + "signal": "email_risk", + "operator": "eq", + "value": "high", + "weight": 30 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + } + } + } + } + }, + "404": { + "description": "`not_found` - No policy with this id in your application." + }, + "400": { + "description": "A field is not valid: the answer names the field, for example a condition whose `signal`, `operator`, `value` or `weight` is not valid." + }, + "409": { + "description": "`flow_has_policy` - Another policy already scores the flow this request moves the policy to." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X PATCH 'https://verification.didit.me/v3/phone/fraud/policies/9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"name\": \"Payment check\", \"flow\": \"payment\", \"conditions\": [{\"signal\": \"sim_swap\", \"operator\": \"within_hours\", \"value\": \"72\", \"weight\": 40}], \"threshold\": 60, \"action\": \"challenge\"}'" + } + ] + }, + "delete": { + "summary": "Delete a fraud policy", + "description": "Delete a fraud policy. The flow it scored falls back to the fraud level and the rules in the fraud settings. Deletion is irreversible.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "delete_phone_fraud_policy", + "x-didit-sdk": { + "resource": "phone.fraud.policies", + "method": "delete", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "policy_id", + "in": "path", + "required": true, + "description": "The policy", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "responses": { + "204": { + "description": "The operation succeeded; there is no response body." + }, + "404": { + "description": "`not_found` - No policy with this id in your application." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X DELETE 'https://verification.didit.me/v3/phone/fraud/policies/9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/phone/fraud/events/batch/": { + "post": { + "summary": "Send fraud events in a batch", + "description": "Send up to 1,000 of your own events - a `signup`, a `login`, a `payment`, a `password_reset`, an `account_change` or a type of your own - to the fraud scoring, with the number, the email address, the IP address and the device signals of each one.\n\nThe answer is `207 Multi-Status`: `accepted` counts the events the scoring uses from the next request, and `results` gives each event's place in `events`, its id, whether it was accepted and, when it was rejected, why. An event with no `type` or `occurred_at` is rejected on its own as `invalid_event` in `results` while the valid events of the same batch are accepted: the answer is still `207`. A request whose `events` is not a list of objects with correctly typed fields is a malformed request.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "create_phone_fraud_events_batch", + "x-didit-sdk": { + "resource": "phone.fraud.events", + "method": "create_batch", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "events": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "`signup`, `login`, `payment`, `password_reset`, `account_change` or a type of your own.", + "example": "login" + }, + "phone_number": { + "type": "string", + "description": "The number In E.164 format; an event with another value is rejected on its own as `invalid_event`.", + "example": "+34600000012" + }, + "email": { + "type": "string", + "description": "Or an email address" + }, + "ip_address": { + "type": "string", + "description": "Your user's IP address." + }, + "device_signals": { + "type": "string", + "description": "The signed token from the SDK" + }, + "existing_user": { + "type": "boolean", + "description": "A returning user" + }, + "occurred_at": { + "type": "string", + "description": "When it happened, ISO 8601 An RFC 3339 date-time; another value rejects the event on its own.", + "example": "2026-11-21T09:58:00Z" + }, + "reference": { + "type": "string", + "description": "Your id for it", + "example": "login-99812" + } + }, + "description": "One event, an object whose fields have the JSON types below (a value of another JSON type, such as a number for `phone_number`, is a malformed request that no gateway or client should send). Beyond the types, each event is checked on its own: an event with no `type` or `occurred_at`, or with a phone number that is not E.164, an email that is not an address or a date-time that is not RFC 3339, is rejected as `invalid_event` in the `207` results while the rest of the batch is accepted." + }, + "maxItems": 1000, + "description": "Up to 1,000 events, each with the number, the address and what happened." + } + }, + "required": [ + "events" + ] + }, + "examples": { + "Example": { + "value": { + "events": [ + { + "type": "login", + "phone_number": "+34600000012", + "occurred_at": "2026-11-21T09:58:00Z", + "reference": "login-99812" + } + ] + } + } + } + } + } + }, + "responses": { + "207": { + "description": "How many events were accepted, and each event's result.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "accepted": { + "type": "integer", + "description": "Events the scoring uses from the next request", + "example": 1 + }, + "results": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneFraudEventResult" + } + } + } + }, + "examples": { + "Example": { + "value": { + "accepted": 1, + "results": [ + { + "index": 0, + "event_id": "ae4f1a36-8c7a-4d25-9a49-3f6b0c2d7e55", + "status": "accepted", + "error": null + } + ] + } + }, + "Mixed batch": { + "summary": "One valid event and one rejected", + "value": { + "accepted": 1, + "results": [ + { + "index": 0, + "event_id": "ae4f1a36-8c7a-4d25-9a49-3f6b0c2d7e55", + "status": "accepted", + "error": null + }, + { + "index": 1, + "status": "rejected", + "error": "invalid_event" + } + ] + } + } + } + } + } + }, + "400": { + "description": "`events` is missing, is empty, is not a list of objects, or has more than 1,000 events: nothing is accepted, and for more than 1,000 the error under `events` carries `code: too_many_events`. An event that is missing `type` or `occurred_at`, or has an invalid value, is not a `400`: it is rejected on its own in the `207` results." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/fraud/events/batch/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"events\": [{\"type\": \"login\", \"phone_number\": \"+34600000012\", \"occurred_at\": \"2026-11-21T09:58:00Z\", \"reference\": \"login-99812\"}]}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, + "/v3/phone/lists/check/": { + "post": { + "summary": "Check a number against your allow and block lists", + "description": "Answer whether a number is on the allow or the block list, and which entries match it: a number, a prefix, the country or the number's network. A match on the block list answers `blocked`.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "check_phone_lists", + "x-didit-sdk": { + "resource": "phone.lists", + "method": "check", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "phone_number": { + "type": "string", + "description": "The number to check", + "example": "+447700900123", + "pattern": "^\\+[1-9]\\d{6,14}$" + } + }, + "required": [ + "phone_number" + ] + }, + "examples": { + "Example": { + "value": { + "phone_number": "+447700900123" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Whether the number is allowed or blocked, and the entries that matched.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "allowed": { + "type": "boolean", + "description": "On the allow list", + "example": false + }, + "blocked": { + "type": "boolean", + "description": "On the block list, by number, prefix, country or network", + "example": true + }, + "matches": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneListMatch" + } + } + } + }, + "examples": { + "Example": { + "value": { + "allowed": false, + "blocked": true, + "matches": [ + { + "list_id": "block", + "entry_id": "c06b3c58-ae9c-4f47-9c6b-518d2e4f9a77", + "type": "prefix" + } + ] + } + } + } + } + } + }, + "400": { + "description": "`phone_number` is not a valid number: the answer is a field error that names `phone_number`." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/lists/check/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"phone_number\": \"+447700900123\"}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, + "/v3/phone/lists/{list_id}/entries/": { + "post": { + "summary": "Add an entry to an allow or block list", + "description": "Add an entry to one of the application's phone lists. `list_id` is `allow` or `block`, and `value` is a number, a prefix, a country code or a network, which `type` names (`number`, `prefix`, `country` or `network`).\n\nAn `expires_at` makes a temporary entry that ends on its own; `note` records why it was listed. `POST /v3/phone/lists/check/` answers with the entries that match a number, and the fraud rules read both lists.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "create_phone_list_entry", + "x-didit-sdk": { + "resource": "phone.lists", + "method": "add", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "list_id", + "in": "path", + "required": true, + "description": "The list: `allow` or `block`. Any other value answers `404`.", + "schema": { + "type": "string", + "enum": [ + "allow", + "block" + ] + }, + "example": "block" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "A number in E.164, a prefix, an ISO country code or a mobile network, as `type` says.", + "example": "+88216" + }, + "type": { + "type": "string", + "description": "number, prefix, country or network", + "example": "prefix", + "enum": [ + "number", + "prefix", + "country", + "network" + ] + }, + "expires_at": { + "type": "string", + "description": "A temporary entry ends on its own", + "format": "date-time" + }, + "note": { + "type": "string", + "description": "Why it is listed", + "example": "Pumping from this prefix", + "maxLength": 500 + } + }, + "required": [ + "value" + ] + }, + "examples": { + "Example": { + "value": { + "value": "+88216", + "type": "prefix", + "note": "Pumping from this prefix" + } + } + } + } + } + }, + "responses": { + "201": { + "description": "The new entry.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneListEntry" + }, + "examples": { + "Example": { + "value": { + "entry_id": "bf5a2b47-9d8b-4e36-8b5a-407c1d3e8f66", + "list_id": "block", + "value": "+88216", + "expires_at": null, + "type": "prefix", + "source": "api" + } + } + } + } + } + }, + "400": { + "description": "`invalid_value` - The value does not match its type: a number that is not valid, a prefix that does not start with `+` and digits, a country that is not a country code or a network name of more than 255 characters. Another invalid field answers a field error that names it." + }, + "404": { + "description": "`not_found` - No list with this id in your application." + }, + "409": { + "description": "`already_listed` - It is already on the list." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/lists/block/entries/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"value\": \"+88216\", \"type\": \"prefix\", \"note\": \"Pumping from this prefix\"}'" + } + ] + }, + "get": { + "summary": "List the entries of an allow or block list", + "description": "Read one of the application's lists: its entries, their type and the source that added each one (`manual`, `api` or `alert`). Filter by `type` or by part of a `value` or a `note`; `format=csv` exports every row of the filtered list instead of a page. Only the application's own phone and country lists are covered: `number`, `prefix` and `network` entries are in the phone list and `country` entries in the country list.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "list_phone_list_entries", + "x-didit-sdk": { + "resource": "phone.lists", + "method": "list_entries", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "list_id", + "in": "path", + "required": true, + "description": "The list: `allow` or `block`. Any other value answers `404`.", + "schema": { + "type": "string", + "enum": [ + "allow", + "block" + ] + }, + "example": "block" + }, + { + "name": "type", + "in": "query", + "required": false, + "description": "number, prefix, country or network", + "schema": { + "type": "string", + "enum": [ + "number", + "prefix", + "country", + "network" + ] + } + }, + { + "name": "search", + "in": "query", + "required": false, + "description": "Part of a value or a note", + "schema": { + "type": "string" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "20 by default, 100 at most", + "schema": { + "type": "integer", + "default": 20, + "minimum": 1, + "maximum": 100 + } + }, + { + "name": "offset", + "in": "query", + "required": false, + "description": "Where the page starts", + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + }, + { + "name": "format", + "in": "query", + "required": false, + "description": "json, or csv to export every row of the filtered list", + "schema": { + "type": "string", + "enum": [ + "json", + "csv" + ] + } + } + ], + "responses": { + "200": { + "description": "A page of the list's entries.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "count": { + "type": "integer", + "description": "The number of list entries that match the filters", + "example": 1, + "minimum": 0 + }, + "next": { + "type": "string", + "description": "The next page, or null", + "format": "uri", + "nullable": true + }, + "previous": { + "type": "string", + "description": "The previous page, or null", + "format": "uri", + "nullable": true + }, + "results": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneListEntry" + } + } + } + }, + "examples": { + "Example": { + "value": { + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "entry_id": "c06b3c58-ae9c-4f47-9c6b-518d2e4f9a77", + "value": "+4475", + "type": "prefix", + "expires_at": null, + "source": "alert" + } + ] + } + } + } + }, + "text/csv": { + "schema": { + "type": "string" + }, + "example": "entry_id,value,type,expires_at,source\nc06b3c58-ae9c-4f47-9c6b-518d2e4f9a77,+4475,prefix,,alert\n" + } + } + }, + "404": { + "description": "`not_found` - No list with this id in your application." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedRead" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X GET 'https://verification.didit.me/v3/phone/lists/block/entries/?limit=20' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/phone/lists/{list_id}/entries/{entry_id}/": { + "delete": { + "summary": "Delete an entry from an allow or block list", + "description": "Delete an entry from an allow or block list, for example to unblock a network. Deletion is irreversible: the number, prefix, country or network is no longer listed from the next request. Only the application's own phone and country lists are covered: `number`, `prefix` and `network` entries are in the phone list and `country` entries in the country list.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "delete_phone_list_entry", + "x-didit-sdk": { + "resource": "phone.lists", + "method": "remove", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "list_id", + "in": "path", + "required": true, + "description": "The list: `allow` or `block`. Any other value answers `404`.", + "schema": { + "type": "string", + "enum": [ + "allow", + "block" + ] + }, + "example": "block" + }, + { + "name": "entry_id", + "in": "path", + "required": true, + "description": "The entry", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "bf5a2b47-9d8b-4e36-8b5a-407c1d3e8f66" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "responses": { + "204": { + "description": "The operation succeeded; there is no response body." + }, + "404": { + "description": "`not_found` - No entry with this id in your application." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X DELETE 'https://verification.didit.me/v3/phone/lists/block/entries/bf5a2b47-9d8b-4e36-8b5a-407c1d3e8f66/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/phone/rate-limits/": { + "post": { + "summary": "Create a velocity limit", + "description": "Create a velocity limit of your own. A limit is keyed by the name of the value your sends are counted by, for example `user_id`, and each of its `buckets` allows `max` starts in `interval` seconds, at most 30 days (2,592,000 seconds). Send history is kept for that longest window, so every bucket counts the starts of its whole interval.\n\nA request over a bucket answers `429` with `Retry-After`, and the key is refused until the interval ends.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "create_phone_rate_limit", + "x-didit-sdk": { + "resource": "phone.rate_limits", + "method": "create", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "key": { + "type": "string", + "description": "The name of the value the limit counts, for example `user_id`.", + "example": "user_id", + "maxLength": 128 + }, + "buckets": { + "type": "array", + "items": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "description": "Starts allowed in the interval", + "example": 5, + "minimum": 1, + "maximum": 2147483647 + }, + "interval": { + "type": "integer", + "description": "The interval, in seconds, from 1 second to 30 days (2,592,000)", + "example": 3600, + "minimum": 1, + "maximum": 2592000 + } + }, + "required": [ + "max", + "interval" + ] + }, + "minItems": 1 + } + }, + "required": [ + "key", + "buckets" + ] + }, + "examples": { + "Example": { + "value": { + "key": "user_id", + "buckets": [ + { + "max": 5, + "interval": 3600 + } + ] + } + } + } + } + } + }, + "responses": { + "201": { + "description": "The new velocity limit and its buckets.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRateLimit" + }, + "examples": { + "Example": { + "value": { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 5, + "interval": 3600 + } + ] + } + } + } + } + } + }, + "400": { + "description": "A field is not valid: the answer names the field. For `buckets` the error carries `code: invalid_bucket` when no bucket is sent or `max` and `interval` are not positive, and a `max` outside 1 to 2147483647 or an `interval` outside 1 to 2,592,000 seconds (30 days) is a field error too." + }, + "409": { + "description": "`key_exists` - A limit with this key exists." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/rate-limits/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"key\": \"user_id\", \"buckets\": [{\"max\": 5, \"interval\": 3600}]}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + }, + "get": { + "summary": "List velocity limits", + "description": "List the application's velocity limits, oldest first, each with its key and its buckets.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "list_phone_rate_limits", + "x-didit-sdk": { + "resource": "phone.rate_limits", + "method": "list", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "required": false, + "description": "20 by default, 100 at most", + "schema": { + "type": "integer", + "default": 20, + "minimum": 1, + "maximum": 100 + } + }, + { + "name": "offset", + "in": "query", + "required": false, + "description": "Where the page starts", + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + } + ], + "responses": { + "200": { + "description": "A page of velocity limits, each with its buckets.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "count": { + "type": "integer", + "description": "The number of velocity limits that match the filters", + "example": 1, + "minimum": 0 + }, + "next": { + "type": "string", + "description": "The next page, or null", + "format": "uri", + "nullable": true + }, + "previous": { + "type": "string", + "description": "The previous page, or null", + "format": "uri", + "nullable": true + }, + "results": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneRateLimit" + } + } + } + }, + "examples": { + "Example": { + "value": { + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 5, + "interval": 3600, + "in_use": 2 + } + ] + } + ] + } + } + } + } + } + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedRead" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X GET 'https://verification.didit.me/v3/phone/rate-limits/?limit=20' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/phone/rate-limits/{rate_limit_id}/": { + "get": { + "summary": "Retrieve a velocity limit", + "description": "One velocity limit with its buckets, each bucket's `max`, `interval` and the starts already counted in the current interval as `in_use`.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "retrieve_phone_rate_limit", + "x-didit-sdk": { + "resource": "phone.rate_limits", + "method": "retrieve", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "rate_limit_id", + "in": "path", + "required": true, + "description": "The limit", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01" + } + ], + "responses": { + "200": { + "description": "The velocity limit and its buckets.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRateLimit" + }, + "examples": { + "Example": { + "value": { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 5, + "interval": 3600, + "in_use": 2 + } + ] + } + } + } + } + } + }, + "404": { + "description": "`not_found` - No rate limit with this id in your application." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry read access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedRead" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X GET 'https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + }, + "patch": { + "summary": "Update a velocity limit", + "description": "Change a velocity limit's buckets: send a `bucket_id` to change that bucket, or leave it out to add one. `max` and `interval` must be positive, and `interval` at most 30 days (2,592,000 seconds), or the answer is `400`. A `bucket_id` that is not a bucket of this limit answers `404` and nothing is changed; a bucket can be removed with Delete a bucket of a velocity limit.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "update_phone_rate_limit", + "x-didit-sdk": { + "resource": "phone.rate_limits", + "method": "update", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "rate_limit_id", + "in": "path", + "required": true, + "description": "The limit", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "buckets": { + "type": "array", + "items": { + "type": "object", + "properties": { + "bucket_id": { + "type": "string", + "description": "A bucket to change; left out, a new bucket is added.", + "example": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "format": "uuid" + }, + "max": { + "type": "integer", + "description": "Starts allowed in the interval", + "example": 10, + "minimum": 1, + "maximum": 2147483647 + }, + "interval": { + "type": "integer", + "description": "The interval, in seconds, from 1 second to 30 days (2,592,000)", + "example": 86400, + "minimum": 1, + "maximum": 2592000 + } + } + }, + "minItems": 1 + } + }, + "description": "`buckets` holds the bucket to add or change.", + "required": [ + "buckets" + ] + }, + "examples": { + "Example": { + "value": { + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 10, + "interval": 86400 + } + ] + } + } + } + } + } + }, + "responses": { + "200": { + "description": "The velocity limit and its buckets as they now stand.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhoneRateLimit" + }, + "examples": { + "Example": { + "value": { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 10, + "interval": 86400, + "in_use": 2 + } + ] + } + } + } + } + } + }, + "404": { + "description": "`not_found` - No rate limit with this id in your application." + }, + "400": { + "description": "A field is not valid: the answer names the field. For `buckets` the error carries `code: invalid_bucket` when no bucket is sent or `max` and `interval` are not positive, and a `max` outside 1 to 2147483647 or an `interval` outside 1 to 2,592,000 seconds (30 days) is a field error too." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X PATCH 'https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"buckets\": [{\"bucket_id\": \"0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10\", \"max\": 10, \"interval\": 86400}]}'" + } + ] + }, + "delete": { + "summary": "Delete a velocity limit", + "description": "Delete a velocity limit and every bucket in it. The key it was created for no longer limits sends. Deletion is irreversible.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "delete_phone_rate_limit", + "x-didit-sdk": { + "resource": "phone.rate_limits", + "method": "delete", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "rate_limit_id", + "in": "path", + "required": true, + "description": "The limit", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "responses": { + "204": { + "description": "The operation succeeded; there is no response body." + }, + "404": { + "description": "`not_found` - No rate limit with this id in your application." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X DELETE 'https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/phone/rate-limits/{rate_limit_id}/buckets/{bucket_id}/": { + "delete": { + "summary": "Delete a bucket of a velocity limit", + "description": "Delete one bucket of a velocity limit. A limit keeps at least one bucket, so the last one answers `409 last_bucket`: delete the limit instead. Deletion is irreversible.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "delete_phone_rate_limit_bucket", + "x-didit-sdk": { + "resource": "phone.rate_limits.buckets", + "method": "delete", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "rate_limit_id", + "in": "path", + "required": true, + "description": "The limit", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01" + }, + { + "name": "bucket_id", + "in": "path", + "required": true, + "description": "The bucket", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "responses": { + "204": { + "description": "The operation succeeded; there is no response body." + }, + "404": { + "description": "`not_found` - No bucket with this id in your application." + }, + "409": { + "description": "`last_bucket` - A limit keeps at least one bucket: delete the limit instead." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X DELETE 'https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/buckets/0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/phone/line-type-overrides/": { + "post": { + "summary": "Correct the line type of a number", + "description": "Correct the line type of a number for your future lookups: later lookups of that number report the corrected type (`mobile`, `landline`, `fixed_voip`, `non_fixed_voip`, `toll_free`, `premium` or `pager`) instead of the one the network gives, A second correction for the same number replaces the first and answers `201` too.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "create_phone_line_type_override", + "x-didit-sdk": { + "resource": "phone.line_type_overrides", + "method": "create", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "phone_number": { + "type": "string", + "description": "The number", + "example": "+34911234567", + "pattern": "^\\+[1-9]\\d{6,14}$" + }, + "line_type": { + "type": "string", + "description": "mobile, landline, fixed_voip, non_fixed_voip, toll_free, premium or pager", + "example": "landline", + "enum": [ + "mobile", + "landline", + "fixed_voip", + "non_fixed_voip", + "toll_free", + "premium", + "pager" + ] + }, + "note": { + "type": "string", + "description": "Why it is corrected", + "maxLength": 500 + } + }, + "required": [ + "phone_number", + "line_type" + ] + }, + "examples": { + "Example": { + "value": { + "phone_number": "+34911234567", + "line_type": "landline" + } + } + } + } + } + }, + "responses": { + "201": { + "description": "The line-type correction.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "override_id": { + "type": "string", + "description": "The override", + "example": "7c2d9e14-6a58-4b03-9e27-1d4f8a0b5c33", + "format": "uuid" + }, + "phone_number": { + "type": "string", + "description": "The number in E.164 format", + "example": "+34911234567", + "pattern": "^\\+[1-9]\\d{6,14}$" + }, + "line_type": { + "type": "string", + "description": "What lookups return from now on", + "example": "landline", + "enum": [ + "mobile", + "landline", + "fixed_voip", + "non_fixed_voip", + "toll_free", + "premium", + "pager" + ] + }, + "created_at": { + "type": "string", + "description": "When", + "example": "2026-11-21T09:00:00Z", + "format": "date-time" + } + }, + "required": [ + "override_id", + "phone_number", + "line_type", + "created_at" + ] + }, + "examples": { + "Example": { + "value": { + "override_id": "7c2d9e14-6a58-4b03-9e27-1d4f8a0b5c33", + "phone_number": "+34911234567", + "line_type": "landline", + "created_at": "2026-11-21T09:00:00Z" + } + } + } + } + } + }, + "400": { + "description": "A field is not valid: the answer names the field, for example a `line_type` outside the values listed or a `phone_number` that is not a valid number." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/phone/line-type-overrides/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"phone_number\": \"+34911234567\", \"line_type\": \"landline\"}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, + "/v3/phone/line-type-overrides/{override_id}/": { + "delete": { + "summary": "Delete a line-type correction", + "description": "Delete a line-type correction so lookups report the type the network gives again. Deletion is irreversible.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "delete_phone_line_type_override", + "x-didit-sdk": { + "resource": "phone.line_type_overrides", + "method": "delete", + "auth": "api_key", + "server": true + }, + "tags": [ + "Standalone APIs" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "parameters": [ + { + "name": "override_id", + "in": "path", + "required": true, + "description": "The override", + "schema": { + "type": "string", + "format": "uuid" + }, + "example": "7c2d9e14-6a58-4b03-9e27-1d4f8a0b5c33" + }, + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ], + "responses": { + "204": { + "description": "The operation succeeded; there is no response body." + }, + "404": { + "description": "`not_found` - No override with this id in your application." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `sessions`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X DELETE 'https://verification.didit.me/v3/phone/line-type-overrides/7c2d9e14-6a58-4b03-9e27-1d4f8a0b5c33/' \\\n -H 'x-api-key: YOUR_API_KEY'" + } + ] + } + }, + "/v3/messages/rules/": { + "post": { + "summary": "Create a messaging rule", + "description": "Add a messaging rule that allows or blocks by country, prefix or number. Send exactly one of `match.country` (an ISO country code), `match.prefix` or `match.number`; `direction` is `outbound` (the default) or `inbound`, and `channels` limits the rule to the channels it names.\n\n**Authentication.** Send your application's API key in `x-api-key`.", + "operationId": "create_message_rule", + "x-didit-sdk": { + "resource": "messages.rules", + "method": "create", + "auth": "api_key", + "server": true + }, + "tags": [ + "Messages" + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "action": { + "type": "string", + "description": "allow or block", + "example": "block", + "enum": [ + "allow", + "block" + ] + }, + "direction": { + "type": "string", + "description": "outbound (default) or inbound", + "example": "outbound", + "enum": [ + "outbound", + "inbound" + ], + "default": "outbound" + }, + "match": { + "type": "object", + "properties": { + "country": { + "type": "string", + "description": "An ISO 3166-1 alpha-2 country code, in any case", + "pattern": "^[A-Za-z]{2}$" + }, + "prefix": { + "type": "string", + "description": "A number prefix", + "example": "+88216", + "maxLength": 16 + }, + "number": { + "type": "string", + "description": "One number" + } + }, + "description": "Exactly one of `country`, `prefix` or `number`.", + "oneOf": [ + { + "required": [ + "country" + ] + }, + { + "required": [ + "prefix" + ] + }, + { + "required": [ + "number" + ] + } + ] + }, + "channels": { + "type": "array", + "description": "The channels it covers, for example `sms`, `whatsapp` or `voice`; all channels when you send none", + "example": [ + "sms" + ], + "items": { + "type": "string", + "maxLength": 16 + }, + "default": [] + } + }, + "required": [ + "action", + "match" + ], + "description": "Send exactly one of `match.country`, `match.prefix` or `match.number`." + }, + "examples": { + "Example": { + "value": { + "action": "block", + "direction": "outbound", + "match": { + "prefix": "+88216" + }, + "channels": [ + "sms" + ] + } + } + } + } + } + }, + "responses": { + "201": { + "description": "The new messaging rule.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "rule_id": { + "type": "string", + "description": "The rule", + "example": "5b1e7a90-2c43-4d68-8f15-0a9c3e6d7b22", + "format": "uuid" + } + }, + "required": [ + "rule_id" + ] + }, + "examples": { + "Example": { + "value": { + "rule_id": "5b1e7a90-2c43-4d68-8f15-0a9c3e6d7b22" + } + } + } + } + } + }, + "400": { + "description": "A field is not valid: the answer names the field. `match` carries `code: invalid_match` when it does not hold exactly one of `country`, `prefix` or `number`, or the country is not two letters." + }, + "403": { + "description": "The `x-api-key` header is missing, or the key is scoped and does not carry write access to `messages`: the answer is `{\"detail\": ...}`." + }, + "429": { + "$ref": "#/components/responses/RateLimitedWrite" + } + }, + "x-codeSamples": [ + { + "lang": "curl", + "label": "curl", + "source": "curl -X POST 'https://verification.didit.me/v3/messages/rules/' \\\n -H 'x-api-key: YOUR_API_KEY' \\\n -H 'Content-Type: application/json' \\\n -d '{\"action\": \"block\", \"direction\": \"outbound\", \"match\": {\"prefix\": \"+88216\"}, \"channels\": [\"sms\"]}'" + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/IdempotencyKey" + } + ] + } + }, "/v3/bank/account-check/": { "post": { "summary": "Check a bank account", @@ -152201,6 +155376,538 @@ "$ref": "#/components/schemas/BankVerificationOngoingAvailability" } } + }, + "PhoneFraudRule": { + "type": "object", + "properties": { + "key": { + "type": "string", + "description": "velocity, pumping, risk_score, sim_swap, device or country", + "example": "sim_swap", + "enum": [ + "velocity", + "pumping", + "risk_score", + "sim_swap", + "device", + "country" + ] + }, + "action": { + "type": "string", + "description": "allow, review, require_code, challenge or block: challenge continues the verification on challenge_channels only", + "example": "require_code", + "enum": [ + "allow", + "review", + "require_code", + "challenge", + "block" + ] + }, + "countries": { + "type": "array", + "description": "The rule applies only to these countries", + "example": [ + "GB", + "ES" + ], + "items": { + "type": "string", + "pattern": "^[A-Z]{2}$" + } + }, + "platforms": { + "type": "array", + "description": "The rule applies only to web, ios or android", + "items": { + "type": "string", + "enum": [ + "web", + "ios", + "android" + ] + } + }, + "scope": { + "type": "string", + "description": "codes (the only value): the rule applies to verification codes", + "enum": [ + "codes" + ] + } + }, + "description": "One fraud rule: the signal it reads, the action it takes and where it applies." + }, + "PhoneRateLimitBucket": { + "type": "object", + "properties": { + "bucket_id": { + "type": "string", + "description": "Each bucket", + "example": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "format": "uuid" + }, + "max": { + "type": "integer", + "description": "Starts allowed in the interval", + "example": 5, + "minimum": 1, + "maximum": 2147483647 + }, + "interval": { + "type": "integer", + "description": "The interval, in seconds, from 1 second to 30 days (2,592,000)", + "example": 3600, + "minimum": 1, + "maximum": 2592000 + }, + "in_use": { + "type": "integer", + "description": "The starts already counted in the current interval", + "example": 2, + "minimum": 0 + } + }, + "required": [ + "bucket_id", + "max", + "interval", + "in_use" + ] + }, + "PhoneRateLimit": { + "type": "object", + "properties": { + "rate_limit_id": { + "type": "string", + "description": "The limit", + "example": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "format": "uuid" + }, + "key": { + "type": "string", + "description": "Its key", + "example": "user_id", + "maxLength": 128 + }, + "buckets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneRateLimitBucket" + }, + "description": "The buckets of the limit: each allows `max` starts in `interval` seconds." + } + }, + "required": [ + "rate_limit_id", + "key", + "buckets" + ] + }, + "PhoneListEntry": { + "type": "object", + "properties": { + "entry_id": { + "type": "string", + "format": "uuid", + "description": "The entry", + "example": "c06b3c58-ae9c-4f47-9c6b-518d2e4f9a77" + }, + "list_id": { + "type": "string", + "enum": [ + "allow", + "block" + ], + "description": "The list it is on", + "example": "block" + }, + "value": { + "type": "string", + "description": "The number in E.164 format, the prefix, the ISO 3166-1 alpha-3 country code or the network", + "example": "+4475" + }, + "type": { + "type": "string", + "enum": [ + "number", + "prefix", + "country", + "network" + ], + "description": "Its type", + "example": "prefix" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "nullable": true, + "description": "When a temporary entry ends; `null` for a permanent one" + }, + "source": { + "type": "string", + "enum": [ + "manual", + "api", + "alert" + ], + "description": "Who added it: `manual` in the console, `api` through this API or `alert`", + "example": "api" + } + }, + "required": [ + "entry_id", + "list_id", + "value", + "type", + "expires_at", + "source" + ] + }, + "PhoneListMatch": { + "type": "object", + "properties": { + "list_id": { + "type": "string", + "description": "allow or block", + "example": "block", + "enum": [ + "allow", + "block" + ] + }, + "entry_id": { + "type": "string", + "description": "The entry that matched", + "example": "c06b3c58-ae9c-4f47-9c6b-518d2e4f9a77", + "format": "uuid" + }, + "type": { + "type": "string", + "description": "number, prefix, country or network", + "example": "prefix", + "enum": [ + "number", + "prefix", + "country", + "network" + ] + } + }, + "required": [ + "list_id", + "entry_id", + "type" + ] + }, + "PhoneFraudPolicyCondition": { + "type": "object", + "properties": { + "signal": { + "type": "string", + "description": "risk_score, sim_swap, line_type, country, velocity, ip_risk, device, email_risk or existing_user", + "example": "sim_swap", + "enum": [ + "risk_score", + "sim_swap", + "line_type", + "country", + "velocity", + "ip_risk", + "device", + "email_risk", + "existing_user" + ] + }, + "operator": { + "type": "string", + "description": "eq, neq, gt, lt, in or within_hours", + "example": "within_hours", + "enum": [ + "eq", + "neq", + "gt", + "lt", + "in", + "within_hours" + ] + }, + "value": { + "type": "string", + "description": "What the signal is compared with", + "example": "72", + "maxLength": 128 + }, + "weight": { + "type": "integer", + "description": "Points added to the score when the condition holds, 0 to 100", + "example": 40, + "minimum": 0, + "maximum": 100 + } + }, + "required": [ + "signal", + "operator", + "value", + "weight" + ] + }, + "PhoneFraudPolicy": { + "type": "object", + "properties": { + "policy_id": { + "type": "string", + "description": "The policy", + "example": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "format": "uuid" + }, + "name": { + "type": "string", + "description": "Its name", + "example": "Payment check", + "maxLength": 128 + }, + "flow": { + "type": "string", + "description": "The flow it scores, as sent in action on evaluate and send", + "example": "payment", + "maxLength": 64 + }, + "threshold": { + "type": "integer", + "description": "The score at which action applies", + "example": 60, + "minimum": 0, + "maximum": 100 + }, + "action": { + "type": "string", + "description": "allow, review, challenge or block", + "example": "challenge", + "enum": [ + "allow", + "review", + "challenge", + "block" + ] + }, + "updated_at": { + "type": "string", + "description": "Last change", + "example": "2026-11-21T09:00:00Z", + "format": "date-time" + }, + "conditions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneFraudPolicyCondition" + }, + "description": "The conditions that add their weight to the score when they hold." + } + }, + "required": [ + "policy_id", + "name", + "flow", + "conditions", + "threshold", + "action", + "updated_at" + ] + }, + "PhoneFraudEventResult": { + "type": "object", + "properties": { + "index": { + "type": "integer", + "description": "The event's place in events", + "example": 0, + "minimum": 0 + }, + "event_id": { + "type": "string", + "description": "The event; present only for an accepted event", + "example": "ae4f1a36-8c7a-4d25-9a49-3f6b0c2d7e55", + "format": "uuid" + }, + "status": { + "type": "string", + "description": "accepted or rejected", + "example": "accepted", + "enum": [ + "accepted", + "rejected" + ] + }, + "error": { + "type": "string", + "description": "Why it was rejected: `invalid_event`; `null` for an accepted event", + "nullable": true, + "enum": [ + "invalid_event", + null + ] + } + }, + "required": [ + "index", + "status" + ] + }, + "PhoneRiskBulkJob": { + "type": "object", + "description": "A bulk risk job.", + "properties": { + "job_id": { + "type": "string", + "format": "uuid", + "description": "The job.", + "example": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55" + }, + "status": { + "type": "string", + "enum": [ + "queued", + "running", + "done", + "failed" + ], + "description": "`queued`, `running`, `done`, or `failed`. A job fails when your organization balance cannot pay for the next paid lookup (the rows already answered stay downloadable) or after 3 failed retries.", + "example": "queued" + }, + "total": { + "type": "integer", + "minimum": 0, + "description": "Numbers in the file.", + "example": 2400 + }, + "processed": { + "type": "integer", + "minimum": 0, + "description": "Numbers answered so far.", + "example": 0 + }, + "results_url": { + "type": "string", + "nullable": true, + "description": "The relative path `/v3/phone/risk/bulk/{job_id}/results/` of the CSV, present once a result file exists (also for a failed job); otherwise `null`.", + "example": "/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/results/" + } + }, + "required": [ + "job_id", + "status", + "total", + "processed", + "results_url" + ] + }, + "PhoneRiskBulkCallback": { + "type": "object", + "description": "The body Didit posts to your `callback_url` when the job finishes.", + "properties": { + "job_id": { + "type": "string", + "format": "uuid", + "description": "The job.", + "example": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55" + }, + "status": { + "type": "string", + "enum": [ + "done", + "failed" + ], + "description": "`done`, or `failed` when your organization balance could not pay for the next paid lookup or after 3 failed retries.", + "example": "done" + }, + "total": { + "type": "integer", + "minimum": 0, + "description": "Numbers in the file.", + "example": 2400 + }, + "results_url": { + "type": "string", + "nullable": true, + "description": "The relative path `/v3/phone/risk/bulk/{job_id}/results/` of the CSV, present once a result file exists (also for a failed job); otherwise `null`.", + "example": "/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/results/" + } + }, + "required": [ + "job_id", + "status", + "total", + "results_url" + ], + "example": { + "job_id": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55", + "status": "done", + "total": 2400, + "results_url": "/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/results/" + } + }, + "PhoneRiskBulkError": { + "type": "object", + "description": "An error answer: `code` names the reason and `detail` says it in words.", + "properties": { + "detail": { + "type": "string", + "example": "The results are not ready." + }, + "code": { + "type": "string", + "example": "results_not_ready" + } + }, + "required": [ + "detail", + "code" + ] + }, + "PhoneFraudPolicyInput": { + "type": "object", + "description": "The fields of a fraud policy you can write. A field you leave out stays as it is on an update; on a create `name` and `flow` are required, `threshold` defaults to 60 and `action` to `review`.", + "properties": { + "name": { + "type": "string", + "description": "Its name", + "example": "Payment check", + "maxLength": 128 + }, + "flow": { + "type": "string", + "description": "The flow it scores: `signup`, `login`, `payment` or a flow of your own, as sent in `action` on evaluate and send.", + "example": "payment", + "maxLength": 64 + }, + "conditions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PhoneFraudPolicyCondition" + } + }, + "threshold": { + "type": "integer", + "description": "The score at which action applies", + "example": 60, + "minimum": 0, + "maximum": 100 + }, + "action": { + "type": "string", + "description": "allow, review, challenge or block", + "example": "challenge", + "enum": [ + "allow", + "review", + "challenge", + "block" + ] + } + } } }, "securitySchemes": { diff --git a/sig/didit/resources/messages.rbs b/sig/didit/resources/messages.rbs index 6be43d7..c05b3f0 100644 --- a/sig/didit/resources/messages.rbs +++ b/sig/didit/resources/messages.rbs @@ -3,6 +3,7 @@ module Didit module Resources class Messages < Didit::Resource + def rules: () -> Didit::Resources::Messages::Rules def cancel: (String message_id, ?request_options: Didit::request_options?) -> Didit::Types::Message def delete: (String message_id, ?request_options: Didit::request_options?) -> nil def list: (?limit: Integer, ?offset: Integer, ?status: String, ?channel: String, ?to: String, ?correlation_id: String, ?created_after: Time | String, ?created_before: Time | String, ?request_options: Didit::request_options?) -> Didit::Page[Didit::Types::Message] @@ -11,6 +12,9 @@ module Didit def retrieve_settings: (?request_options: Didit::request_options?) -> Didit::Types::MessagesSettings def send_message: (to: String, ?to_email: String, ?channels: Array[String], ?body: String, ?template_id: String, ?variables: Hash[String | Symbol, String], ?locale: String, ?subject: String, ?schedule_at: Time | String, ?expires_at: Time | String, ?correlation_id: String, ?options: Didit::Types::messages_send_params_options, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::Message def update_settings: (retention_days: Integer, ?request_options: Didit::request_options?) -> Didit::Types::MessagesSettings + class Rules < Didit::Resource + def create: (action: String, match: Didit::Types::messages_rules_create_params_match, ?direction: String, ?channels: Array[String], ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::MessagesRulesCreateResponse + end end end end diff --git a/sig/didit/resources/phone.rbs b/sig/didit/resources/phone.rbs index ee345fb..1e4a8d8 100644 --- a/sig/didit/resources/phone.rbs +++ b/sig/didit/resources/phone.rbs @@ -3,9 +3,54 @@ module Didit module Resources class Phone < Didit::Resource + def fraud: () -> Didit::Resources::Phone::Fraud + def line_type_overrides: () -> Didit::Resources::Phone::LineTypeOverrides + def lists: () -> Didit::Resources::Phone::Lists + def rate_limits: () -> Didit::Resources::Phone::RateLimits def assess_risk: (phone_number: String, ?country_code: String, ?signals: Didit::Types::risk_signals, ?vendor_data: String, ?metadata: (Hash[String | Symbol, untyped])?, ?enable_social: bool, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneRiskResponse + def assess_risk_bulk: (file: Didit::upload, ?fields: Array[String], ?callback_url: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneRiskBulkJob def check_code: (phone_number: String, code: String, ?duplicated_phone_number_action: String, ?disposable_number_action: String, ?voip_number_action: String, ?enable_enrichment: bool, ?phone_intelligence_score_action: String, ?phone_type_risk_action: String, ?recent_port_action: String, ?low_phone_trust_action: String, ?enable_social: bool, ?phone_no_social_presence_action: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneVerificationCheckResponse + def download_risk_bulk_results: (String job_id, ?request_options: Didit::request_options?) -> String + | (String job_id, ?request_options: Didit::request_options?) { (String chunk) -> void } -> nil + def retrieve_risk_bulk: (String job_id, ?request_options: Didit::request_options?) -> Didit::Types::PhoneRiskBulkJob def send_code: (phone_number: String, ?options: Didit::Types::phone_send_code_params_options, ?signals: Didit::Types::phone_send_code_params_signals, ?vendor_data: String, ?metadata: (Hash[String | Symbol, untyped])?, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneVerificationSendResponse + class Fraud < Didit::Resource + def events: () -> Didit::Resources::Phone::Fraud::Events + def policies: () -> Didit::Resources::Phone::Fraud::Policies + def evaluate: (?phone_number: String, ?email: String, ?action: String, ?ip_address: String, ?device_signals: String, ?existing_user: bool, ?trusted_user: bool, ?fraud_override: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneFraudEvaluateResponse + def update: (?level: String, ?rules: Array[Didit::Types::phone_fraud_update_params_rules], ?challenge_channels: Array[String], ?sim_swap_within: Integer, ?daily_cap: String?, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneFraudUpdateResponse + class Events < Didit::Resource + def create_batch: (events: Array[Didit::Types::phone_fraud_events_create_batch_params_events], ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneFraudEventsCreateBatchResponse + end + class Policies < Didit::Resource + def create: (?name: String, ?flow: String, ?conditions: Array[Didit::Types::phone_fraud_policy_condition], ?threshold: Integer, ?action: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneFraudPolicy + def delete: (String policy_id, ?idempotency_key: String, ?request_options: Didit::request_options?) -> nil + def list: (?flow: String, ?limit: Integer, ?offset: Integer, ?request_options: Didit::request_options?) -> Didit::Page[Didit::Types::PhoneFraudPolicy] + def retrieve: (String policy_id, ?request_options: Didit::request_options?) -> Didit::Types::PhoneFraudPolicy + def update: (String policy_id, ?name: String, ?flow: String, ?conditions: Array[Didit::Types::phone_fraud_policy_condition], ?threshold: Integer, ?action: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneFraudPolicy + end + end + class LineTypeOverrides < Didit::Resource + def create: (phone_number: String, line_type: String, ?note: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneLineTypeOverridesCreateResponse + def delete: (String override_id, ?idempotency_key: String, ?request_options: Didit::request_options?) -> nil + end + class Lists < Didit::Resource + def add: (String list_id, value: String, ?type: String, ?expires_at: Time | String, ?note: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneListEntry + def check: (phone_number: String, ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneListsCheckResponse + def list_entries: (String list_id, ?type: String, ?search: String, ?limit: Integer, ?offset: Integer, ?format: String, ?request_options: Didit::request_options?) -> Didit::Page[Didit::Types::PhoneListEntry] + def remove: (String list_id, String entry_id, ?idempotency_key: String, ?request_options: Didit::request_options?) -> nil + end + class RateLimits < Didit::Resource + def buckets: () -> Didit::Resources::Phone::RateLimits::Buckets + def create: (key: String, buckets: Array[Didit::Types::phone_rate_limits_create_params_buckets], ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneRateLimit + def delete: (String rate_limit_id, ?idempotency_key: String, ?request_options: Didit::request_options?) -> nil + def list: (?limit: Integer, ?offset: Integer, ?request_options: Didit::request_options?) -> Didit::Page[Didit::Types::PhoneRateLimit] + def retrieve: (String rate_limit_id, ?request_options: Didit::request_options?) -> Didit::Types::PhoneRateLimit + def update: (String rate_limit_id, buckets: Array[Didit::Types::phone_rate_limits_update_params_buckets], ?idempotency_key: String, ?request_options: Didit::request_options?) -> Didit::Types::PhoneRateLimit + class Buckets < Didit::Resource + def delete: (String rate_limit_id, String bucket_id, ?idempotency_key: String, ?request_options: Didit::request_options?) -> nil + end + end end end end diff --git a/sig/didit/types/components.rbs b/sig/didit/types/components.rbs index f701798..f85fbde 100644 --- a/sig/didit/types/components.rbs +++ b/sig/didit/types/components.rbs @@ -2863,6 +2863,97 @@ module Didit VALUES: Array[String] end + module PhoneFraudEventResultError + INVALID_EVENT: String + + VALUES: Array[String] + end + + module PhoneFraudEventResultStatus + ACCEPTED: String + REJECTED: String + + VALUES: Array[String] + end + + module PhoneFraudPolicyAction + ALLOW: String + REVIEW: String + CHALLENGE: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneFraudPolicyConditionOperator + EQ: String + NEQ: String + GT: String + LT: String + IN: String + WITHIN_HOURS: String + + VALUES: Array[String] + end + + module PhoneFraudPolicyConditionSignal + RISK_SCORE: String + SIM_SWAP: String + LINE_TYPE: String + COUNTRY: String + VELOCITY: String + IP_RISK: String + DEVICE: String + EMAIL_RISK: String + EXISTING_USER: String + + VALUES: Array[String] + end + + module PhoneFraudPolicyInputAction + ALLOW: String + REVIEW: String + CHALLENGE: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneFraudRuleAction + ALLOW: String + REVIEW: String + REQUIRE_CODE: String + CHALLENGE: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneFraudRuleKey + VELOCITY: String + PUMPING: String + RISK_SCORE: String + SIM_SWAP: String + DEVICE: String + COUNTRY: String + + VALUES: Array[String] + end + + module PhoneFraudRulePlatforms + WEB: String + IOS: String + ANDROID: String + + VALUES: Array[String] + end + + module PhoneFraudRuleScope + CODES: String + + VALUES: Array[String] + end + module PhoneIntelligenceReasonCodesDirection RISK: String TRUST: String @@ -2870,6 +2961,55 @@ module Didit VALUES: Array[String] end + module PhoneListEntryListId + ALLOW: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneListEntrySource + MANUAL: String + API: String + ALERT: String + + VALUES: Array[String] + end + + module PhoneListEntryType + NUMBER: String + PREFIX: String + COUNTRY: String + NETWORK: String + + VALUES: Array[String] + end + + module PhoneListMatchListId + ALLOW: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneListMatchType + NUMBER: String + PREFIX: String + COUNTRY: String + NETWORK: String + + VALUES: Array[String] + end + + module PhoneRiskBulkJobStatus + QUEUED: String + RUNNING: String + DONE: String + FAILED: String + + VALUES: Array[String] + end + module PhoneRiskResponsePhoneStatus APPROVED: String IN_REVIEW: String @@ -10107,6 +10247,38 @@ module Didit def failed_insufficient_balance: () -> Integer? end + class PhoneFraudEventResult < Didit::Model + def index: () -> Integer + def event_id: () -> String? + def status: () -> String + def error: () -> String? + end + + class PhoneFraudPolicy < Didit::Model + def policy_id: () -> String + def name: () -> String + def flow: () -> String + def threshold: () -> Integer + def action: () -> String + def updated_at: () -> Time + def conditions: () -> Array[Didit::Types::PhoneFraudPolicyCondition] + end + + class PhoneFraudPolicyCondition < Didit::Model + def signal: () -> String + def operator: () -> String + def value: () -> String + def weight: () -> Integer + end + + class PhoneFraudRule < Didit::Model + def key: () -> String? + def action: () -> String? + def countries: () -> Array[String]? + def platforms: () -> Array[String]? + def scope: () -> String? + end + class PhoneIntelligence < Didit::Model def score: () -> Float? def phone_type_risk: () -> String? @@ -10127,6 +10299,21 @@ module Didit def impact_level: () -> String? end + class PhoneListEntry < Didit::Model + def entry_id: () -> String + def list_id: () -> String + def value: () -> String + def `type`: () -> String + def expires_at: () -> Time? + def source: () -> String + end + + class PhoneListMatch < Didit::Model + def list_id: () -> String + def entry_id: () -> String + def `type`: () -> String + end + class PhoneMatchItem < Didit::Model def session_id: () -> String? def session_number: () -> Integer? @@ -10139,6 +10326,27 @@ module Didit def source: () -> String? end + class PhoneRateLimit < Didit::Model + def rate_limit_id: () -> String + def key: () -> String + def buckets: () -> Array[Didit::Types::PhoneRateLimitBucket] + end + + class PhoneRateLimitBucket < Didit::Model + def bucket_id: () -> String + def max: () -> Integer + def interval: () -> Integer + def in_use: () -> Integer + end + + class PhoneRiskBulkJob < Didit::Model + def job_id: () -> String + def status: () -> String + def total: () -> Integer + def processed: () -> Integer + def results_url: () -> String? + end + class PhoneRiskResponse < Didit::Model def request_id: () -> String def status: () -> String @@ -14236,6 +14444,10 @@ module Didit type monitoring_event_create_request_transaction_context = { ?amount: String?, ?currency: String?, ?direction: String?, ?payment_reference_id: String? } + type phone_fraud_policy_condition = { signal: String, operator: String, value: String, weight: Integer } + + type phone_fraud_policy_input = { ?name: String, ?flow: String, ?conditions: Array[Didit::Types::phone_fraud_policy_condition], ?threshold: Integer, ?action: String } + type risk_signals = { ?ip: String, ?device_id: String, ?device_platform: String, ?device_model: String, ?os_version: String, ?app_version: String, ?user_agent: String } type session_sign_document = { ?title: String, file_name: String, content_base64: String, ?fields: Array[Didit::Types::signature_field] } diff --git a/sig/didit/types/messages.rbs b/sig/didit/types/messages.rbs index ce89ff1..ebfeba6 100644 --- a/sig/didit/types/messages.rbs +++ b/sig/didit/types/messages.rbs @@ -23,6 +23,20 @@ module Didit VALUES: Array[String] end + module MessagesRulesCreateParamsAction + ALLOW: String + BLOCK: String + + VALUES: Array[String] + end + + module MessagesRulesCreateParamsDirection + OUTBOUND: String + INBOUND: String + + VALUES: Array[String] + end + module MessagesSendParamsChannels SMS: String WHATSAPP: String @@ -31,6 +45,14 @@ module Didit VALUES: Array[String] end + class MessagesRulesCreateResponse < Didit::Model + def rule_id: () -> String + end + + type messages_rules_create_params = { action: String, ?direction: String, match: Didit::Types::messages_rules_create_params_match, ?channels: Array[String] } + + type messages_rules_create_params_match = { ?country: String, ?prefix: String, ?number: String } + type messages_send_params = { to: String, ?to_email: String, ?channels: Array[String], ?body: String, ?template_id: String, ?variables: Hash[String | Symbol, String], ?locale: String, ?subject: String, ?schedule_at: Time | String, ?expires_at: Time | String, ?correlation_id: String, ?options: Didit::Types::messages_send_params_options } type messages_send_params_options = { ?append_opt_out_line: bool } diff --git a/sig/didit/types/phone.rbs b/sig/didit/types/phone.rbs index a9ec277..66228c9 100644 --- a/sig/didit/types/phone.rbs +++ b/sig/didit/types/phone.rbs @@ -2,6 +2,20 @@ module Didit module Types + module PhoneAssessRiskBulkParamsFields + FORMAT: String + LINE_TYPE: String + NETWORK: String + REACHABILITY: String + SIM_SWAP: String + SMS_PUMPING_RISK: String + PREFILL: String + SCAM_SIGNAL: String + IDENTITY_MATCH: String + + VALUES: Array[String] + end + module PhoneCheckCodeParamsDisposableNumberAction NO_ACTION: String DECLINE: String @@ -58,6 +72,200 @@ module Didit VALUES: Array[String] end + module PhoneFraudEvaluateResponseChallengeChannels + SILENT: String + WHATSAPP: String + TELEGRAM: String + RCS: String + VIBER: String + ZALO: String + EMAIL: String + PUSH: String + TOTP: String + PASSKEY: String + + VALUES: Array[String] + end + + module PhoneFraudEvaluateResponseDecision + ALLOW: String + REVIEW: String + CHALLENGE: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneFraudEvaluateResponseEmailReasons + DISPOSABLE_DOMAIN: String + + VALUES: Array[String] + end + + module PhoneFraudEvaluateResponseEmailRisk + LOW: String + HIGH: String + + VALUES: Array[String] + end + + module PhoneFraudEvaluateResponseException + TRUSTED_USER: String + + VALUES: Array[String] + end + + module PhoneFraudEvaluateResponseMatchedRulesAction + ALLOW: String + REVIEW: String + REQUIRE_CODE: String + CHALLENGE: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneFraudEvaluateResponseMatchedRulesKey + VELOCITY: String + PUMPING: String + RISK_SCORE: String + SIM_SWAP: String + DEVICE: String + COUNTRY: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateParamsChallengeChannels + SILENT: String + WHATSAPP: String + TELEGRAM: String + RCS: String + VIBER: String + ZALO: String + EMAIL: String + PUSH: String + TOTP: String + PASSKEY: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateParamsLevel + STANDARD: String + STRICT: String + CUSTOM: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateParamsRulesAction + ALLOW: String + REVIEW: String + REQUIRE_CODE: String + CHALLENGE: String + BLOCK: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateParamsRulesKey + VELOCITY: String + PUMPING: String + RISK_SCORE: String + SIM_SWAP: String + DEVICE: String + COUNTRY: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateParamsRulesPlatforms + WEB: String + IOS: String + ANDROID: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateParamsRulesScope + CODES: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateResponseChallengeChannels + SILENT: String + WHATSAPP: String + TELEGRAM: String + RCS: String + VIBER: String + ZALO: String + EMAIL: String + PUSH: String + TOTP: String + PASSKEY: String + + VALUES: Array[String] + end + + module PhoneFraudUpdateResponseLevel + STANDARD: String + STRICT: String + CUSTOM: String + + VALUES: Array[String] + end + + module PhoneLineTypeOverridesCreateParamsLineType + MOBILE: String + LANDLINE: String + FIXED_VOIP: String + NON_FIXED_VOIP: String + TOLL_FREE: String + PREMIUM: String + PAGER: String + + VALUES: Array[String] + end + + module PhoneLineTypeOverridesCreateResponseLineType + MOBILE: String + LANDLINE: String + FIXED_VOIP: String + NON_FIXED_VOIP: String + TOLL_FREE: String + PREMIUM: String + PAGER: String + + VALUES: Array[String] + end + + module PhoneListsAddParamsType + NUMBER: String + PREFIX: String + COUNTRY: String + NETWORK: String + + VALUES: Array[String] + end + + module PhoneListsListEntriesParamsFormat + JSON: String + CSV: String + + VALUES: Array[String] + end + + module PhoneListsListEntriesParamsType + NUMBER: String + PREFIX: String + COUNTRY: String + NETWORK: String + + VALUES: Array[String] + end + module PhoneSendCodeParamsOptionsPreferredChannel WHATSAPP: String SMS: String @@ -80,10 +288,114 @@ module Didit VALUES: Array[String] end + class PhoneFraudEvaluateResponse < Didit::Model + def decision: () -> String + def score: () -> Integer + def matched_rules: () -> Array[Didit::Types::PhoneFraudEvaluateResponseMatchedRules] + def policy: () -> Didit::Types::PhoneFraudEvaluateResponsePolicy? + def challenge_channels: () -> Array[String] + def email: () -> Didit::Types::PhoneFraudEvaluateResponseEmail? + def existing_user: () -> bool + def exception: () -> String? + end + + class PhoneFraudEvaluateResponseEmail < Didit::Model + def risk: () -> String + def disposable: () -> bool + def domain_age_days: () -> Integer? + def reasons: () -> Array[String] + def email: () -> String + end + + class PhoneFraudEvaluateResponseMatchedRules < Didit::Model + def key: () -> String + def action: () -> String + end + + class PhoneFraudEvaluateResponsePolicy < Didit::Model + def policy_id: () -> String + def score: () -> Integer + def conditions_met: () -> Array[String] + end + + class PhoneFraudEventsCreateBatchResponse < Didit::Model + def accepted: () -> Integer? + def results: () -> Array[Didit::Types::PhoneFraudEventResult]? + end + + class PhoneFraudPoliciesListResponse < Didit::Model + def count: () -> Integer? + def `next`: () -> String? + def previous: () -> String? + def results: () -> Array[Didit::Types::PhoneFraudPolicy]? + end + + class PhoneFraudUpdateResponse < Didit::Model + def level: () -> String + def rules: () -> Array[Didit::Types::PhoneFraudRule] + def updated_at: () -> Time + def challenge_channels: () -> Array[String] + def sim_swap_within: () -> Integer + def daily_cap: () -> String? + end + + class PhoneLineTypeOverridesCreateResponse < Didit::Model + def override_id: () -> String + def phone_number: () -> String + def line_type: () -> String + def created_at: () -> Time + end + + class PhoneListsCheckResponse < Didit::Model + def allowed: () -> bool? + def blocked: () -> bool? + def matches: () -> Array[Didit::Types::PhoneListMatch]? + end + + class PhoneListsListEntriesResponse < Didit::Model + def count: () -> Integer? + def `next`: () -> String? + def previous: () -> String? + def results: () -> Array[Didit::Types::PhoneListEntry]? + end + + class PhoneRateLimitsListResponse < Didit::Model + def count: () -> Integer? + def `next`: () -> String? + def previous: () -> String? + def results: () -> Array[Didit::Types::PhoneRateLimit]? + end + + type phone_assess_risk_bulk_params = { file: Didit::upload, ?fields: Array[String], ?callback_url: String } + type phone_assess_risk_params = { phone_number: String, ?country_code: String, ?signals: Didit::Types::risk_signals, ?vendor_data: String, ?metadata: (Hash[String | Symbol, untyped])?, ?enable_social: bool } type phone_check_code_params = { phone_number: String, code: String, ?duplicated_phone_number_action: String, ?disposable_number_action: String, ?voip_number_action: String, ?enable_enrichment: bool, ?phone_intelligence_score_action: String, ?phone_type_risk_action: String, ?recent_port_action: String, ?low_phone_trust_action: String, ?enable_social: bool, ?phone_no_social_presence_action: String } + type phone_fraud_evaluate_params = { ?phone_number: String, ?email: String, ?action: String, ?ip_address: String, ?device_signals: String, ?existing_user: bool, ?trusted_user: bool, ?fraud_override: String } + + type phone_fraud_events_create_batch_params = { events: Array[Didit::Types::phone_fraud_events_create_batch_params_events] } + + type phone_fraud_events_create_batch_params_events = { ?type: String, ?phone_number: String, ?email: String, ?ip_address: String, ?device_signals: String, ?existing_user: bool, ?occurred_at: String, ?reference: String } + + type phone_fraud_update_params = { ?level: String, ?rules: Array[Didit::Types::phone_fraud_update_params_rules], ?challenge_channels: Array[String], ?sim_swap_within: Integer, ?daily_cap: String? } + + type phone_fraud_update_params_rules = { key: String, action: String, ?countries: Array[String], ?platforms: Array[String], ?scope: String } + + type phone_line_type_overrides_create_params = { phone_number: String, line_type: String, ?note: String } + + type phone_lists_add_params = { value: String, ?type: String, ?expires_at: Time | String, ?note: String } + + type phone_lists_check_params = { phone_number: String } + + type phone_rate_limits_create_params = { key: String, buckets: Array[Didit::Types::phone_rate_limits_create_params_buckets] } + + type phone_rate_limits_create_params_buckets = { max: Integer, interval: Integer } + + type phone_rate_limits_update_params = { buckets: Array[Didit::Types::phone_rate_limits_update_params_buckets] } + + type phone_rate_limits_update_params_buckets = { ?bucket_id: String, ?max: Integer, ?interval: Integer } + type phone_send_code_params = { phone_number: String, ?options: Didit::Types::phone_send_code_params_options, ?signals: Didit::Types::phone_send_code_params_signals, ?vendor_data: String, ?metadata: (Hash[String | Symbol, untyped])? } type phone_send_code_params_options = { ?code_size: Integer, ?locale: String, ?preferred_channel: String, ?use_white_label_customization: bool, ?sms_sender_name: String? } diff --git a/spec/generated/messages_spec.rb b/spec/generated/messages_spec.rb index 8d45cb0..13f8912 100644 --- a/spec/generated/messages_spec.rb +++ b/spec/generated/messages_spec.rb @@ -436,4 +436,45 @@ expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) exercise_readers(result) end + + it "messages.rules.create sends POST /v3/messages/rules/" do + calls = stub_api(status: 201, body: <<~'JSON') + { + "rule_id": "5b1e7a90-2c43-4d68-8f15-0a9c3e6d7b22" + } + JSON + result = client.messages.rules.create( + action: "block", + direction: "outbound", + match: { + prefix: "+88216" + }, + channels: [ + "sms" + ], + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/messages/rules/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "action" => "block", + "direction" => "outbound", + "match" => { + "prefix" => "+88216" + }, + "channels" => [ + "sms" + ] + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::MessagesRulesCreateResponse) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end end diff --git a/spec/generated/phone_spec.rb b/spec/generated/phone_spec.rb index f2fd097..a246793 100644 --- a/spec/generated/phone_spec.rb +++ b/spec/generated/phone_spec.rb @@ -81,6 +81,51 @@ exercise_readers(result) end + it "phone.assess_risk_bulk sends POST /v3/phone/risk/bulk/" do + calls = stub_api(status: 202, body: <<~'JSON') + { + "job_id": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55", + "status": "queued", + "total": 2400, + "processed": 0, + "results_url": null + } + JSON + result = client.phone.assess_risk_bulk( + fields: [ + "line_type", + "sim_swap" + ], + file: Didit::FilePart.new("fake-file-bytes", filename: "file.jpg", content_type: "image/jpeg"), + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/risk/bulk/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_multipart_body( + request, + fields: { + "fields" => "[\"line_type\",\"sim_swap\"]" + }, + files: { + "file" => [ + "file.jpg", + "image/jpeg", + "fake-file-bytes" + ] + } + ) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneRiskBulkJob) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + it "phone.check_code sends POST /v3/phone/check/" do calls = stub_api(status: 200, body: <<~'JSON') { @@ -174,6 +219,50 @@ exercise_readers(result) end + it "phone.download_risk_bulk_results sends GET /v3/phone/risk/bulk/{job_id}/results/" do + calls = stub_api(status: 200, body: "fake-binary-body", content_type: "text/csv") + result = client.phone.download_risk_bulk_results( + "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55" + ) + request = expect_api_request( + calls, + method: :get, + url: "https://verification.didit.me/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/results/", + query: [], + auth: :api_key, + accept: "text/csv, application/json" + ) + expect_no_body(request) + expect(result).to eq("fake-binary-body") + end + + it "phone.retrieve_risk_bulk sends GET /v3/phone/risk/bulk/{job_id}/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "job_id": "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55", + "status": "done", + "total": 2400, + "processed": 2400, + "results_url": "/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/results/" + } + JSON + result = client.phone.retrieve_risk_bulk( + "8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55" + ) + request = expect_api_request( + calls, + method: :get, + url: "https://verification.didit.me/v3/phone/risk/bulk/8c1f2d3e-5a47-4b90-8e21-7d3a9b6c4f55/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(result).to be_a(Didit::Types::PhoneRiskBulkJob) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + it "phone.send_code sends POST /v3/phone/send/" do calls = stub_api(status: 200, body: <<~'JSON') { @@ -214,4 +303,793 @@ expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) exercise_readers(result) end + + it "phone.fraud.evaluate sends POST /v3/phone/fraud/evaluate/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "decision": "allow", + "score": 12, + "matched_rules": [], + "policy": { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "score": 40, + "conditions_met": [ + "sim_swap" + ] + }, + "challenge_channels": [], + "email": null, + "existing_user": false, + "exception": null + } + JSON + result = client.phone.fraud.evaluate( + phone_number: "+34600000012", + action: "signup", + existing_user: false, + trusted_user: false, + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/fraud/evaluate/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "phone_number" => "+34600000012", + "action" => "signup", + "existing_user" => false, + "trusted_user" => false + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneFraudEvaluateResponse) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.fraud.update sends PATCH /v3/phone/fraud/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "level": "custom", + "rules": [ + { + "key": "sim_swap", + "action": "require_code", + "countries": [ + "GB", + "ES" + ] + } + ], + "challenge_channels": [ + "silent", + "whatsapp", + "passkey" + ], + "updated_at": "2026-11-21T10:00:00Z", + "sim_swap_within": 72, + "daily_cap": null + } + JSON + result = client.phone.fraud.update( + level: "custom", + rules: [ + { + key: "sim_swap", + action: "require_code", + countries: [ + "GB", + "ES" + ] + } + ], + challenge_channels: [ + "silent", + "whatsapp", + "passkey" + ], + sim_swap_within: 72, + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :patch, + url: "https://verification.didit.me/v3/phone/fraud/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "level" => "custom", + "rules" => [ + { + "key" => "sim_swap", + "action" => "require_code", + "countries" => [ + "GB", + "ES" + ] + } + ], + "challenge_channels" => [ + "silent", + "whatsapp", + "passkey" + ], + "sim_swap_within" => 72 + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneFraudUpdateResponse) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.fraud.events.create_batch sends POST /v3/phone/fraud/events/batch/" do + calls = stub_api(status: 207, body: <<~'JSON') + { + "accepted": 1, + "results": [ + { + "index": 0, + "event_id": "ae4f1a36-8c7a-4d25-9a49-3f6b0c2d7e55", + "status": "accepted", + "error": null + } + ] + } + JSON + result = client.phone.fraud.events.create_batch( + events: [ + { + type: "login", + phone_number: "+34600000012", + occurred_at: "2026-11-21T09:58:00Z", + reference: "login-99812" + } + ], + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/fraud/events/batch/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "events" => [ + { + "type" => "login", + "phone_number" => "+34600000012", + "occurred_at" => "2026-11-21T09:58:00Z", + "reference" => "login-99812" + } + ] + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneFraudEventsCreateBatchResponse) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.fraud.policies.create sends POST /v3/phone/fraud/policies/" do + calls = stub_api(status: 201, body: <<~'JSON') + { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + JSON + result = client.phone.fraud.policies.create( + name: "Payment check", + flow: "payment", + conditions: [ + { + signal: "sim_swap", + operator: "within_hours", + value: "72", + weight: 40 + } + ], + threshold: 60, + action: "challenge", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/fraud/policies/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "name" => "Payment check", + "flow" => "payment", + "conditions" => [ + { + "signal" => "sim_swap", + "operator" => "within_hours", + "value" => "72", + "weight" => 40 + } + ], + "threshold" => 60, + "action" => "challenge" + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneFraudPolicy) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.fraud.policies.delete sends DELETE /v3/phone/fraud/policies/{policy_id}/" do + calls = stub_api(status: 204, body: nil, content_type: nil) + result = client.phone.fraud.policies.delete( + "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :delete, + url: "https://verification.didit.me/v3/phone/fraud/policies/9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_nil + end + + it "phone.fraud.policies.list sends GET /v3/phone/fraud/policies/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + ] + } + JSON + result = client.phone.fraud.policies.list + request = expect_api_request( + calls, + method: :get, + url: "https://verification.didit.me/v3/phone/fraud/policies/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(result).to be_a(Didit::Page) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + expect(result.results).to all(be_a(Didit::Types::PhoneFraudPolicy)) + exercise_readers(result.results) + end + + it "phone.fraud.policies.retrieve sends GET /v3/phone/fraud/policies/{policy_id}/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + }, + { + "signal": "email_risk", + "operator": "eq", + "value": "high", + "weight": 30 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + JSON + result = client.phone.fraud.policies.retrieve( + "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44" + ) + request = expect_api_request( + calls, + method: :get, + url: "https://verification.didit.me/v3/phone/fraud/policies/9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(result).to be_a(Didit::Types::PhoneFraudPolicy) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.fraud.policies.update sends PATCH /v3/phone/fraud/policies/{policy_id}/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "policy_id": "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + "name": "Payment check", + "flow": "payment", + "conditions": [ + { + "signal": "sim_swap", + "operator": "within_hours", + "value": "72", + "weight": 40 + }, + { + "signal": "email_risk", + "operator": "eq", + "value": "high", + "weight": 30 + } + ], + "threshold": 60, + "action": "challenge", + "updated_at": "2026-11-21T09:00:00Z" + } + JSON + result = client.phone.fraud.policies.update( + "9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44", + name: "Payment check", + flow: "payment", + conditions: [ + { + signal: "sim_swap", + operator: "within_hours", + value: "72", + weight: 40 + } + ], + threshold: 60, + action: "challenge", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :patch, + url: "https://verification.didit.me/v3/phone/fraud/policies/9d3e0f25-7b69-4c14-8f38-2e5a9b1c6d44/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "name" => "Payment check", + "flow" => "payment", + "conditions" => [ + { + "signal" => "sim_swap", + "operator" => "within_hours", + "value" => "72", + "weight" => 40 + } + ], + "threshold" => 60, + "action" => "challenge" + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneFraudPolicy) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.line_type_overrides.create sends POST /v3/phone/line-type-overrides/" do + calls = stub_api(status: 201, body: <<~'JSON') + { + "override_id": "7c2d9e14-6a58-4b03-9e27-1d4f8a0b5c33", + "phone_number": "+34911234567", + "line_type": "landline", + "created_at": "2026-11-21T09:00:00Z" + } + JSON + result = client.phone.line_type_overrides.create( + phone_number: "+34911234567", + line_type: "landline", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/line-type-overrides/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "phone_number" => "+34911234567", + "line_type" => "landline" + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneLineTypeOverridesCreateResponse) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.line_type_overrides.delete sends DELETE /v3/phone/line-type-overrides/{override_id}/" do + calls = stub_api(status: 204, body: nil, content_type: nil) + result = client.phone.line_type_overrides.delete( + "7c2d9e14-6a58-4b03-9e27-1d4f8a0b5c33", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :delete, + url: "https://verification.didit.me/v3/phone/line-type-overrides/7c2d9e14-6a58-4b03-9e27-1d4f8a0b5c33/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_nil + end + + it "phone.lists.add sends POST /v3/phone/lists/{list_id}/entries/" do + calls = stub_api(status: 201, body: <<~'JSON') + { + "entry_id": "bf5a2b47-9d8b-4e36-8b5a-407c1d3e8f66", + "list_id": "block", + "value": "+88216", + "expires_at": null, + "type": "prefix", + "source": "api" + } + JSON + result = client.phone.lists.add( + "block", + value: "+88216", + type: "prefix", + note: "Pumping from this prefix", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/lists/block/entries/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "value" => "+88216", + "type" => "prefix", + "note" => "Pumping from this prefix" + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneListEntry) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.lists.check sends POST /v3/phone/lists/check/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "allowed": false, + "blocked": true, + "matches": [ + { + "list_id": "block", + "entry_id": "c06b3c58-ae9c-4f47-9c6b-518d2e4f9a77", + "type": "prefix" + } + ] + } + JSON + result = client.phone.lists.check( + phone_number: "+447700900123", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/lists/check/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "phone_number" => "+447700900123" + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneListsCheckResponse) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.lists.list_entries sends GET /v3/phone/lists/{list_id}/entries/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "entry_id": "c06b3c58-ae9c-4f47-9c6b-518d2e4f9a77", + "value": "+4475", + "type": "prefix", + "expires_at": null, + "source": "alert" + } + ] + } + JSON + result = client.phone.lists.list_entries( + "block" + ) + request = expect_api_request( + calls, + method: :get, + url: "https://verification.didit.me/v3/phone/lists/block/entries/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(result).to be_a(Didit::Page) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + expect(result.results).to all(be_a(Didit::Types::PhoneListEntry)) + exercise_readers(result.results) + end + + it "phone.lists.remove sends DELETE /v3/phone/lists/{list_id}/entries/{entry_id}/" do + calls = stub_api(status: 204, body: nil, content_type: nil) + result = client.phone.lists.remove( + "block", + "bf5a2b47-9d8b-4e36-8b5a-407c1d3e8f66", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :delete, + url: "https://verification.didit.me/v3/phone/lists/block/entries/bf5a2b47-9d8b-4e36-8b5a-407c1d3e8f66/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_nil + end + + it "phone.rate_limits.create sends POST /v3/phone/rate-limits/" do + calls = stub_api(status: 201, body: <<~'JSON') + { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 5, + "interval": 3600 + } + ] + } + JSON + result = client.phone.rate_limits.create( + key: "user_id", + buckets: [ + { + max: 5, + interval: 3600 + } + ], + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :post, + url: "https://verification.didit.me/v3/phone/rate-limits/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "key" => "user_id", + "buckets" => [ + { + "max" => 5, + "interval" => 3600 + } + ] + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneRateLimit) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.rate_limits.delete sends DELETE /v3/phone/rate-limits/{rate_limit_id}/" do + calls = stub_api(status: 204, body: nil, content_type: nil) + result = client.phone.rate_limits.delete( + "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :delete, + url: "https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_nil + end + + it "phone.rate_limits.list sends GET /v3/phone/rate-limits/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 5, + "interval": 3600, + "in_use": 2 + } + ] + } + ] + } + JSON + result = client.phone.rate_limits.list + request = expect_api_request( + calls, + method: :get, + url: "https://verification.didit.me/v3/phone/rate-limits/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(result).to be_a(Didit::Page) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + expect(result.results).to all(be_a(Didit::Types::PhoneRateLimit)) + exercise_readers(result.results) + end + + it "phone.rate_limits.retrieve sends GET /v3/phone/rate-limits/{rate_limit_id}/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 5, + "interval": 3600, + "in_use": 2 + } + ] + } + JSON + result = client.phone.rate_limits.retrieve( + "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01" + ) + request = expect_api_request( + calls, + method: :get, + url: "https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(result).to be_a(Didit::Types::PhoneRateLimit) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.rate_limits.update sends PATCH /v3/phone/rate-limits/{rate_limit_id}/" do + calls = stub_api(status: 200, body: <<~'JSON') + { + "rate_limit_id": "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "key": "user_id", + "buckets": [ + { + "bucket_id": "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max": 10, + "interval": 86400, + "in_use": 2 + } + ] + } + JSON + result = client.phone.rate_limits.update( + "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + buckets: [ + { + bucket_id: "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + max: 10, + interval: 86400 + } + ], + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :patch, + url: "https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_json_body(request, { + "buckets" => [ + { + "bucket_id" => "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + "max" => 10, + "interval" => 86400 + } + ] + }) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_a(Didit::Types::PhoneRateLimit) + expect(result.to_h).to eq(JSON.parse(calls.body, symbolize_names: true)) + exercise_readers(result) + end + + it "phone.rate_limits.buckets.delete sends DELETE /v3/phone/rate-limits/{rate_limit_id}/buckets/{bucket_id}/" do + calls = stub_api(status: 204, body: nil, content_type: nil) + result = client.phone.rate_limits.buckets.delete( + "3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01", + "0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10", + idempotency_key: "idem-key-1" + ) + request = expect_api_request( + calls, + method: :delete, + url: "https://verification.didit.me/v3/phone/rate-limits/3f6c1b52-8d4e-4a7b-9c10-5e2a7d9b1c01/buckets/0b6f6a4e-3f1a-4c6e-9a53-6b1d2f9c7a10/", + query: [], + auth: :api_key, + accept: "application/json" + ) + expect_no_body(request) + expect(request.headers["Idempotency-Key"]).to eq("idem-key-1") + expect(result).to be_nil + end end