A Radar attempt represents a sign-in or signup attempt and includes context such as IP address and user agent. The Radar engine assesses attempts for risk and returns a decision that you can use to drive behavior in your application.
Assess a request for risk using the Radar engine and receive a verdict.
curl --request POST \ --url "https://api.workos.com/radar/attempts" \ --header "Authorization: Bearer sk_example_123456789" \ --header "Content-Type: application/json" \ -d @- <<'BODY' { "ip_address": "49.78.240.97", "user_agent": "Mozilla/5.0", "email": "user@example.com", "auth_method": "Password", "action": "sign-in" } BODY
{ "verdict": "block", "reason": "Detected enabled Radar control", "attempt_id": "radar_att_01HZBC6N1EB1ZY7KG32X", "control": "bot_detection", "blocklist_type": "ip_address" }
| curl --request POST \ | |
| --url "https://api.workos.com/radar/attempts" \ | |
| --header "Authorization: Bearer sk_example_123456789" \ | |
| --header "Content-Type: application/json" \ | |
| -d @- <<'BODY' | |
| { | |
| "ip_address": "49.78.240.97", | |
| "user_agent": "Mozilla/5.0", | |
| "email": "user@example.com", | |
| "auth_method": "Password", | |
| "action": "sign-in" | |
| } | |
| BODY |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.radar.create_attempt( | |
| ip_address: "49.78.240.97", | |
| user_agent: "Mozilla/5.0", | |
| email: "user@example.com", | |
| auth_method: "Password", | |
| action: "sign-in" | |
| ) |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.radar.create_attempt( | |
| ip_address="49.78.240.97", | |
| user_agent="Mozilla/5.0", | |
| email="user@example.com", | |
| auth_method="Password", | |
| action="sign-in", | |
| ) |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.Radar().CreateAttempt(context.Background(), &workos.RadarCreateAttemptParams{ | |
| IPAddress: "49.78.240.97", | |
| UserAgent: "Mozilla/5.0", | |
| Email: "user@example.com", | |
| AuthMethod: "Password", | |
| Action: "sign-in", | |
| }) | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos | |
| ->radar() | |
| ->createAttempt( | |
| ipAddress: "49.78.240.97", | |
| userAgent: "Mozilla/5.0", | |
| email: "user@example.com", | |
| authMethod: "Password", | |
| action: "sign-in", | |
| ); |
| import com.workos.WorkOS; | |
| import com.workos.radar.RadarApi.CreateAttemptOptions; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| CreateAttemptOptions options = CreateAttemptOptions.builder() | |
| .ipAddress("49.78.240.97") | |
| .userAgent("Mozilla/5.0") | |
| .email("user@example.com") | |
| .authMethod("Password") | |
| .action("sign-in") | |
| .build(); | |
| workos.radar.createAttempt(options); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.Radar.CreateAttemptAsync(new RadarCreateAttemptOptions { | |
| IpAddress = "49.78.240.97", | |
| UserAgent = "Mozilla/5.0", | |
| Email = "user@example.com", | |
| AuthMethod = "Password", | |
| Action = "sign-in", | |
| }); |
| use workos::Client; | |
| use workos::radar::CreateAttemptParams; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .radar() | |
| .create_attempt( | |
| CreateAttemptParams { | |
| ip_address: "49.78.240.97".into(), | |
| user_agent: "Mozilla/5.0".into(), | |
| email: "user@example.com".into(), | |
| auth_method: "Password".into(), | |
| action: "sign-in".into(), | |
| ..Default::default() | |
| } | |
| ) | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "verdict": "block", | |
| "reason": "Detected enabled Radar control", | |
| "attempt_id": "radar_att_01HZBC6N1EB1ZY7KG32X", | |
| "control": "bot_detection", | |
| "blocklist_type": "ip_address" | |
| } |
POST/radar /attemptsReturns You may optionally inform Radar that an authentication attempt or challenge was successful using this endpoint. Some Radar controls depend on tracking recent successful attempts, such as impossible travel.
curl --request PUT \ --url "https://api.workos.com/radar/attempts/radar_att_01HZBC6N1EB1ZY7KG32X" \ --header "Authorization: Bearer sk_example_123456789" \ --header "Content-Type: application/json" \ -d @- <<'BODY' { "challenge_status": "success", "attempt_status": "success" } BODY
| curl --request PUT \ | |
| --url "https://api.workos.com/radar/attempts/radar_att_01HZBC6N1EB1ZY7KG32X" \ | |
| --header "Authorization: Bearer sk_example_123456789" \ | |
| --header "Content-Type: application/json" \ | |
| -d @- <<'BODY' | |
| { | |
| "challenge_status": "success", | |
| "attempt_status": "success" | |
| } | |
| BODY |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.radar.update_attempt(id: "radar_att_01HZBC6N1EB1ZY7KG32X") |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.radar.update_attempt(id_="radar_att_01HZBC6N1EB1ZY7KG32X") |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.Radar().UpdateAttempt(context.Background(), "radar_att_01HZBC6N1EB1ZY7KG32X") | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos->radar()->updateAttempt(id: "radar_att_01HZBC6N1EB1ZY7KG32X"); |
| import com.workos.WorkOS; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| workos.radar.updateAttempt("radar_att_01HZBC6N1EB1ZY7KG32X"); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.Radar.UpdateAttemptAsync("radar_att_01HZBC6N1EB1ZY7KG32X"); |
| use workos::Client; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .radar() | |
| .update_attempt("radar_att_01HZBC6N1EB1ZY7KG32X") | |
| .await?; | |
| Ok(()) | |
| } |
PUT/radar /attempts /:idParameters Returns